Last active
October 27, 2016 16:50
-
-
Save ericboehs/761a68fd1669afb9307e971a2f5cf055 to your computer and use it in GitHub Desktop.
Fill in system password dialogs from 1Password
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
-- 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.