-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrols.py
51 lines (43 loc) · 1.44 KB
/
controls.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
import pyautogui
class Scroll:
scroll_started = False
frame_count = 1
previous_diff = 1
start_pos = 1
diff = 1
scroll_threshold = 1.6
def scroll(current):
print(Scroll.frame_count)
if Scroll.scroll_started == False:
Scroll.start_pos = current
Scroll.scroll_started = True
Scroll.frame_count = 0
if Scroll.frame_count == 5:
Scroll.frame_count = 0
Scroll.previous_diff = Scroll.diff
pyautogui.scroll(150 if Scroll.previous_diff<0.0 else -150)
Scroll.diff = current - Scroll.start_pos
if(abs(Scroll.previous_diff-Scroll.diff) <= Scroll.scroll_threshold):
Scroll.frame_count += 1
Scroll.frame_count = 0
Scroll.previous_diff = Scroll.diff
class Drag:
clicked = False
def drag():
if(Drag.drag_started == True):
Drag.frame_count += 1
print(f"framecount: {Drag.frame_count}")
else:
Drag.frame_count = 0
Drag.drag_started = True
if(Drag.frame_count == 5):
if(Drag.clicked == False):
print("Drag started")
pyautogui.click()
pyautogui.sleep(0.4)
pyautogui.mouseDown()
Drag.clicked = True
else:
print("Drag ended")
pyautogui.mouseUp()
Drag.clicked = False