हां, आप AppleScript का उपयोग करके इसे स्वचालित कर सकते हैं।
यहाँ एक स्क्रिप्ट है जिसका मैं उपयोग करता हूँ:
-- 1. Place in ~/Library/Scripts and enable the Applescript menu via the Applescript Editor
-- (Or export to .app to run from spotlight.)
-- 2. Substitute "vpn.example.com", "username" 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 (or for this .app if so exported)
-- 5. Trigger script from the menu (or run from spotlight)
-- 6. Enjoy being connected
-- 7. Run script again to close connection
-- AnyConnect now refered to as targetApp
set targetApp to "Cisco AnyConnect Secure Mobility Client"
-- Determine if AnyConnect is currently running
tell application "System Events"
set processExists to exists process targetApp
end tell
-- Close connection if running; else start connection and fill in password
if processExists is true then
tell application targetApp
quit
end tell
else
tell application targetApp
activate
end tell
tell application "System Events"
repeat until (window 1 of process targetApp exists)
delay 1
end repeat
tell process targetApp
keystroke ("vpn.example.com" as string)
keystroke return
end tell
repeat until (window 2 of process targetApp exists)
delay 1
end repeat
tell process targetApp
keystroke (tab) using {shift down}
keystroke ("username" as string)
keystroke tab
keystroke ("redacted" as string)
keystroke return
end tell
delay 1
tell process targetApp
keystroke return
end tell
end tell
end if
यह एक स्क्रिप्ट है जिसे मैंने पाया और ट्वीक किया; मुझे यकीन नहीं है कि मूल लेखक कौन है क्योंकि आसपास कई संस्करण तैर रहे हैं। मैंने इसे https://gist.github.com/twksos/44b45abf5263635776ec से प्राप्त किया