I have written a filemaker pro database application for my wife. I need a way to have a elapsed timer show on the desktop that I can call from the filemaker pro application (filemaker pro has a applescript step) to start, pause, resume, and stop the timer. I can’t do it from within filemaker itself, but I am sure I could do this with applescript. I am stuck in how to implement it.
Any thoughts??
Kevin
Model: MacBook
Browser: Safari 530.17
Operating System: Mac OS X (10.5)
What you really need to do is create an applescript studio application to do this, but here’s an applescript way. You’ll see it’s not very good but it works.
display dialog "Start the timer?"
set start to current date
delay 1
repeat
set secondsElapsed to (get current date) - start
display dialog (secondsElapsed as text) buttons {"Stop", "Pause"} default button 2 with icon note giving up after 1
if button returned of result is "Stop" then
exit repeat
else if button returned of result is "Pause" then
display dialog "Do you want to continue?" buttons {"Stop", "Resume"} with icon note
if button returned of result is "Stop" then exit repeat
end if
end repeat
Thanks for the reply. I came up something similar, but yours is better. However, where I am getting stuck is that I want to be able to send the timer script a parameter to tell it to pause resume or stop from a different script. That way I way I can control it from within Filemaker pro by issuing an applecript step. I was thinking that the timer script would have a subroutine that I can call and use a parameter to tell it to pause resume or stop.
You can’t ever access the code of a running application directly from applescript. Using applescript, there’s only 2 ways you can interact with an application, 1) applescripting it through the stuff it exposes in its applescript dictionary or 2) using gui scripting techniques where you can click buttons or menu items in the application’s interface.
So in order to do what you want, you would have to write an application (easiest is applescript studio) that does your timer and then you could use gui scripting to control it. With gui scripting you could do something like the following… for example if you wanted to click the “Pause” button from an applescript:
tell application "myApplication" to activate
tell application "System Events"
tell process "myApplication"
click button "Pause" of window 1
end tell
end tell
So my suggestion to you would be this. Since you’re no able to write your own application in applescript studio I would search MacUpdate and/or google for a timer application. I would guess that you could find one. Then use applescript to control that application as I explained.