Renamed functions.

This commit is contained in:
Sheldon 2021-02-19 19:12:39 +08:00
parent 5a63fea1f0
commit e148084649

View File

@ -5,28 +5,29 @@ import time
# Functions.
#
def locateClick(imgname, alt=None, t=0.1, button="left"):
# Locates gui element.
def locate_click(imgname, alt=None, t=0.1, button="left"):
# Add pause to allow time for gui elements to appear.
time.sleep(t)
# Try to find image.
# Try to find image from screengrab.
box = locateOnScreen(imgname)
print(imgname, "found at: ", box)
# It not found, try to find alt image.
if box is None:
if alt is not None:
locateClick(alt, button=button)
locate_click(alt, button=button)
return False
# Get center of button and click.
x, y = box.left + box.width/2, box.top + box.height/2
moveTo(x, y)
longClick(button=button)
long_click(button=button)
return True
# Longer click, so FFXIV registers it
def longClick(t=0.100, button="left"):
# Longer click, so FFXIV registers it.
def long_click(t=0.100, button="left"):
mouseDown(button=button)
time.sleep(t)
mouseUp(button=button)
@ -48,17 +49,17 @@ while(True):
# move cursor to get focus, and click on sign
moveTo(start_x, start_y)
click();
longClick(button="right")
long_click(button="right")
# will attempt to find gui buttons.
if not locateClick("PurchaseLand.png", t=0.3):
# Attempt to find gui buttons.
if not locate_click("PurchaseLand.png", t=0.3):
press("esc");
continue
if not locateClick("FreeCompanyAlt.png", "FreeCompany.png"):
if not locate_click("FreeCompanyAlt.png", "FreeCompany.png"):
press("esc");
press("esc");
continue
if not locateClick("Yes.png"):
if not locate_click("Yes.png"):
press("esc");
press("esc");
press("esc");