Skip to content

Instantly share code, notes, and snippets.

@fungiboletus
Last active April 9, 2024 14:44
Show Gist options
  • Save fungiboletus/f1570bb3248dfb9955ac617946c1655a to your computer and use it in GitHub Desktop.
Save fungiboletus/f1570bb3248dfb9955ac617946c1655a to your computer and use it in GitHub Desktop.
Prefill Cisco AnnyConnect SSO login email using HammerSpoon
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