Search code examples
sikuliuser-interactionsikuli-scriptsikuli-idesikuli-x

sikulix ask user to click on location and save it


Is there a way to ask the user to click on a Location and save the coordinates to use that Location later?

None of the tools isted in the page https://sikulix-2014.readthedocs.io/en/latest/interaction.html are suitable for the job, i think.


Solution

  • This is RaiMan from SikuliX

    Eugene's answer is absolutely correct: Currently SikuliX does not have any features to get feedback, when a user clicks somewhere on the screen.

    But for your request there is a rather simple solution:

    simg = userCapture("select location (center of capture)") # capture with prompt
    loc = None # None means user did not capture (ESC)
    if simg != None:
        loc = simg.getRegion().getCenter() # the location to use as center of capture
    print loc
    

    This will tell the user to capture a region, that has its center at the wanted location. The internal capture result (ScreenImage) knows its coordinates on the screen.

    Hope it helps ;-)