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.

Revisions

  1. doitian revised this gist Jul 20, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,6 @@ 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 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](https://github.com/doitian/emacs.d/blob/master/site-lisp/org-pomodoro.el)
  2. doitian revised this gist Jul 20, 2013. No changes.
  3. doitian revised this gist Jul 20, 2013. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    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.
  4. doitian revised this gist Jul 20, 2013. 1 changed file with 0 additions and 0 deletions.
    Binary file added Vitamin-R-Preferences.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  5. doitian revised this gist Jul 20, 2013. 1 changed file with 48 additions and 0 deletions.
    48 changes: 48 additions & 0 deletions Stop.applescript
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    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
  6. doitian created this gist Jul 20, 2013.
    76 changes: 76 additions & 0 deletions Start.applescript
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,76 @@
    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