Wait after click?

Asked by argh

My if else statement seems to be working, however I'm not sure if it's waiting after clicking asdf2.png (doesn't really seem like it).

-------------------------------------
if exists("asdf1.png"):
    click("asdf2.png",10)
    wait(10)
else:
    click("asdf3.png")
-------------------------------------

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

the syntax is ok, but you should avoid the second search with the click:

before version 1.1.0:

if exists("asdf1.png"):
    click(getLastMatch())
    wait(10)
else:
    click("asdf3.png")

version 1.1.x+

if exists("asdf1.png"):
    click()
    wait(10)
else:
    click("asdf3.png")

Revision history for this message
argh (aargh) said :
#2

Thanks RaiMan, that solved my question.

Revision history for this message
masuo (masuo-ohara) said :
#3

@argh

"asdf2.png" is typo ?
@RaiMan's codes do not contain "asdf2.png".

I recommend to use user log feature.

[example:]
Settings.UserLogs = True
Settings.UserLogTimes = True

Debug.user("check point-1")
if exists("asdf1.png"):
    Debug.user("check point-2")
    click("asdf2.png",10)
    Debug.user("check point-3")
    wait(10)
    Debug.user("check point-4")
else:
    click("asdf3.png")

Revision history for this message
RaiMan (raimund-hocke) said :
#4

LOL, thanks masuo: one should always start only thinking after having read AND understood ;-)

... your answer should help to shed some light on what is going on.

BTW:
click("asdf2.png",10)

... the ,10 does not make sense here. the 2nd parameter can be used to specify modifier keys (like shift, ctrl, ...) to be held down during the mouse action.
The 10 here is interpreted as a binary 8 + 2, which means "press clrtl+alt" during the mouse click.
Hence it is taken as
click("asdf2.png", KeyModifier.CTRL + KeyModifier.ALT)

Revision history for this message
argh (aargh) said :
#5

The script seems to work well in the limited amount of time I have to test it and I've gone ahead and setup a task for it to run daily, however the next step of leaving it to smoothly run with minimal power requirements is unknown to me. I have it in a Windows 7 hyper-v which I'll be transferring to a (Win 10) laptop shortly. If I leave the VM session connected (Win 7desktop showing and all) but with the laptop lid down, Win 10 locked, will this be sufficient for the script to run in the VM?