Just need a simple example of clicking a yes button on a popup using saved images

Asked by Joseph MacDonald

I've JUST started looking at this application and appears rather robust ... however what I'm looking for is a simple script to identify a popup window that appears during an uninstall and then click the Yes button. I have saved images identifying both the window and the button but can't seem to structure the script correctly so that it runs. I'm attempting to use the OnAppear function in a Windows XP environment.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Joseph MacDonald (joseph-macdonald-gowlings) said :
#1

Okay, I think I have it ...

observe(45)
onAppear("AR-Confirm.bmp", click("AR-YesBtn.bmp"))

This seems to work if I run the script and then start the uninstall however, how do I call this from a .VBS?

Is there a more refined way of doing this rather than setting the "Observe" to a specified time frame?

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

The observer feature has a bug in windows and does not work properly.

For more details and a solution using exists() look at my answers with question
https://answers.launchpad.net/sikuli/+question/119324

Your script:
observe(45) # this waits 45 seconds without doing anything
onAppear("AR-Confirm.bmp", click("AR-YesBtn.bmp")) # this is wrong, the second parameter has to be the name of a function
# when executed, the click is performed and may eventually fire, if AR-YesBtn.bmp is visible on the screen.

If it would work on windows, it should look like this:

def myHandler(event):
   global clicked
   click("AR-YesBtn.bmp")
   clicked = True # to report success
   event.region.stopObserver() # to stop observation before timeout

clicked = False
onAppear("AR-Confirm.bmp", myHandler)
observe(45)
if not clicked:
   print "sorry, window did not come up"
   exit()

But since it does not work and seems to be a little bit oversized, this would do the same

if exists("AR-Confirm.bmp", 45): waits max 45 seconds for the image to come up
   click("AR-YesBtn.bmp")
else:
   print "sorry, window did not come up"
   exit()

Call it from a .VBS:
you have to use the command line execution of a .sikuli or .skl form your VBS code.

Can you help with this problem?

Provide an answer of your own, or ask Joseph MacDonald for more information if necessary.

To post a message you must log in.