-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistners.py
91 lines (80 loc) · 2.61 KB
/
listners.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
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import threading
import win32api
import win32con
import send
import time
import mouse
import keyboard
import clipboard
import runtimeREF
import httpServer
relativeClients = {"T": "192.168.1.105"}
screen_width = win32api.GetSystemMetrics(win32con.SM_CXSCREEN)
screen_height = win32api.GetSystemMetrics(win32con.SM_CYSCREEN)
border_height = win32api.GetSystemMetrics(win32con.SM_CYBORDER)
# start listners
activeThreads = {}
rawMouseInput = threading.Thread(target=mouse.getMouseRawInput)
rawMouseInput.start()
onCopy = threading.Thread(target=clipboard.onCopy)
onCopy.start()
httpServerRef = threading.Thread(target=httpServer.startServer)
httpServerRef.start()
activeThreads["rawMouseInput"] = rawMouseInput
activeThreads["onCopy"] = onCopy
activeThreads["httpServerRef"] = httpServerRef
mhook = mouse.listner()
khook = keyboard.listner()
def getEdge():
currentEdge = None
while True:
try:
cursor_x, cursor_y = win32api.GetCursorPos()
if cursor_x == 0:
currentEdge = "L" # LEFT
elif cursor_x == screen_width - 1:
currentEdge = "R" # RIGHT
elif cursor_y == 0:
currentEdge = "T" # TOP
elif cursor_y == screen_height - border_height:
currentEdge = "B" # BOTTOM
if(currentEdge != None and relativeClients[currentEdge] in runtimeREF.clients): # If client is online
return currentEdge, cursor_x, cursor_y
else:
currentEdge = None
time.sleep(0.1)
except:
time.sleep(0.1)
continue
def active(arg):
if (arg["ACTIVEIP"] == runtimeREF.HOSTIP):
if (mhook._listner._running):
try:
win32api.SetCursorPos((arg["Width"], 5))
except:
pass
mhook.unSuppress()
khook.unSuppress()
else:
pass
runtimeREF.ACTIVEIP = arg["ACTIVEIP"]
while True:
Edge = getEdge()
try: # If client does not exist in relative borders
runtimeREF.ACTIVEIP = relativeClients[Edge[0]]
send.sendALL(fn=50, ACTIVEIP=runtimeREF.ACTIVEIP, Width=Edge[1], Height=Edge[2])
mhook.suppress()
khook.suppress()
win32api.SetCursorPos((683, 384))
break
except:
continue
def setActiveIP(arg):
runtimeREF.ACTIVEIP = arg["ACTIVEIP"]
if(runtimeREF.ACTIVEIP != runtimeREF.HOSTIP):
mhook.suppress()
khook.suppress()
win32api.SetCursorPos((683, 384))
print(runtimeREF.ACTIVEIP)
if __name__ == "__main__":
print(getEdge())