Skip to content

Instantly share code, notes, and snippets.

@coreyja
Forked from nonrational/autopush.applescript
Last active February 22, 2018 16:52
Show Gist options
  • Save coreyja/8333db604b1532dd6c5c2c642daaa721 to your computer and use it in GitHub Desktop.
Save coreyja/8333db604b1532dd6c5c2c642daaa721 to your computer and use it in GitHub Desktop.
Viscosity Connect and Duo Push
# This is the alias to actually launch the AppleScript.
# Put this in your `.bash_profile` or wherever you like to keep aliases
# This assumes the AppleScript is located in `~/AppleScripts/autopush.applescript`
alias veep="osascript ~/AppleScripts/autopush.applescript"
-- Will need to change the name to the VPN Client you wish to connect to
set vpnClientName to "Betterment VPN"
set viscosityWindowName to "Viscosity - " & vpnClientName
set afterWindowOpenDelay to 1
tell application "Viscosity" to connect vpnClientName
tell application "System Events"
set duoPrompt to a reference to static text "Duo passcode or second factor:" of window viscosityWindowName of application process "Viscosity"
set mfaInputField to a reference to text field of window viscosityWindowName of application process "Viscosity"
set okButton to a reference to button "OK" of window viscosityWindowName of application process "Viscosity"
repeat until exists duoPrompt
delay 0.2
end repeat
delay afterWindowOpenDelay -- This delay is annoying, but important. The push is never sent without it
set value of mfaInputField to "push"
click okButton
end tell
# This will install tccutil https://github.com/jacobsalmela/tccutil
# for giving apps Accessibility Access then gives `osacript` and `iterm2`
# Accesibility Access to allow GUI interactions
brew install tccutil
sudo tccutil -i /usr/bin/osascript; sudo tccutil -e /usr/bin/osascript;
sudo tccutil -i com.googlecode.iterm2; sudo tccutil -e com.googlecode.iterm2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment