From a5a758abc5e02a0b7d4b13d20b9a718664df8733 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Wed, 17 Apr 2019 22:45:42 +0300 Subject: [PATCH] #DaemonServerScreenshotPrototype #NeedPILInPython --- HowToUsePIP.txt | 3 ++- .../RobotDaemon/RobotDaemonServerWeb/Index.xhtml | 3 ++- Orchestrator/RobotDaemon/robotDaemonServer.py | 13 +++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/HowToUsePIP.txt b/HowToUsePIP.txt index 20922075..b5a20d30 100644 --- a/HowToUsePIP.txt +++ b/HowToUsePIP.txt @@ -1,3 +1,4 @@ pip3 install numpy -python -m pip install --upgrade pip \ No newline at end of file +python -m pip install --upgrade pip +pillow \ No newline at end of file diff --git a/Orchestrator/RobotDaemon/RobotDaemonServerWeb/Index.xhtml b/Orchestrator/RobotDaemon/RobotDaemonServerWeb/Index.xhtml index 1d4fcc98..280732ac 100644 --- a/Orchestrator/RobotDaemon/RobotDaemonServerWeb/Index.xhtml +++ b/Orchestrator/RobotDaemon/RobotDaemonServerWeb/Index.xhtml @@ -129,7 +129,8 @@
- + + GetScreenshot
diff --git a/Orchestrator/RobotDaemon/robotDaemonServer.py b/Orchestrator/RobotDaemon/robotDaemonServer.py index 1f2cbaf7..abc246a0 100644 --- a/Orchestrator/RobotDaemon/robotDaemonServer.py +++ b/Orchestrator/RobotDaemon/robotDaemonServer.py @@ -6,7 +6,14 @@ import subprocess import time import zlib import os +import PIL +from PIL import ImageGrab from threading import Thread +def SaveScreenshot(inFilePath): + # grab fullscreen + lScreenshot = ImageGrab.grab() + # save image file + lScreenshot.save('screenshot.png') class RobotDaemonServer(Thread): def __init__(self,name): @@ -59,6 +66,12 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): #Мост между файлом и http запросом (новый формат) if self.path == '/favicon.ico': self.SendResponseContentTypeFile('image/x-icon',"..\\..\\favicon.ico") + #Получить скриншот + if self.path == '/GetScreenshot': + #Сохранить файл на диск + SaveScreenshot("Screenshot.png") + self.SendResponseContentTypeFile('image/png',"Screenshot.png") + #Action ObjectInspector GetObjectList if self.path == '/ObjectDetector/JSONGetWindowList': #ReadRequest