Last active
April 9, 2024 14:44
-
-
Save fungiboletus/f1570bb3248dfb9955ac617946c1655a to your computer and use it in GitHub Desktop.
Prefill Cisco AnnyConnect SSO login email using HammerSpoon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "v", function() | |
-- Change your email | |
local email = "[email protected]" | |
local ciscoName = "Cisco AnyConnect Secure Mobility Client" | |
local loginWindowName = "login" | |
if hs.application.launchOrFocus(ciscoName) then | |
local ciscoApplication = hs.application.get(ciscoName) | |
local mainWindow = ciscoApplication:mainWindow() | |
while not mainWindow do | |
hs.timer.usleep(500000) | |
mainWindow = ciscoApplication:mainWindow() | |
end | |
mainWindow:focus() | |
hs.eventtap.keyStroke({}, "return") | |
hs.timer.usleep(1000000) | |
local loginWindow = ciscoApplication:findWindow(loginWindowName) | |
local cpt = 0 | |
while not loginWindow and cpt < 10 do | |
cpt = cpt + 1 | |
hs.timer.usleep(500000) | |
loginWindow = ciscoApplication:findWindow(loginWindowName) | |
end | |
if not loginWindow then | |
hs.alert.show("Could not find login window") | |
return | |
end | |
loginWindow:focus() | |
-- Let Microsoft login load | |
hs.timer.usleep(500000) | |
-- Replace with your email address | |
hs.eventtap.keyStrokes(email) | |
hs.eventtap.keyStroke({}, "return") | |
-- Your password should NOT be automatically filled, don't add more steps | |
else | |
-- show error message | |
hs.alert.show("Cisco AnyConnect Secure Mobility Client is not running") | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment