non-continuous wait

Asked by eugene

I found that using "wait" seems to be chewing a lot of CPU cycles and impacts the underlying app I am trying to test.
When I run Sikuli and the test application on separate machines there are no problems. However when I run the sikuli and the test app on the same machine, sikuli slows down the test app significantly.

I narrowed the problem down to the "wait" statement. I timed the test app when I did wait(non-existent-image,100) and I saw that the underlying app response was x5 times slower at the least.

Of course I can write my own "mywait" that will do something like:

attempts=NN
while not exists(img) and attempts>0:
  sleep(2)
  attempts=attempts-1

Ideally I would like to be able to tell "wait" to examine screen at certain interval, not continuously. Is this possible?

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

Good idea. This feature is not yet available.
Submit a request bug, to get it on the list.

I myself have many helper functions that I import at scriptstart to pack things together or to avoid some odds of Sikuli.

One of them does exactly what you describe, can act on the match (e.g. click on it) and returns the match or None for further processing.

Revision history for this message
eugene (eugene-margulis) said :
#2

Thanks!
I'll submit the bug.
It is probably too much to ask, but could you make some of the most popular workarounds/helper functions publicly available?

Revision history for this message
eugene (eugene-margulis) said :
#3

Thanks RaiMan, that solved my question.

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

I looked through my things and have to say most of them are very specific to my focus right now or to the Mac environment.

I'm just busy with changing everything to Netbeans IDE and import modules. To have the functions Capture and Preview/TargetOffsetSetting I use the XML-RPC solution I have setup for me and documented at: https://answers.launchpad.net/sikuli/+question/129181 (The link is on the HP in the 3rd party segment).

But some of these are Mac-only, since I use some support functions based on Applescript (flexible access to the clipboard, the vanishing messages without context switching, using the Mac screenshotfeature).

I'm just adding stuff to my library, to make some of my scripts run both on Mac and Windows and Support for Safari, Firefox or Internetexplorer regarding shortcuts and some basic browser features.

I have integrated Sikuli into Portable.apps (only for me and the people who have to use my scripts), to run Sikuli scripts on every Windows in a sandbox, even without the need for java to be installed. This is used as a platform to share my scripts and be able to run updates.

And I have a "Mac Safari based experiment" lying around to have a reliable and self documenting form fill workflow based on .csv files for web forms. (tabbing, selecting options, selecting from drop dows, scrolling, ...).

And last but not least I have a solution running to extract text from images using ImageMagick and Tesseract (the developers are just on the way with Sikuli X 1.0 where we will have some OCR AND find("some text"))

So except the XML-RPC and OCR feature nothing is really ready to have it on a pin-board.

One more thing:
This tiny little one I really love (runs where Sikuli runs):
def stopSelect(t=3):
    wait(t)
    rightClick(getCenter())
def myAlarm(text, t=3):
    import thread
    thread.start_new_thread(stopSelect, (t,))
    selectRegion(text)
myAlarm("Hi, your System is shut down now! Don't panic!", 5)

The message will be there with the capture overlay for 5 seconds and vanishes automatically. I use it in longer workflows as some
 "inbetween-show-up".

If you are more specific, it may make sense, to share something.