Skip to content

Instantly share code, notes, and snippets.

@lotreal
Last active August 29, 2015 14:12
Show Gist options
  • Save lotreal/ce43f4a85d8ae73781fa to your computer and use it in GitHub Desktop.
Save lotreal/ce43f4a85d8ae73781fa to your computer and use it in GitHub Desktop.
anyconnect.scpt
-- 1. Place in ~/Library/Scripts and enable the Applescript menu via the Applescript Editor
-- 2. Substitute "vpn.example.com" and "redacted" for your VPN server and password
-- 3. Open Security & Privacy System Preferences, go to Privacy, Accessibility
-- 4. Enable Applescript Editor and System UI Server
-- 5. Trigger script from the menu
-- 6. Enjoy being connected
tell application "Cisco AnyConnect Secure Mobility Client"
activate
end tell
repeat until application "Cisco AnyConnect Secure Mobility Client" is running
delay 0.3
end repeat
tell application "System Events"
repeat until (window 1 of process "Cisco AnyConnect Secure Mobility Client" exists)
delay 0.3
end repeat
delay 0.3
tell process "Cisco AnyConnect Secure Mobility Client"
-- keystroke ("host" as string)
keystroke return
end tell
repeat until (window 2 of process "Cisco AnyConnect Secure Mobility Client" exists)
delay 0.3
end repeat
set ConnectAnyway to button 2 of window 1 of process "Cisco AnyConnect Secure Mobility Client"
click ConnectAnyway
repeat until (window 2 of process "Cisco AnyConnect Secure Mobility Client" exists)
delay 0.3
end repeat
tell process "Cisco AnyConnect Secure Mobility Client"
-- keystroke ("username" as string)
keystroke return
end tell
repeat until (window 2 of process "Cisco AnyConnect Secure Mobility Client" exists)
delay 0.3
end repeat
tell process "Cisco AnyConnect Secure Mobility Client"
keystroke ("521198" as string)
keystroke return
end tell
repeat until (window 1 of process "vpndownloader" exists)
delay 0.3
end repeat
set ConnectAnyway to button "Connect Anyway" of window 0 of process "vpndownloader"
-- properties of ConnectAnyway
click ConnectAnyway
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment