Update client.py
This commit is contained in:
25
client.py
Normal file
25
client.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import socket
|
||||
from pynput.mouse import Controller
|
||||
|
||||
mouse = Controller()
|
||||
|
||||
HOST = '0.0.0.0'
|
||||
PORT = 2025
|
||||
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
sock.bind((HOST, PORT))
|
||||
|
||||
print(f"listening on {HOST}:{PORT}")
|
||||
|
||||
try:
|
||||
while True:
|
||||
data, addr = sock.recvfrom(1024)
|
||||
x_str, y_str = data.decode().split(',')
|
||||
x = float(x_str)
|
||||
y = float(y_str)
|
||||
mouse.position = (x, y)
|
||||
print(f"Moved mouse to: X={x}, Y={y}")
|
||||
except KeyboardInterrupt:
|
||||
print("UDP server shutting down.")
|
||||
finally:
|
||||
sock.close()
|
||||
Reference in New Issue
Block a user