From 9dede2eaa1d3e68be387c5fd612eb48226a54c9d Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 04 八月 2023 16:07:22 +0800 Subject: [PATCH] HOST修改 --- gui_wx.py | 88 +++++++------------------------------------ 1 files changed, 15 insertions(+), 73 deletions(-) diff --git a/gui_wx.py b/gui_wx.py index 395fa4e..299a24a 100644 --- a/gui_wx.py +++ b/gui_wx.py @@ -318,15 +318,23 @@ import log +# 璇嗗埆鍚岃姳椤虹湅鐩橀〉闈笂闈㈢殑浠g爜 def ocr_ths_code(): hwnd = ths_util.get_ths_main_content_hwnd() if not hwnd: raise Exception("鐪嬬洏椤甸潰鍙ユ焺鏈幏鍙栧埌") # 鍙ユ焺鎴浘 + # 瀹為檯浣嶇疆(宸�,涓�,鍙�,涓�) rect = win32gui.GetWindowRect(hwnd) - # hwnd_width = (rect[2] - rect[0]) * 15 // 10 + + # 鏍煎紡涓�:锛堜笂杈硅窛,瀹藉害,楂樺害锛� rect_ = setting.get_ths_auto_code_rect() - img = win32_util.window_capture(hwnd, (0, rect_[0], rect_[1], rect_[0] + rect_[2])) + scale = 1.5 + if len(rect_) > 3: + scale = rect_[3] + width = int((rect[2] - rect[0]) * scale) + left = width - rect_[1] + img = win32_util.window_capture(hwnd, (left, rect_[0], width - 1, rect_[0] + rect_[2]), scale) clip_img, details = opencv_util.clip_ths_code_area(img) start_time = time.time() code = ocr_util.recognize_code(clip_img) @@ -342,73 +350,6 @@ return code -# -# # 浠g爜灞炴�� -# class CodeAttributeFrame(wx.Frame): -# def __init__(self): -# wx.Frame.__init__(self, None, -1, "灞炴��", -# style=wx.CAPTION ^ wx.RESIZE_BORDER ^ wx.MINIMIZE_BOX ^ wx.CLOSE_BOX ^ wx.STAY_ON_TOP, -# size=(200, 300)) -# self.SetBackgroundColour(wx.Colour(224, 224, 224)) -# self.SetTransparent(230) -# self.Bind(wx.EVT_CLOSE, self.OnExit) -# # 璇诲彇閰嶇疆淇℃伅 -# window_info = setting.get_code_attribute_window_info() -# if window_info: -# self.SetPosition(wx.Point(window_info[0], window_info[1])) -# self.Size = wx.Size(window_info[2], window_info[3]) -# -# bs = wx.BoxSizer(wx.VERTICAL) -# -# self.label_code_name = wx.StaticText(self, label="") -# -# self.label_atrribute = wx.StaticText(self, label="") -# -# self.label_error = wx.StaticText(self, label="") -# self.label_error.SetForegroundColour(wx.Colour(255, 0, 0)) -# -# bs.Add(self.label_code_name, 0, wx.LEFT | wx.TOP, 10) -# bs.Add(self.label_atrribute, 0, wx.LEFT | wx.TOP, 10) -# bs.Add(self.label_error, 0, wx.LEFT | wx.TOP, 10) -# -# self.SetSizer(bs) -# -# def __request(self, code): -# client = socket.socket() # 鐢熸垚socket锛岃繛鎺erver -# ip_port = (SERVER_HOST, SOCKET_PORT) # server鍦板潃鍜岀鍙e彿锛堟渶濂芥槸10000浠ュ悗锛� -# client.connect(ip_port) -# data = {"type": 430, "data": {"code": code}} -# client.send(json.dumps(data).encode("utf-8")) -# result = client.recv(1024) -# client.close() -# return result.decode("gbk") -# -# # 璁剧疆浠g爜 -# def setCode(self, code): -# # 鑾峰彇浠g爜灞炴�ф弿杩� -# try: -# result = self.__request(code) -# result = json.loads(result) -# if result['code'] == 0: -# code_info = result['data']['code_info'] -# desc = result['data']['desc'] -# self.label_code_name.SetLabelText(f"{code_info[1]}({code_info[0]})") -# self.label_atrribute.SetLabelText(desc) -# self.label_error.SetLabelText("") -# except Exception as e: -# self.label_code_name.SetLabelText("") -# self.label_atrribute.SetLabelText("") -# self.label_error.SetLabelText(str(e)) -# -# def OnExit(self, e): -# try: -# setting.set_code_attribute_window_info((self.Position[0], self.Position[1], self.Size[0], self.Size[1])) -# except Exception as e: -# print("") -# self.Hide() -# - -# 鎮诞妗� class FloatFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, "鎮诞鐩洏", style=wx.CAPTION ^ wx.MINIMIZE_BOX ^ wx.CLOSE_BOX ^ wx.STAY_ON_TOP, @@ -1038,7 +979,7 @@ # 璁剧疆浠g爜锛岃姹備唬鐮佸睘鎬� def setCode(self, code): # 鑾峰彇浠g爜灞炴�ф弿杩� - #auto_focus = setting.get_float_frame_auto_focus() + # auto_focus = setting.get_float_frame_auto_focus() if True: print("鏄惁鏈夌鐞嗗憳鏉冮檺", self.is_admin()) # 绐楀彛鏄剧ず鍦ㄦ渶鍓嶉潰 @@ -1772,6 +1713,7 @@ if __name__ == "__main__": - app = mainApp() - app.MainLoop() - # ths_auto_refresh() + # app = mainApp() + # app.MainLoop() + # ocr_ths_code() + print(int(1.5)) -- Gitblit v1.8.0