Skip to content

Instantly share code, notes, and snippets.

@ericboehs
Last active October 27, 2016 16:50
Show Gist options
  • Save ericboehs/761a68fd1669afb9307e971a2f5cf055 to your computer and use it in GitHub Desktop.
Save ericboehs/761a68fd1669afb9307e971a2f5cf055 to your computer and use it in GitHub Desktop.
Fill in system password dialogs from 1Password
-- Change E27 to a unique string that will find your system password in 1Password
do shell script "open x-onepassword-helper://search/E27"
-- Give 1Password a smidge of time to open
delay 0.5
-- Copy the password to the clipboard (1Password will auto clear it after 90 seconds)
tell application "System Events" to keystroke "c" using {shift down, command down}
-- Give 1Password a smidge of time to copy
delay 0.5
-- Focus the system password dialog
tell application "SecurityAgent" to activate
-- Open ForcePaste, an app that types out your clipboard using virtual keyboard events
-- Secure system dialogs don't allow you to paste into them normally
do shell script "open /Applications/Force\\ Paste.app"
-- Delay a smidge as Alfred loses focus when activating via a Workflow
delay 0.5
-- Uncomment this line to press enter after pasting.
-- I didn't do this in case I accidently activated this while in Messages, Slack, etc.
-- There's no safeguard to prevent it from sending your system password to whoever you're chatting with.
-- tell application "System Events" to keystroke return
@ericboehs
Copy link
Author

ericboehs commented Jul 4, 2016

You'll need to download Force Paste to your /Applications.

For convenience, I created an Alfred Workflow to launch this AppleScript via a global keyboard shortcut.

It didn't want to run from within Alfred so I saved this as an AppleScript Application (an option in Script Editor's save dialog) and gave it accessibility rights in Security.prefPane.

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