-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
98 lines (60 loc) · 1.45 KB
/
Copy pathscript.py
File metadata and controls
98 lines (60 loc) · 1.45 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
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
92
93
94
95
96
97
98
import pyautogui
import time
import datetime
import subprocess
POPUP_IMAGE = "imgs/popup.png"
# reload tab
def reload_page():
subprocess.run([
"osascript",
"-e",
'''
tell application "Brave Browser"
activate
tell application "System Events"
keystroke "r" using command down
end tell
end tell
'''
])
print("Đã reload")
# click giữa màn hình
def click_center():
width, height = pyautogui.size()
x = width // 2
y = height // 2
pyautogui.click(x, y)
print("Đã click giữa màn hình")
# di chuột ra góc để không đè lên popup (dễ detect hơn)
def move_cursor_to_corner():
pyautogui.moveTo(20, 20, duration=0.2)
time.sleep(0.15)
# check popup
def check_popup():
try:
location = pyautogui.locateOnScreen(
POPUP_IMAGE,
confidence=0.7,
grayscale=True
)
if location:
time.sleep(0.5)
click_center()
time.sleep(2)
except pyautogui.ImageNotFoundException:
pass
# check reload time
def check_reload():
now = datetime.datetime.now()
if now.hour == 0 and now.minute == 5:
reload_page()
time.sleep(60)
# main loop
print("Script started")
time.sleep(3)
while True:
time.sleep(10)
move_cursor_to_corner()
check_popup()
check_reload()
time.sleep(1)