From 73bc694cd03367557cb241956042a2d99c86a5e2 Mon Sep 17 00:00:00 2001 From: DarkLord76865 Date: Sat, 17 Jun 2023 16:12:03 +0200 Subject: [PATCH] fix window closing bug one type of popup window (about purchasing dlcs) wasn't getting closed bump version release v0.1.3 --- build.py | 2 +- main.py | 38 +++++++++++++----- .../cv_templates/pop_ups/buy_orange.png | Bin 0 -> 824 bytes run_data/images/cv_templates/pop_ups/x.png | Bin 0 -> 614 bytes 4 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 run_data/images/cv_templates/pop_ups/buy_orange.png create mode 100644 run_data/images/cv_templates/pop_ups/x.png diff --git a/build.py b/build.py index e9067a2..07968ad 100644 --- a/build.py +++ b/build.py @@ -67,7 +67,7 @@ def build(name, console, onefile, uac_admin, icon, files, folders): def main(): name = "Autofish" - version = "0.1.2" + version = "0.1.3" console = False onefile = True diff --git a/main.py b/main.py index 4b69c27..2d88c5a 100644 --- a/main.py +++ b/main.py @@ -144,7 +144,7 @@ def checks(tip): changes = True while changes: changes = False - for image in bot_data["images"]["pop_ups"]: + for image in bot_data["images"]["pop_ups"]["list"]: inf = cv2.minMaxLoc(cv2.matchTemplate(cv2.cvtColor(np.array(ImageGrab.grab()), cv2.COLOR_RGB2GRAY), image, cv2.TM_SQDIFF)) if inf[0] <= 1000000: mouse.move(inf[2][0], inf[2][1], absolute=True, duration=0) @@ -153,6 +153,18 @@ def checks(tip): ret_changes = True time.sleep(2) break + if changes: + continue + # buy + inf = cv2.minMaxLoc(cv2.matchTemplate(cv2.cvtColor(np.array(ImageGrab.grab()), cv2.COLOR_RGB2GRAY), bot_data["images"]["pop_ups"]["buy"][0], cv2.TM_SQDIFF)) + if inf[0] <= 1_000_000: + inf2 = cv2.minMaxLoc(cv2.matchTemplate(cv2.cvtColor(np.array(ImageGrab.grab()), cv2.COLOR_RGB2GRAY), bot_data["images"]["pop_ups"]["buy"][1], cv2.TM_SQDIFF)) + shape = np.shape(bot_data["images"]["pop_ups"]["buy"][1]) + mouse.move(inf2[2][0] + shape[1] // 2, inf2[2][1] + shape[0] // 2, absolute=True, duration=0) + mouse.click(button="left") + changes = True + ret_changes = True + time.sleep(2) return ret_changes case "after_reel_in": while True: @@ -251,15 +263,21 @@ def load_data(): for j in ("", "_dark"): bot_data["images"]["digits"].append(cv2.imread(resource_path(f"run_data\\images\\cv_templates\\digits\\{i}{j}.png"), cv2.IMREAD_GRAYSCALE)) - bot_data["images"]["pop_ups"] = [ - cv2.imread(resource_path(r"run_data/images/cv_templates/pop_ups/claim_green.png"), cv2.IMREAD_GRAYSCALE), - cv2.imread(resource_path(r"run_data/images/cv_templates/pop_ups/close_gray.png"), cv2.IMREAD_GRAYSCALE), - cv2.imread(resource_path(r"run_data/images/cv_templates/pop_ups/close_gray_2.png"), cv2.IMREAD_GRAYSCALE), - cv2.imread(resource_path(r"run_data/images/cv_templates/pop_ups/close_orange.png"), cv2.IMREAD_GRAYSCALE), - cv2.imread(resource_path("run_data/images/cv_templates/pop_ups/close_orange_2.png"), cv2.IMREAD_GRAYSCALE), - cv2.imread(resource_path(r"run_data/images/cv_templates/pop_ups/extend_orange.png"), cv2.IMREAD_GRAYSCALE), - cv2.imread(resource_path(r"run_data/images/cv_templates/pop_ups/ok_orange.png"), cv2.IMREAD_GRAYSCALE) - ] + bot_data["images"]["pop_ups"] = { + "list": [ + cv2.imread(resource_path(r"run_data/images/cv_templates/pop_ups/claim_green.png"), cv2.IMREAD_GRAYSCALE), + cv2.imread(resource_path(r"run_data/images/cv_templates/pop_ups/close_gray.png"), cv2.IMREAD_GRAYSCALE), + cv2.imread(resource_path(r"run_data/images/cv_templates/pop_ups/close_gray_2.png"), cv2.IMREAD_GRAYSCALE), + cv2.imread(resource_path(r"run_data/images/cv_templates/pop_ups/close_orange.png"), cv2.IMREAD_GRAYSCALE), + cv2.imread(resource_path("run_data/images/cv_templates/pop_ups/close_orange_2.png"), cv2.IMREAD_GRAYSCALE), + cv2.imread(resource_path(r"run_data/images/cv_templates/pop_ups/extend_orange.png"), cv2.IMREAD_GRAYSCALE), + cv2.imread(resource_path(r"run_data/images/cv_templates/pop_ups/ok_orange.png"), cv2.IMREAD_GRAYSCALE) + ], + "buy": [ + cv2.imread(resource_path(r"run_data/images/cv_templates/pop_ups/buy_orange.png"), cv2.IMREAD_GRAYSCALE), + cv2.imread(resource_path(r"run_data/images/cv_templates/pop_ups/x.png"), cv2.IMREAD_GRAYSCALE), + ], + } bot_data["images"]["caught_fish"] = { "discard": cv2.imread(resource_path(r"run_data/images/cv_templates/caught_fish/discard_gray.png"), cv2.IMREAD_GRAYSCALE), diff --git a/run_data/images/cv_templates/pop_ups/buy_orange.png b/run_data/images/cv_templates/pop_ups/buy_orange.png new file mode 100644 index 0000000000000000000000000000000000000000..8c31af3f1216ae3426b03c4d9d5843ed1e6668de GIT binary patch literal 824 zcmeAS@N?(olHy`uVBq!ia0vp^xTx zGl_p9%f@z(rW?*Gj&Bw&D|w|n$FH{K^2+`KtFMB7%k2)myyEWL?AiefM zLVbJk^7D_&8n=DFQF-^~xo?b*YNVrAaCq45?XcKz+rF|O)!~2L@#cw*+s@wHXcu?S zyXnUzk7x5+r)x3YIqT>rqpRm^dHmEG{-rjnjSnZL{eL&hZ~u#@*V+AC8|G?k_`7GX z@q@2-_@2sqm1JIOb9(#P3V!e6m>-|!9)7heR8Z;6r#I<;UbjUx7xlUEYCO#hJK479 z*Sv*-k0JvuJH8Q2i_AK5uY%v+j_((@NtTLZePi0xC(^|czjGJOju*4JGR3dw={gR@}e>;+QTKX(*dwQ(h zWc7{W`0^e0zbk(*GbshJDxgfoZJ8Qn_Mv)&!p0X!P1y^ZctG{yP=(5C5Ls z5G$pmaxb@^1fY2M$F{3_IH7=-Sb* zU-;7XDlueEzxRG9`tRKbJRrS$|g?n5eetuee(~N#R?=X8Dqw uTm>OfMrca1nEQ)kd9eILP%=YHmf!3zvRSfdXxnIjvV^CrpUXO@geCxP=zfj> literal 0 HcmV?d00001 diff --git a/run_data/images/cv_templates/pop_ups/x.png b/run_data/images/cv_templates/pop_ups/x.png new file mode 100644 index 0000000000000000000000000000000000000000..155e9cada8a3bfb01087ac575e8b75a0992f89c8 GIT binary patch literal 614 zcmV-s0-61ZP)_0006lNklmKr}2bUwAt8B3C_J^6~Q{AR4xm=Al~TvcRGbeWeA6hDAtf9`?2wHiHu<20XD(7&8wlQ3N-8TD4DT4rQEt6&t4>5?#ACS){syHR3bKC57C zH0hBrLpfF2jS@Yxc?DzhfIbN`l2_@}OW0;!D;S#x3`hivNl#wI+}{GG-}*4tj~J2& z7L&f5D(r9KfA2>xoG>C0EG7e4)y4jgSAO)>Qye71xZHx9<~{V)7ETi3l5Efo`f7_Y z5(Sek0TXz$LVmQp?6^!B`BsEvNUSULHj7%>n7+XhJQmU&{t1u)nhJ4FDjEz5Zr9y7Aw!?tL z7?^tFLtksrmsxOAFViP6`W`I$&dP6?9YoN|(gx3ZxZ` zwH9MiK{t&uHi=`KO?xrcPq`!&a?vPbkvNt>#*49a%oUlSP}>0{fo16lM(KzNGC__% zor5H>JPZBZJ!GOxp!pe)1lPE8jztpOh$Og?|H0t0B@TdbtN;K207*qoM6N<$f)29^ A4gdfE literal 0 HcmV?d00001