2021-02-19 18:32:20 +08:00
|
|
|
from pyautogui import *
|
|
|
|
import time
|
|
|
|
|
2021-02-19 19:00:15 +08:00
|
|
|
#
|
|
|
|
# Functions.
|
|
|
|
#
|
|
|
|
|
2021-02-19 18:32:20 +08:00
|
|
|
def locateClick(imgname, alt=None, t=0.1, button="left"):
|
2021-02-19 19:00:15 +08:00
|
|
|
# Add pause to allow time for gui elements to appear.
|
2021-02-19 18:32:20 +08:00
|
|
|
time.sleep(t)
|
2021-02-19 19:00:15 +08:00
|
|
|
|
|
|
|
# Try to find image.
|
2021-02-19 18:32:20 +08:00
|
|
|
box = locateOnScreen(imgname)
|
|
|
|
print(imgname, "found at: ", box)
|
|
|
|
|
2021-02-19 19:00:15 +08:00
|
|
|
# It not found, try to find alt image.
|
2021-02-19 18:32:20 +08:00
|
|
|
if box is None:
|
|
|
|
if alt is not None:
|
|
|
|
locateClick(alt, button=button)
|
|
|
|
return False
|
|
|
|
|
2021-02-19 19:00:15 +08:00
|
|
|
# Get center of button and click.
|
2021-02-19 18:32:20 +08:00
|
|
|
x, y = box.left + box.width/2, box.top + box.height/2
|
|
|
|
moveTo(x, y)
|
|
|
|
longClick(button=button)
|
|
|
|
return True
|
|
|
|
|
2021-02-19 19:00:15 +08:00
|
|
|
# Longer click, so FFXIV registers it
|
2021-02-19 18:32:20 +08:00
|
|
|
def longClick(t=0.100, button="left"):
|
|
|
|
mouseDown(button=button)
|
|
|
|
time.sleep(t)
|
|
|
|
mouseUp(button=button)
|
|
|
|
|
2021-02-19 19:00:15 +08:00
|
|
|
#
|
|
|
|
# Main logic.
|
|
|
|
#
|
|
|
|
|
2021-02-19 18:32:20 +08:00
|
|
|
count = 1;
|
|
|
|
while(True):
|
2021-02-19 19:00:15 +08:00
|
|
|
# Option to pause every 5 iteratons to stop program
|
2021-02-19 18:32:20 +08:00
|
|
|
#if count%5 == 0: time.sleep(5);
|
|
|
|
|
2021-02-19 19:00:15 +08:00
|
|
|
# get center left third of of screen
|
2021-02-19 18:32:20 +08:00
|
|
|
start_x, start_y = size()
|
|
|
|
start_x /= 3;
|
|
|
|
start_y /= 2;
|
|
|
|
|
2021-02-19 19:00:15 +08:00
|
|
|
# move cursor to get focus, and click on sign
|
2021-02-19 18:32:20 +08:00
|
|
|
moveTo(start_x, start_y)
|
|
|
|
click();
|
|
|
|
longClick(button="right")
|
|
|
|
|
2021-02-19 19:00:15 +08:00
|
|
|
# will attempt to find gui buttons.
|
2021-02-19 18:32:20 +08:00
|
|
|
if not locateClick("PurchaseLand.png", t=0.3):
|
|
|
|
press("esc");
|
|
|
|
continue
|
2021-02-19 19:00:15 +08:00
|
|
|
if not locateClick("FreeCompanyAlt.png", "FreeCompany.png"):
|
|
|
|
press("esc");
|
|
|
|
press("esc");
|
|
|
|
continue
|
|
|
|
if not locateClick("Yes.png"):
|
|
|
|
press("esc");
|
|
|
|
press("esc");
|
|
|
|
press("esc");
|
|
|
|
continue
|
2021-02-19 18:32:20 +08:00
|
|
|
|
2021-02-19 19:00:15 +08:00
|
|
|
count += 1;
|
2021-02-19 18:32:20 +08:00
|
|
|
|