Skip to content

Instantly share code, notes, and snippets.

@mpepping
Created April 6, 2019 12:20
Show Gist options
  • Save mpepping/af304a276fdc9148efb90a4510cceccb to your computer and use it in GitHub Desktop.
Save mpepping/af304a276fdc9148efb90a4510cceccb to your computer and use it in GitHub Desktop.
AppleScript to copy a Safenet MobilePASS OTP
-- AppleScript to copy a Safenet MobilePASS OTP.
--
-- 'osascript ~/path/to/token.applescript'
-- Set 'passwd' to your MobilePASS passcode.
set passwd to "0000"
-- Start MobilePASS
tell application "MobilePASS"
activate
delay 1
end tell
-- Copy token
tell application "System Events"
tell table 1 of scroll area 1 of window "MobilePASS" of application process "MobilePASS"
delay 1
select row 1
end tell
keystroke passwd
delay 1
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
@mpepping
Copy link
Author

@cloudmustafa posted a small update to the script of my previous comment. Maybe it useful ..

@jmccartan
Copy link

Outstanding! Thanks for sharing!!

@marfrede
Copy link

marfrede commented Feb 9, 2024

thanks @mpepping !

I improved this a little further for an even faster approach :-)

takes not even one second now.
(for example by using set value of text field to passwd instead of keystroke passwd)

-- AppleScript to copy a Safenet MobilePASS OTP.
-- 
-- 'osascript ~/path/to/token.applescript'
-- Set 'passwd' to your MobilePASS passcode.
set passwd to "0000"

-- Make sure MobilePASS is not running
tell application "MobilePASS"
	quit
	delay 0.2
end tell

-- Start MobilePASS
tell application "MobilePASS" to activate

-- Copy token
tell application "System Events"
	tell window "MobilePASS" of application process "MobilePASS"
		-- Select the first item in the list
		tell table 1 of scroll area 1 to select row 1
		-- Fill the input field with the value from the passwd variable
		set value of text field 1 to "4321"
		-- Copy the passcode
		set uiScript to click UI element "Copy Passcode"
	end tell
end tell

-- Quit MobilePASS
tell application "MobilePASS" to quit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment