-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
60 lines (46 loc) · 1.25 KB
/
server.py
File metadata and controls
60 lines (46 loc) · 1.25 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import socket
import pyautogui
pyautogui.FAILSAFE = False
pyautogui.PAUSE = 0
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
host = "0.0.0.0"
port = 2345
server_config = (host, port)
s.bind(server_config)
print("server running:")
mousedown = 0
# single_click_count = 0
while True:
data, addr = s.recvfrom(15)
data = data.decode()
coord = data.split(":")
x = coord[0]
y = coord[1]
z = coord[2]
if z == '0':
# if single_click_count == 0:
# pyautogui.moveTo(int(y), int(x))
# single_click_count = single_click_count+1
mousedown = 0
pyautogui.mouseUp()
# else:
# single_click_count = 0
if z == '1':
pyautogui.click(button='left')
if z == '2':
pyautogui.doubleClick(button='left')
if z == '3':
pyautogui.click(button='right')
if z == '4':
pyautogui.moveTo(int(y), int(x))
if z == '5' or z == '6':
pyautogui.dragTo(int(y), int(x), button='left')
# if mousedown != 1:
# pyautogui.mouseUp()
# pyautogui.moveTo(int(y), int(x))
# mousedown = 1
# pyautogui.mouseDown()
# pyautogui.moveTo(int(y), int(x))
# else:
# mousedown = 0
print(data)