Need a scripting nudge for naming a new stopwatch in Clockwork, please.

Tags ( )

Hello,

I'm trying to set up Clockwork to create new Stopwatches on the fly, based on X-10 trigger actions from Indigo. It seems like this should be a very simple task. Trouble is, everything I've tried to enter a timer name fails. It's critical that my script is able to supply the name of the remote trigger device that started the timer.

Naturally our consideration for the purchase of Clockwork hinges on this use, so I'm trying to get this answered within the 30 day trial timeframe.

Currently, I get a new unnamed timer for every event trigger. All I need now is to assign the name, which will be a known value in the script. Grrr! Any thoughts would be greatly appreciated.

Here's my script so far. Thanks in advance.

-George

--Add a new stopwatch to the window...
activate application "Clockwork"
tell application "System Events"
tell process "Clockwork"
tell menu bar 1
tell menu bar item "File"
tell menu 1
tell menu item "New"
tell menu 1
click menu item "Stopwatch"
end tell
end tell
end tell
end tell
end tell
end tell
end tell

-- Still trying to get the name right...
activate application "Clockwork"
tell application "System Events"
tell process "Clockwork"
tell window "Clockwork"
tell group 1
tell scroll area 1
tell table 1
tell row 2
tell text field 1
--this, in theory, should enter the table number and start the timer. But nooooo...
set value to "Table 1"
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell

--Start me up!
activate application "Clockwork"
tell application "System Events"
tell process "Clockwork"
tell menu bar 1
tell menu bar item "Timer"
tell menu 1
click menu item "Start"
end tell
end tell
end tell
end tell
end tell

I think you are trying to do

I think you are trying to do things the hard way. Instead of using "System Events" use Clockworks built in scripting support. I think this will do what you want.

tell application "Clockwork"
set s to make timer with properties {mode:stopwatch, name:"some name"}
s start
end tell

Yea, leave it to me to take

Yea, leave it to me to take the long road. It's been too long since my last "programming" experience (Hypercard, LOL).

I couldn't make heads or tails out of the dictionary stuff, but this works perfectly. Many thanks!

George

Still doing it the hard way

Hi Jesse.

Sorry to bug you again with my stupidity. Your script works great, but since folks will be starting a new stopwatch blindly by remote, and every press of the button creates a new stopwatch, it will get out of hand fast.

Now I need to precede the startup code with a conditional statement that sniffs for an existing timer of the same name (ie: Table 12) and skips it if one exits, or deletes the existing timer before starting a new one.

So far all my trial and error hasn't produced the correct results. On the chance that this is something you could toss out without much thought, I'd really appreciate the toss.

Thanks,
George

P.S. Here's where my mods to your script have gone so far. Ideally it would just not make a new timer if one with the same name already exists.

tell application "Clockwork"
get "name"
set TimerName to "name"
exists {TimerName:"Table 12"}
select timer "Table 12"
delete timer "Table 12"
set s to make timer with properties {mode:stopwatch, name:"Table 12"}
s start
end tell

I think this should get you on the right path

tell application "Clockwork"
set some_name to "name"
if (exists timer named some_name) then
set named_timer to timer named some_name
named_timer stop
set display time of named_timer to 0
else
set named_timer to make timer with properties {mode:stopwatch, name:some_name}
end if
named_timer start
end tell

Oooh it likes this. Thank

Oooh it likes this.

Thank you, thank you, thank you!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.