-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreenCapture.py
31 lines (27 loc) · 908 Bytes
/
screenCapture.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pyautogui
import time
import base64
from io import BytesIO
import threading
class ssCapture():
def __init__(self):
image = pyautogui.screenshot()
buffer = BytesIO()
image.save(buffer,format='jpeg')
byte_data = buffer.getvalue()
base64_data = base64.b64encode(byte_data)
self.base64 = base64_data.decode()
self.stop_event = threading.Event()
def capture(self):
print("Capture starting...")
while not self.stop_event.is_set():
image = pyautogui.screenshot()
buffer = BytesIO()
image.save(buffer,format='jpeg')
byte_data = buffer.getvalue()
base64_data = base64.b64encode(byte_data)
self.base64 = base64_data.decode()
time.sleep(0.5)
# print("Captured...")
print("Capture ending...")
screenVar = ssCapture()