From c26de725beaa327bb4cef78e368c64c80beaeb5a Mon Sep 17 00:00:00 2001 From: Vincentzyx <929403983@qq.com> Date: Wed, 28 Jul 2021 23:47:46 +0800 Subject: [PATCH] Add Support for different zoom rate --- GameHelper.py | 13 +++++++++++-- main.py | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/GameHelper.py b/GameHelper.py index f0a23f3..6fa2579 100644 --- a/GameHelper.py +++ b/GameHelper.py @@ -155,6 +155,7 @@ class GameHelper: self.PicsCV = {} self.Handle = win32gui.FindWindow("Hlddz", None) self.Interrupt = False + self.RealRate = (1796, 1047) for file in os.listdir("./pics"): info = file.split(".") if info[1] == "png": @@ -190,7 +191,11 @@ class GameHelper: saveDC.DeleteDC() mfcDC.DeleteDC() win32gui.ReleaseDC(hwnd, hwndDC) - im = im.resize((1796, 1047)) + im = im.resize((1800, 1050)) + self.RealRate = (width, height) + # print(width, height) + # print(self.RealRate) + # time.sleep(2) if region is not None: im = im.crop((region[0], region[1], region[0] + region[2], region[1] + region[3])) if result: @@ -207,7 +212,7 @@ class GameHelper: image, _ = self.Screenshot() result = pyautogui.locate(needleImage=self.Pics[templateName], haystackImage=image, confidence=confidence, region=region) if result is not None: - self.LeftClick((result[0],result[1])) + self.LeftClick((result[0], result[1])) def GetCardsState(self, image): st = time.time() @@ -341,6 +346,10 @@ class GameHelper: def LeftClick(self, pos): x, y = pos + x = (x / 1800) * self.RealRate[0] * self.ScreenZoomRate + y = (y / 1050) * self.RealRate[1] * self.ScreenZoomRate + x = int(x) + y = int(y) lParam = win32api.MAKELONG(x, y) win32gui.PostMessage(self.Handle, WM_MOUSEMOVE, MK_LBUTTON, lParam) win32gui.PostMessage(self.Handle, WM_LBUTTONDOWN, MK_LBUTTON, lParam) diff --git a/main.py b/main.py index a791d62..a77c482 100644 --- a/main.py +++ b/main.py @@ -430,6 +430,9 @@ class MyPyQT_Form(QtWidgets.QWidget, Ui_Form): if play_btn is not None: helper.LeftClick((play_btn[0], play_btn[1])) self.beforeStart() + img, _ = helper.Screenshot() + img = gh.DrawRectWithText(img, (play_btn[0], play_btn[1],10,10)) + gh.ShowImg(img) def beforeStart(self): GameHelper.Interrupt = True