Add Support for different zoom rate
This commit is contained in:
parent
0c78a4a26c
commit
c26de725be
|
@ -155,6 +155,7 @@ class GameHelper:
|
||||||
self.PicsCV = {}
|
self.PicsCV = {}
|
||||||
self.Handle = win32gui.FindWindow("Hlddz", None)
|
self.Handle = win32gui.FindWindow("Hlddz", None)
|
||||||
self.Interrupt = False
|
self.Interrupt = False
|
||||||
|
self.RealRate = (1796, 1047)
|
||||||
for file in os.listdir("./pics"):
|
for file in os.listdir("./pics"):
|
||||||
info = file.split(".")
|
info = file.split(".")
|
||||||
if info[1] == "png":
|
if info[1] == "png":
|
||||||
|
@ -190,7 +191,11 @@ class GameHelper:
|
||||||
saveDC.DeleteDC()
|
saveDC.DeleteDC()
|
||||||
mfcDC.DeleteDC()
|
mfcDC.DeleteDC()
|
||||||
win32gui.ReleaseDC(hwnd, hwndDC)
|
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:
|
if region is not None:
|
||||||
im = im.crop((region[0], region[1], region[0] + region[2], region[1] + region[3]))
|
im = im.crop((region[0], region[1], region[0] + region[2], region[1] + region[3]))
|
||||||
if result:
|
if result:
|
||||||
|
@ -207,7 +212,7 @@ class GameHelper:
|
||||||
image, _ = self.Screenshot()
|
image, _ = self.Screenshot()
|
||||||
result = pyautogui.locate(needleImage=self.Pics[templateName], haystackImage=image, confidence=confidence, region=region)
|
result = pyautogui.locate(needleImage=self.Pics[templateName], haystackImage=image, confidence=confidence, region=region)
|
||||||
if result is not None:
|
if result is not None:
|
||||||
self.LeftClick((result[0],result[1]))
|
self.LeftClick((result[0], result[1]))
|
||||||
|
|
||||||
def GetCardsState(self, image):
|
def GetCardsState(self, image):
|
||||||
st = time.time()
|
st = time.time()
|
||||||
|
@ -341,6 +346,10 @@ class GameHelper:
|
||||||
|
|
||||||
def LeftClick(self, pos):
|
def LeftClick(self, pos):
|
||||||
x, y = 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)
|
lParam = win32api.MAKELONG(x, y)
|
||||||
win32gui.PostMessage(self.Handle, WM_MOUSEMOVE, MK_LBUTTON, lParam)
|
win32gui.PostMessage(self.Handle, WM_MOUSEMOVE, MK_LBUTTON, lParam)
|
||||||
win32gui.PostMessage(self.Handle, WM_LBUTTONDOWN, MK_LBUTTON, lParam)
|
win32gui.PostMessage(self.Handle, WM_LBUTTONDOWN, MK_LBUTTON, lParam)
|
||||||
|
|
3
main.py
3
main.py
|
@ -430,6 +430,9 @@ class MyPyQT_Form(QtWidgets.QWidget, Ui_Form):
|
||||||
if play_btn is not None:
|
if play_btn is not None:
|
||||||
helper.LeftClick((play_btn[0], play_btn[1]))
|
helper.LeftClick((play_btn[0], play_btn[1]))
|
||||||
self.beforeStart()
|
self.beforeStart()
|
||||||
|
img, _ = helper.Screenshot()
|
||||||
|
img = gh.DrawRectWithText(img, (play_btn[0], play_btn[1],10,10))
|
||||||
|
gh.ShowImg(img)
|
||||||
|
|
||||||
def beforeStart(self):
|
def beforeStart(self):
|
||||||
GameHelper.Interrupt = True
|
GameHelper.Interrupt = True
|
||||||
|
|
Loading…
Reference in New Issue