Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1991
  • Last Modified:

Countdown timer in Apple script

Hello All,

I am trying to create a Apple script code where in it can display a timer for 15 minutes.
After the 15 minutes the script invokes another application.
The timer is just a alert message for the user to close his documents.
I did use the display dialog through repeat but it I do not want the display to pop up every time.
Only the time should decrease from the display message.
Like 15:00 then 14:59, 14:58.
Please help.
Thanks
0
karthik80c
Asked:
karthik80c
  • 2
1 Solution
 
SimonCommented:
In plain Applescript, you can only do a repeat with a static dialog. Presumably you want to do this so the you don't get the 'flicker' of the dialog box being re-displayed every second? You can reduce the re-display by updating the timer less frequently...
repeat with i from 15 to 1 by -1
	set Dlg to display dialog "You have " & return & i & " minutes left to decide" buttons {"Yes", "No"} default button ¬
		"Yes" with icon caution giving up after 60
	if (button returned of Dlg) is "Yes" then
		return "Yes"
		exit repeat
	else if i = 1 or (button returned of Dlg) is "No" then
		return "No"
		exit repeat
	end if
end repeat

Open in new window


You could also get a bit fancier and change the repeat time from minutes to seconds when you get down to the final minute.

However, I'd say the only way to do exactly what you requested is to build an Cocoa-Applescript application in XCode.
0
 
karthik80cAuthor Commented:
Thank you for your response.
I will use the cocoa-applescript and check whether am able to do that.
0
 
karthik80cAuthor Commented:
Dear Simon

I did try using a Cocoa - Apple script as suggested by you. I am new to that. So I searched different forums to get the one I require.
Could you please provide me a solution to the following query. Thank you for your help.
http://www.experts-exchange.com/OS/Apple_Operating_Systems/OS_X/Q_28590069.html
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now