PDA

View Full Version : Applescript - bring popup window to front?




poobear
Apr 21, 2011, 12:38 PM
Hi!

I have this applescript:

repeat
display dialog "Take a break!" buttons {"Ok"} default button 1
delay 600
end repeat

I have saved this as minibreak.app file and have it running reminding me to take short breaks. Problem is, these popup windows happens in the background, I just hear the popup sound and see the dock icon jumping. I would like to bring these windows to the front so I never miss them.

I googled and tried to add set window 1 of application "minibreak" to frontmost but that did not work.

Does anyone have an idea on how to solve this?

Thanks!



McGordon
Apr 21, 2011, 06:35 PM
Just activate it to bring your script to the front.


repeat
activate
display dialog "Take a break!" buttons {"Ok"} default button 1
delay 600
end repeat

poobear
Apr 22, 2011, 04:16 AM
Thanks! That was an easy fix.

Also, I can't quit this program either by right clicking on the Dock icon or by clicking Close in the Apple menu. Does anyone know why this is? I have to force quit it every time.

mysterytramp
Apr 22, 2011, 06:57 AM
You can't quit because of this:

display dialog "Take a break!" buttons {"Ok"} default button 1

Or more precisely "buttons {"Ok"} default button 1"

Ordinarily, display dialog would present two buttons, OK and Cancel. With Cancel, you'd be able to exit the script gracefully. But by adding "buttons {"Ok"} default button 1" you've told AS you don't want the standard.

Change that one line to:

display dialog "Take a break!"

If you press "OK," the script proceeds normally and delays 600 seconds. Hit cancel and it exits.

mt