1. Controlling Sikuli Scripts and their Behaviour

exit - setShowActions

Accessible attributes in class Settings:

DelayAfterDrag - DelayBeforeDrop - MoveMouseDelay - WaitScanRate - ObserveScanRate - SlowMotionDelay


MoveMouseDelay

As a standard behaviour the time to move the mouse pointer from the current location to the target location given by mouse actions is 1.0 second. During this time, the mouse pointer is moved continuosly with decreasing speed to the target point. An additional benefit of this behavior is, that it gives the active application some time to react on the previous mouse action, since the e.g. click is simulated at the end of the mouse movement.

Settings.MoveMouseDelay - control the time taken for mouse movement to a target location by setting Settings.MoveMouseDelay to a decimal value meaning seconds (default 1.0). Setting it to 0 will switch off any animation (the mouse will "jump" to the target location).

mmd = Settings.MoveMouseDelay # save default/actual value
click(image1) # implicitly wait 1 second before click
Settings.MoveMouseDelay = 3
click(image2) # give app 3 seconds time before clicking again
Settings.MoveMouseDelay = mmd # reset to original value

[ Controlling Sikuli] ] - [ Global Functions ] - [ Navigator ] - [ top of Document ]


DelayAfterDrag / DelayBeforeDrop

When using dragDrop() you may have situations, where the operation is not processed as expected. This may be due to the fact, that the Sikuli actions are too fast for the target application to react properly. With these settings the waiting time after the mouse down at the source location and before the mouse up at the target location of a dragDrop operation are controlled. The standard settings are 0.3 seconds for each value. The time that is taken, to move the mouse from source to target is controlled by Settings.MoveMouseDelay.

Settings.DelayAfterDrag - specify the waiting time after mouse down at the source location as a decimal value meaning seconds (default 0.3).

Settings.DelayBeforeDrop - specify the waiting time before mouse up at the target location as a decimal value meaning seconds (default 0.3).

# you may wish to save the actual settings before
Settings.DelayAfterDrag = 1
Settings.DelayBeforeDrop = 1
Settings.MoveMouseDelay = 3
dragDrop(source_image, target_image)
# time for complete dragDrop: about 5 seconds + search times

[ Controlling Sikuli] ] - [ Global Functions ] - [ Navigator ] - [ top of Document ]


setShowActions( False | True ) / SlowMotionDelay

If set to True, when a script is run, Sikuli shows a visual effect on the spot where the action will take place before executing actions (e.g. click, dragDrop, type, etc) for about 2 seconds in the standard. The default setting is False.

Error: Macro Image(showactions-code.png) failed
Attachment 'wiki:RaiMansWork: showactions-code.png' does not exist.
Error: Macro Image(showactions.png) failed
Attachment 'wiki:RaiMansWork: showactions.png' does not exist.

Settings.SlowMotionDelay - you can control the duration of the effect by setting Settings.SlowMotionDelay to a decimal value meaning seconds (default 2.0).

Both settings are remembered independently from each other.

setShowActions(True)
Settings.SlowMotionDelay = 3
click(path_to_some_image)
# before clicking, the showActions effect
# will be visible for about 3 seconds
setShowActions(False)

[ Controlling Sikuli] ] - [ Global Functions ] - [ Navigator ] - [ top of Document ]


WaitScanRate / ObserveScanRate

As a standard behavior Sikuli internally processes about 3 search operations per second, when processing a wait() or observe(). In cases where this leads to an excessive usage of system ressources or if you intentionally want to look for the visual object not so often, you may set the respective values to what you need. Since the value is used as a rate per second, specifying values between 1 and near zero, leads to scans every x seconds (e.g. specifying 0.5 will lead to scans every 2 seconds).

Settings.WaitScanRate - set it to a decimal value > 0. A search will happen every 1/value seconds. (default 3). Settings.ObserveScanRate - set it to a decimal value > 0. A search will happen every 1/value seconds. (default 3).

def myHandler(e):
   print "it happened"
# you may wish to save the actual settings before
Settings.ObserveScanRate = 0.2
onAppear(some_image, myHandler)
observe(FOREVER, background = True)
# the observer will look every 5 seconds
# since your script does not wait here, you 
# might want to stop the observing later on ;-)

[ Controlling Sikuli ] - [ Global Functions ] - [ Navigator ] - [ top of Document ]


exit ([value])

Stops the script gracefully at this point. The value is returned to the calling environment.

[ Controlling Sikuli ] - [ Global Functions ] - [ Navigator ] - [ top of Document ]