Popup timeout

Asked by Steen

hi

when having a popup wehn script starts, is it possible to make it disappear agin after 5 sec or so.

popup("You suck if you havnt made a copy of this")

popup("You suck if you havnt made a copy of this"),5 ???? where the ,5 is the timeout!

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

currently not a feature of Sikuli. Feel free, to post a request bug.

On Mac you could make your own popups with osascript and AppleScript's dialog(), which has such a feature.

On Windows you might use any tool, that provides such a feature and can be run from command line.

In both cases you should use os.popen() to run the respective commands from inside your script.

Another possibility is to use Pythons module thread, to run a function in parallel to the popup, that clicks the ok button after a specified time, if the popup still exists.

Revision history for this message
Steen (steenc) said :
#2

Thanks RaiMan, that solved my question.

Revision history for this message
Roman Podolyan (podolyan-roman) said :
#3

As far as I see, nothing regarding popup timeout changed since 2012, right?

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

Yes 😖
Hopefully in version 2. 🙏🏻

Revision history for this message
Roman Podolyan (podolyan-roman) said :
#5

Ok. I'm addding a bit of information here.

Sikuli code calling a piece of Apple Script:
______
os.popen("osascript ~/Your/Precious/Path/timeout_script.scpt")

______

Contents of timeout_script.scpt , a piece of Apple script code with timeout (modified example found on Internet):
_____
tell application "Finder"
 activate
 with timeout of 6 seconds
  set r to display dialog "Send email?" buttons {"Yes", "No"} default button "Yes" giving up after 5 -- seconds
  if r's gave up or r's button returned is not "No" then
   return 1
  end if
 end timeout
 return 0
end tell
_____

It seems that called in such way script does not return any value back to Sikuli / Jython though, but as for my current purpose it is enough to have script doing some job on its own after timeout.

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

@Roman
Did you check, wether osascript return anything from the script to command line?
Check popen for options about stdin/stdout.

Did you check the run option in SikuliX?
http://sikulix-2014.readthedocs.io/en/latest/scripting.html#running-scripts-and-snippets-from-within-other-scripts-and-run-scripts-one-after-the-other

Revision history for this message
Roman Podolyan (podolyan-roman) said :
#7

> Did you check, wether osascript return anything from the script to command line?

Yes. With command lined run via osascript it works as expected and returns 0 or 1 as I want it.

> Did you check the run option in SikuliX?

I tried it, but it returns 0 regardless of return code of the script, even where I get 1 with command line with certain steps.

> Check popen for options about stdin/stdout.

Sorry, have to postponed that: didn't manage to found quick and dirty example and not in my current priorities.

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

Hi Roman: no hurry, the tips where just for you, but I will have a look into it the next time too.

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

I have it now in version 2 for popup, popAsk, popError and input / input hidden.

I will not change the code in version 1.1.x, but add a class with the version 2 code to be used alternatively.

... next week ;-)

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

it is out now and in the docs ;-)