-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbig_boss.py
99 lines (80 loc) · 2.17 KB
/
big_boss.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
92
93
94
95
96
97
98
99
from game_ctl import *
import win32com.client
import os
import threading
import logsystem
# 初始化对象
log = logsystem.WriteLog()
yys = GameControl(u'阴阳师-网易游戏')
log.writeinfo('Registration successful')
def is_admin():
'''
UAC申请,获得管理员权限
'''
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
def get_screen():
'''
每隔2s获取一次截图,截图缓存至yys.screen中
'''
while True:
yys.window_full_shot()
time.sleep(2)
def wait_game_img(img_path):
"""
等待游戏图像,每隔2s查询1次,查询成功后休息10再继续
:param img_path: 图片路径
"""
try:
while True:
maxVal, maxLoc = yys.find_img(img_path)
if maxVal > 0.97:
yys.activate_window()
log.writeinfo('Figure found: '+img_path)
time.sleep(8)
time.sleep(2)
except:
# 如果错误则输出警告
log.writeinfo("Threading error! " + img_path)
def start():
"""
启动
"""
# 设置图片路径
info = "img"
# 获取所有待查询的图片
listfile = os.listdir(info)
# 激活窗口
yys.activate_window()
log.writeinfo('Activation successful')
time.sleep(1)
# 启动截图
t = threading.Thread(target=get_screen)
t.start()
time.sleep(1)
# 对每一个待查询的图片启动一个单一的线程
for figure in listfile:
if figure[-4:] == '.png':
path = 'img\\'+figure
log.writeinfo('Files: ' + path)
t = threading.Thread(
target=wait_game_img, args=(path,))
t.start()
if __name__ == "__main__":
log.writeinfo('python version: %s', sys.version)
try:
# 检测管理员权限
if is_admin():
log.writeinfo('UAC pass')
# 开始
start()
else:
ctypes.windll.shell32.ShellExecuteW(
None, "runas", sys.executable, __file__, None, 1)
except KeyboardInterrupt:
log.writeinfo('terminated')
os._exit(0)
else:
pass