Skip to content

Instantly share code, notes, and snippets.

@aahung
Last active June 23, 2022 19:26
Show Gist options
  • Select an option

  • Save aahung/c0be3176c57d656ccf9dbe2bb338dcfd to your computer and use it in GitHub Desktop.

Select an option

Save aahung/c0be3176c57d656ccf9dbe2bb338dcfd to your computer and use it in GitHub Desktop.

Revisions

  1. aahung revised this gist Nov 2, 2017. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    Make sure you add the app invoking this script is in the Preferences -> Security & Privacy -> Pricavy -> Accessbility

    For me, I use it with Alfred, so Alfred 3.app is in the list.
  2. aahung renamed this gist Nov 2, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. aahung created this gist Nov 2, 2017.
    42 changes: 42 additions & 0 deletions scpt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    tell application "System Events"
    tell application process "System Preferences"
    if not (window 1 exists) then
    tell application "System Preferences"
    activate
    end tell
    repeat while not (menu bar 1 exists)
    end repeat
    repeat while not (menu "System Preferences" of menu bar 1 exists)
    end repeat
    repeat while not (menu item "Network" of menu "View" of menu bar 1 exists)
    end repeat
    end if

    click menu item "Network" of menu "View" of menu bar 1

    tell window 1
    repeat while not (rows of table 1 of scroll area 1 exists)
    end repeat
    repeat with current_row in (rows of table 1 of scroll area 1)
    if value of static text 1 of current_row contains "{VPN partial name}" then
    select current_row
    exit repeat
    end if
    end repeat

    repeat with current_checkbox in (checkboxes of group 1)
    if name of current_checkbox is equal to "Connect on demand" then
    click current_checkbox
    exit repeat
    end if
    end repeat

    repeat with current_button in buttons
    if name of current_button is equal to "Apply" then
    click current_button
    exit repeat
    end if
    end repeat
    end tell
    end tell
    end tell