-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathauto_reply.py
More file actions
89 lines (80 loc) · 2.47 KB
/
auto_reply.py
File metadata and controls
89 lines (80 loc) · 2.47 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
import os
import time
import pyautogui
import up
import message
import check
import random
call_count = 0
pyautogui.PAUSE = 0.5
pyautogui.FAILSAFE = True
def click_button() -> None:
while True:
try:
button_pos = pyautogui.locateCenterOnScreen('button.png', confidence=0.9)
if button_pos:
pyautogui.click(button_pos)
time.sleep(1)
break
except pyautogui.ImageNotFoundException:
break
def main() -> None:
global call_count
call_count += 1
up.up_window("微信")
time.sleep(0.5)
pyautogui.hotkey('alt','printscreen')
if call_count == 1:
os.system("start https://chat.baidu.com")
time.sleep(10)
else:
pyautogui.hotkey('alt', 'tab')
pyautogui.click(520, 911)
try:
button_pos = pyautogui.locateCenterOnScreen('chinese.png', confidence=0.9)
if button_pos:
time.sleep(1)
except pyautogui.ImageNotFoundException:
pyautogui.press("shift")
pyautogui.write("bang'wo'hui'fu'zhe'tiao'xiao'xi")
pyautogui.press("space")
pyautogui.write("zhi'yao'hui'fu")
pyautogui.press("space")
pyautogui.hotkey('ctrl', 'v')
time.sleep(5)
pyautogui.press("enter")
while check.is_clipboard_image(): # 防止点击无效
try:
button_pos = pyautogui.locateCenterOnScreen(random.choice(['copy.png', 'copy_icon.png']), confidence=0.99)
if button_pos:
pyautogui.click(button_pos)
time.sleep(1)
else:
click_button()
time.sleep(1)
except pyautogui.ImageNotFoundException:
click_button()
time.sleep(1)
pyautogui.hotkey('alt', 'tab')
time.sleep(2)
pyautogui.hotkey('ctrl', 'v')
pyautogui.press("enter")
if __name__ == "__main__":
if os.name != "nt":
print("支持linux")
exit(1)
print("开始自动回复,按Ctrl+C结束")
time.sleep(5)
try:
main()
time.sleep(0.5)
initial = message.get_screen_roi()
print("开始监控界面变化...")
while True:
is_changed, diff_img = message.detect_screen_change(initial)
if is_changed:
main()
initial = message.get_screen_roi() # 更新快照
time.sleep(1)
except KeyboardInterrupt, pyautogui.FailSafeException:
print("\n自动回复已结束")