Force OSX text field to accept copy-paste

6,780

Solution 1

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.

Solution 2

I wrote a very tiny AppleScript application which allows you to paste passwords even where its not allowed by tricking the system into thinking that you're typing on your keyboard. The downside: it takes space in your Dock.

Solution 3

Another thing that still works is to drag and drop text into the prompt. Copy from your password store, paste it into TextEdit or similar application that lets you select text and move it in a OS X native manner. Select the text in TextEdit, then click the text and drag. Drag the selected text from TextEdit to the password input field. And boom the password drops in-place.

Solution 4

I tried the one way I thought might get around the cut & paste prohibition, which was to try using ctrlK and ctrlY, (Kill and Yank), but that also does not work.

This of course, gets back to the rationale of having a long, difficult encryption key to enhance security, but then having several copies of that key readily available in memory which can be accessed by any unprivileged process. However, there are several dozen 3rd party password managers, many free, on the App store that may meet your needs.

Share:
6,780

Related videos on Youtube

notsurewhattodo
Author by

notsurewhattodo

Updated on September 18, 2022

Comments

  • notsurewhattodo
    notsurewhattodo over 1 year

    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...

  • mikl
    mikl almost 11 years
    Well, this was a lot more convenient to me, since typing in my password would probably have taken ~20 minutes to get right :D
  • mikl
    mikl over 10 years
    It seems the update to OS X 10.8.5 has broken this somehow. Now I get this error: error "System Events got an error: An error of type -25133 has occurred." number -25133
  • bobmagoo
    bobmagoo over 10 years
    Works like a charm! I ended up replacing click button 1 of window 1 with keystroke return because it couldn't find the button index.
  • Cesar
    Cesar about 10 years
    Thanks now I won't be forced to format my encrypted disk.
  • Andreas F
    Andreas F about 3 years
    Works for me on MacOS Catalina 10.15.7, thanks!