on run (argv) set appName to "Vitamin-R 2" set isRunning to false tell application appName activate end tell tell application "System Events" tell process appName set frontmost to true set mainWindow to window "Window" set currentStep to name of static text 1 of mainWindow if currentStep = "Time Slice Paused." then click button "Resume" of mainWindow set frontmost to true set currentStep to name of static text 1 of mainWindow end if tell mainWindow if currentStep = "Total:" then set isRunning to true click button "Finish" set currentStep to name of static text 1 of mainWindow end if if currentStep = "Rate Your Time Slice" then if isRunning then tell pop up button 1 click click menu item 1 of menu 1 end tell if (value of checkbox 1) = 1 then click checkbox 1 end if else if (value of pop up button 1) = "I felt distracted" then tell pop up button 1 click click menu item 2 of menu 1 end tell end if end if end tell end tell end tell end run