Hi,
i wrote a timer-utility useful for any moment in a day. I simply like to proceed organized and use this app almost every day. Save the code as stay-open application and add a nice icon-to identify it with ease.
Here the code:
#Stopwatch
#tag
#0,01
#build by Joy at 27.11.12
#=====================================
#HELP:
# Simple stopwatch
#
#TODO:
#
#
#===========================================================
property diall : "STOPWATCH" & return & return & "set Minutes"
property stopph : 0
property cc : 0
property all_zeit : 0
property zeit_input : 0
property cu_dt : 0
property sound_file : POSIX path of ((path to library folder from system domain as text) & "Sounds:Funk.aiff" as text)
on run
set {cc, all_zeit, cu_dt} to {0, 0, 0}
my setze_zeit()
end run
on idle
if cc > 0 then
set Komplett_i to return & "Total time: " & tab & all_zeit
repeat 2 times
do shell script "afplay '" & sound_file & "'; sleep 0.1"
end repeat
activate
display dialog "STOPWATCH" & return & return & stopph & ¬
" Minutes elapsed " & Komplett_i with icon 1 buttons {"Repeat", "Quit"} default button 1
set btn to the button returned of the result
if btn is "Repeat" then
my setze_zeit()
else
quit
end if
end if
set cc to cc + 1
return stopph * 60
end idle
on setze_zeit()
set stoppzeit to 0
try
set stoppzeit to text returned of (display dialog diall default answer zeit_input with icon 1)
set all_zeit to all_zeit + stoppzeit
on error
quit
end try
try
tell application "System Events" to set visible of process "Stopwatch" to false
end try
set stopph to stoppzeit
set zeit_input to stoppzeit
set cu_dt to current date
end setze_zeit
on quit
continue quit
end quit
on reopen
set cc to (current date) - cu_dt
set detr_sec to (stopph * 60) - cc
set t_diff to (stopph * 60) - detr_sec
if detr_sec > 60 then
set t_def to "Min"
set detr_sec to detr_sec div 2
else
set t_def to "Sek"
end if
if t_diff > 60 then
set t_def to "Min"
set t_diff to t_diff div 2
else
set t_def to "Sec"
end if
activate
display dialog "STATUS:" & return & return & "Elapsed: " & t_diff & space & t_def & return & "Remained: " & detr_sec & space & t_def & return & "Total: " & zeit_input & space & "Min" buttons {"Continue", "Quit"} default button 1 with icon 1
set btn to the button returned of the result
try
tell application "System Events" to set visible of process "Stopwatch" to false
end try
if btn is "Quit" then quit
return
end reopen