From dbc695a9c77fb59425ea061f726e8c3b5b5d566e Mon Sep 17 00:00:00 2001 From: kuwoyuki Date: Fri, 26 Feb 2021 13:14:23 +0100 Subject: [PATCH] feat: saved previously found click pos, use material ui --- .vscode/settings.json | 3 ++ autoclick.py | 91 +++++++++++++++++++++++++----------------- img/PurchaseLand.png | Bin 3057 -> 1770 bytes img/Yes.png | Bin 2296 -> 1030 bytes 4 files changed, 58 insertions(+), 36 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..de288e1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.formatting.provider": "black" +} \ No newline at end of file diff --git a/autoclick.py b/autoclick.py index 879bb13..1c9ab70 100644 --- a/autoclick.py +++ b/autoclick.py @@ -5,6 +5,13 @@ import time # Functions. # +def do_click(box, button): + time.sleep(0.2) + x, y = box.left + box.width / 2, box.top + box.height / 2 + moveTo(x, y) + long_click(button=button) + + # Locates gui element. def locate_click(imgname, alt=None, t=0.1, button="left"): # Add pause to allow time for gui elements to appear. @@ -17,14 +24,13 @@ def locate_click(imgname, alt=None, t=0.1, button="left"): # It not found, try to find alt image. if box is None: if alt is not None: - locate_click(alt, button=button) - return False + box = locate_click(alt, button=button) + return False, None # Get center of button and click. - x, y = box.left + box.width/2, box.top + box.height/2 - moveTo(x, y) - long_click(button=button) - return True + do_click(box, button) + return True, box + # Longer click, so FFXIV registers it. def long_click(t=0.100, button="left"): @@ -32,49 +38,62 @@ def long_click(t=0.100, button="left"): time.sleep(t) mouseUp(button=button) + # # Main logic. # # Define image paths: img_dir = "img/" +img_purchaseland = img_dir + "PurchaseLand.png" +img_purchaseland_alt = None +img_freecompany = img_dir + "FreeCompany.png" +img_freecompany_alt = img_dir + "FreeCompanyAlt.png" +img_yes = img_dir + "Yes.png" +img_yes_alt = None +count = 1 -img_purchaseland = img_dir+"PurchaseLand.png" -img_purchaseland_alt = None; +# save pos +saved_purchase = None +saved_yes = None -img_freecompany = img_dir+"FreeCompany.png" -img_freecompany_alt = img_dir+"FreeCompanyAlt.png" - -img_yes = img_dir+"Yes.png" -img_yes_alt = None; - -count = 1; -while(True): +while True: # Option to pause every 5 iteratons to stop program - #if count%5 == 0: time.sleep(5); - - # get center left third of of screen + # if count%5 == 0: time.sleep(5); + + # get center left third of of screen start_x, start_y = size() - start_x /= 3; - start_y /= 2; + start_x /= 3 + start_y /= 2 # move cursor to get focus, and click on sign moveTo(start_x, start_y) - click(); + click() long_click(button="right") - # Attempt to find gui buttons. - if not locate_click(img_purchaseland, img_purchaseland_alt, t=0.35): - press("esc"); - continue - if not locate_click(img_freecompany_alt, img_freecompany): - press("esc"); - press("esc"); - continue - if not locate_click(img_yes, img_yes_alt): - press("esc"); - press("esc"); - continue - - count += 1; + # Attempt to find gui buttons. + if saved_purchase is not None: + print("using saved purchase pos\n\t", saved_purchase) + do_click(saved_purchase, "left") + else: + success, box = locate_click(img_purchaseland, img_purchaseland_alt, t=0.4) + if not success: + press("esc") + continue + saved_purchase = box + # if not locate_click(img_freecompany_alt, img_freecompany): + # press("esc"); + # press("esc"); + # continue + if saved_yes is not None: + print("using saved yes pos\n\t", saved_yes) + do_click(saved_yes, "left") + else: + sucess, box = locate_click(img_yes, img_yes_alt) + if not success: + press("esc") + press("esc") + continue + saved_yes = box + count += 1 diff --git a/img/PurchaseLand.png b/img/PurchaseLand.png index 6cd7837fae6a904e53ad473db5e0f30317c9880b..d8cb4da0fc07be60898ace9e86825949ebab001b 100644 GIT binary patch delta 1719 zcmV;o21xnw7wQd=7YZZ@1^@s6ljAsRks&mH27gIJK~#8N?V8O?7F!&EF9ayyth$yzgI4#U|zPWQmu~lQ~{GPv&^(JelLA^JI>H zm(G(pUOG?acuLyo`iXlZj;t*#J!G>k2~{(q`u>>Tk>w+ zys4j|ou4MSgF~iMvC{FfkC%XdogJOd2GhhGh;!%8srveQEyvTRPj#9-^9>FT>NJjd z$Q&;%Evc=oEj2MQq0<>S!i&tD5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