Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes and new features #4

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .pylint.d/Base_func_wormhole1.stats
Binary file not shown.
39 changes: 32 additions & 7 deletions Base_func_wormhole.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
import Global_Config as gc
#from Notice import sent_message

sys.path.append(gc.default_dir)


sys.path.append(gc.default_dir)

def init_wormhole():
'''
Initialize the wormhole window.
Expand All @@ -31,26 +32,47 @@ def init_wormhole():

'''
hwnd = win32gui.FindWindow("Qt5QWindowIcon",gc.config[gc.const_phone]["name"]) # 窗口
win32gui.SetWindowPos(hwnd,win32con.HWND_TOPMOST,gc.const_position,0,gc.config[gc.const_phone]["length"],649,0)
win32gui.SetWindowPos(hwnd,
win32con.HWND_TOPMOST,gc.const_position,
0,
gc.config[gc.const_phone]["width"],
gc.config[gc.const_phone]["height"],
0)


class Fuse:
def __init__(self):
init_wormhole()
self.TimeOutNum = 0
self.TimeOutMax = 10
self.value = 0
self.tolerant_time = 50 #截取50张图片后仍未发现对应目标则报错
#防止程序死在死循环里
self.tolerant_time = 10 #截取50张图片后仍未发现对应目标则报错
#防止程序死在死循环里

def set_acceptable_time(self, time_per_loop, max_waiting = 60): #seconds
self.tolerant_time = int( max_waiting // time_per_loop)

def increase(self):
self.value += 1
# print("Fuse: tolerant is %d, value is %d" % (self.tolerant_time, self.value))

def increase_time_out(self):
self.TimeOutNum += 1

def reset_timeout(self):
pass

def reset(self):
self.TimeOutNum = 0
self.value = 0

def alarm(self):
if self.value >= self.tolerant_time:
#sent_message(text='【FGO】: Encounter a fuse error.')
print("Fuse Error!")
sys.exit(0)
if self.TimeOutNum >= self.TimeOutMax:
print("Connection Lost")
sys.exit(0)


def match_template(filename,show_switch=False,err=0.85):
Expand Down Expand Up @@ -166,8 +188,9 @@ def window_capture():

#img = cv.imread(filename)
#截取出ios屏幕区域
cropped = img[16:height-26, (21+gc.config[gc.const_phone]["bias"]):width-(21+gc.config[gc.const_phone]["bias"])] # 裁剪坐标为[y0:y1, x0:x1]
#cv.imwrite('C:/Users/Paul/Desktop/test/3.jpg', cropped) #for testing
cropped = img[(16+gc.config[gc.const_phone]["y_deviation"]):height-(26+gc.config[gc.const_phone]["y_deviation"]),
(21+gc.config[gc.const_phone]["x_deviation"]):width-(21+gc.config[gc.const_phone]["x_deviation"])] # 裁剪坐标为[y0:y1, x0:x1]
# cv.imwrite('C:/Users/Paul/Desktop/test/3.jpg', cropped) #for testing

win32gui.DeleteObject(saveBitMap.GetHandle()) #释放内存
saveDC.DeleteDC()
Expand All @@ -176,3 +199,5 @@ def window_capture():

return cropped

match_template("Menu_button")

Loading