Skip to content

Instantly share code, notes, and snippets.

@doitian
Last active April 1, 2021 23:37
Show Gist options
  • Save doitian/6045827 to your computer and use it in GitHub Desktop.
Save doitian/6045827 to your computer and use it in GitHub Desktop.
Scripts to control Vitamin-R

Usage

osascript Start.applescript "objective" "tag1,tag2"
osascript Stop.applescript

I have skipped most Vitamin-R workflows. See the attached settings snapshot. If you have them enabled, you need to update the script to handle different steps.

I use the scripts in my org pomodoro script

on run (argv)
set argn to count of argv
set appName to "Vitamin-R 2"
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 = "What's Next?" then
tell mainWindow
click radio button "Continue later" of radio group 1
click button "Continue"
set currentStep to name of static text 1
end tell
end if
if currentStep = "Which Kind of Break?" then
tell mainWindow
click radio button "Open-ended break" of radio group 1
click button "Start"
end tell
set frontmost to true
set currentStep to name of static text 1 of mainWindow
end if
tell mainWindow
if currentStep = "Time Remaining:" then
click button "Finish"
set currentStep to name of static text 1
end if
if currentStep = "On an Open-Ended Break…" then
click radio button "Continue with a new time slice" of radio group 1
click button "Continue"
set currentStep to name of static text 1
end if
if currentStep = "Define the Objective for This Time Slice" then
set objectiveArea to text area 1 of scroll area 1
set tagsField to text field 1
if argn > 0 then
set value of objectiveArea to ""
get the value of objectiveArea
set value of objectiveArea to item 1 of argv
get the value of objectiveArea
end if
if argn > 1 then
set value of tagsField to ""
get the value of tagsField
set value of tagsField to item 2 of argv
get the value of tagsField
set focused of tagsField to true
keystroke return
end if
click button "Start"
return "OK"
else
display dialog "Cannot start new time slice:" & currentStep
return
end if
end tell
end tell
end tell
end run
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment