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