-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSendScreenshot.py
More file actions
46 lines (40 loc) · 1.36 KB
/
SendScreenshot.py
File metadata and controls
46 lines (40 loc) · 1.36 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import logging
from PIL import ImageGrab, Image
from pixoo import Pixoo
# Configure logging
logging.basicConfig(level=logging.DEBUG)
# Replace with your Pixoo's IP address
PIXOO_IP = '192.168.1.215'
# Initialize Pixoo device
try:
logging.debug(f"Attempting to connect to Pixoo at IP: {PIXOO_IP}")
pixoo = Pixoo(PIXOO_IP)
logging.debug("Successfully connected to Pixoo.")
except Exception as e:
logging.error(f"Failed to connect to Pixoo: {e}")
exit(1)
# Capture the current screen
try:
logging.debug("Capturing the screen.")
screenshot = ImageGrab.grab()
logging.debug("Screen captured successfully.")
except Exception as e:
logging.error(f"Failed to capture the screen: {e}")
exit(1)
# Resize the screenshot to 64x64 pixels
try:
logging.debug("Resizing the screenshot to 64x64 pixels.")
resized_screenshot = screenshot.resize((64, 64), Image.BICUBIC)
logging.debug("Screenshot resized successfully.")
except Exception as e:
logging.error(f"Failed to resize the screenshot: {e}")
exit(1)
# Send the image to Pixoo
try:
logging.debug("Sending the image to Pixoo.")
pixoo.draw_image(resized_screenshot)
pixoo.push()
logging.debug("Image sent and displayed successfully.")
except Exception as e:
logging.error(f"Failed to send the image to Pixoo: {e}")
exit(1)