← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #680738]: switchApp()

 

Question #680738 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/680738

Eric Jordan posted a new comment:
This is the same exact code as the link I showed you in the first post:

the title on the window shows Clicker Heroes.

Settings.MoveMouseDelay = 0.0
running = True
shouldClickFor = 50
shouldUpgrade = False
timeToDead = 0
boss = False

def runHotkey(event):
    global running
running = False

Env.addHotkey(Key.F1, KeyModifier.CTRL, runHotkey)
ch = switchApp("Clicker Heroes")
wait(5)
while(ch.hasWindow() and running):
    if shouldClickFor > 0:
        hover(Pattern("1557442376919.png").similar(0.89).targetOffset(-209,-223))       
while shouldClickFor > 0 and running:
    mouseDown(Button.LEFT)
    mouseUp(Button.LEFT)
    shouldClickFor -= 1 
    if timeToDead >= 2 and not exists(Pattern("1557442586882.png").similar(0.90)):
        click(Pattern("1557444795030.png").similar(0.89).targetOffset(-143,0))
        timeToDead = 0
        if exists(Pattern("1557442917111.png").similar(0.89)):
            shouldUpgrade = True 
        click(Pattern("1557442917111.png").similar(0.89).targetOffset(51,0))        
        timeToDead += 1
    else:
        if not shouldUpgrade:
            timeToDead = 0
    shouldUpgrade = False
    shouldClickFor = 50
    if exists(Pattern("1557444278907.png").similar(0.90)) and not boss:
        shouldClickFor = 150 
        boss = True
    elif exists(Pattern("1557444278907.png").similar(0.90)):
         click(Pattern("1557442759904.png").similar(0.91).targetOffset(-251,-1))
boss = False

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.