Skip to content

Instantly share code, notes, and snippets.

@cloudmustafa
Created December 13, 2020 22:20
Show Gist options
  • Save cloudmustafa/7c5e65c8c705560708b3494409fa1b95 to your computer and use it in GitHub Desktop.
Save cloudmustafa/7c5e65c8c705560708b3494409fa1b95 to your computer and use it in GitHub Desktop.
Macbook-Applescript for Mobilepass automation
-- AppleScript to copy a SafeNet MobilePASS OTP.
set passwd to "0000"
-- Make sure MobilePASS is not running
tell application "MobilePASS"
quit
delay 0.5
end tell
-- Start MobilePASS
tell application "MobilePASS"
activate
delay 0.2
end tell
-- Copy token
tell application "System Events"
-- Give the window focus in a robust way
set frontmostProcess to first process where it is frontmost
set visible of frontmostProcess to false
repeat while (frontmostProcess is frontmost)
delay 0.1
end repeat
set secondFrontmost to name of first process where it is frontmost
set frontmost of frontmostProcess to true
-- Select the first item in the list
tell table 1 of scroll area 1 of window "MobilePASS" of application process "MobilePASS"
delay 0.5
select row 1
end tell
-- Fill the input field with the value from the passwd variable
keystroke passwd
delay 0.5
-- Copy the passcode
set uiScript to click UI element "Copy Passcode" of window "MobilePASS" of application process "MobilePASS"
end tell
-- Quit MobilePASS
tell application "MobilePASS"
quit
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment