Macos – Force OSX text field to accept copy-paste

encryptionmacmacososx-mountain-lionpasswords

Short version: Is there a way to force text field in OSX to accept pasting a string, despite that the developer (Apple) set it to not to accept copy-paste?

Long story:

Platform: OS X 10.8.2 (Mountain Lion)

Just connected a new external drive, set it to be encrypted (HFS+ encrypted partition). It works as expected.

The problem I have is that I have set a long, randomly generated password. As many others, I have saved this one in KeePassX. Everything would be great… except of the fact Apple does not allow me to simply paste a password into "enter password" dialog that is displayed after connecting a drive!

It is very annoying to rewrite long, random string from one window to second one each time when drive is detected. Is there any way to force the input field to accept pasted password?

To unlock disk "***", type password.

One solution would be storing password in OS X KeyChain, but… it seems that there is a bug with that. The 'input password' window does not disappear even after properly mounting a volume. I type password, click 'Unlock' and the controls are grayed out. After a few seconds, I see that drive appears in Finder, but 'input dialog' windows shakes like in case when wrong password was typed – and reverst back to it's original state. Additionally, despite of checked option to store password in KeyChain, it is not written there (I suppose those two may be related). So, checking "Store in keychain" does not solve my problem…

Best Answer

It's not really more convenient in this case, but you could run this in AppleScript Editor:

tell application "System Events" to tell process "SecurityAgent"
    set value of text field 1 of window 1 to the clipboard
    click button 1 of window 1
end tell

When I clicked the remember in keychain checkbox, the password was saved in the login keychain with the name of the volume, and the volume was subsequently mounted without requiring a password.

Related Question