Paste text even when prohibited in macOS (password dialogs etc)

I wrote a tiny AppleScript application which pastes text into fields which do not allow Cmd+V pasting (like password prompts). This may come in handy when working through VNC/remote desktop or virtualization software (such as Apple Screen Sharing, Parallels Desktop etc). Personally I use it to type in my password into the login screen of the Windows virtual machine.

cant-paste-password

To put it in simple terms: the app uses the virtual keyboard to type in the text from your clipboard. It tricks the program that asks for your input into thinking that you’re actually typing on your keyboard.

The downside of the app is that it occupies space in the Dock.

Download Force Paste.app (~15KB). Don’t forget to drag it into your Dock!

(Advanced users may want to use it from the Script menu rather than the Dock. Download main.scpt and put it to ~/Library/Scripts/ directory).

GitHub repository: https://github.com/EugeneDae/Force-Paste

Important note to macOS Mojave users: if you’re getting a “not allowed to send keystrokes” error, simply add Force Paste.app to System Preferences > Security & Privacy > Accessibility. See issue #7.

This entry was posted in Releases and tagged . Bookmark the permalink.

65 Responses to Paste text even when prohibited in macOS (password dialogs etc)

  1. Dwayne says:

    how do you actually use this little app?

  2. Oliver says:

    Thank you so much Dae, this is a genius script. I just got a new external drive and was horrified I couldn’t paste my randomly generated 50 character/digit/symbol/upper-case/lower-case password! You have just saved me at least half-an-hour!

    kudos!

  3. George says:

    Thank you so much for creating this and making it freely available. Now I can keep using long random passwords without going insane. A lifesaver.

  4. Kelvin says:

    This little app is awesome! The perfect companion to 1Password!

  5. Paolo G. Giarrusso says:

    Thanks a lot!

  6. Brian Aker says:

    Hi!

    Do you have the entire project pushed up to github anywhere?

    Thanks,
    -Brian

  7. Andy Ibanez says:

    Fantastic tool Dae.

    I really hate it how we can’t copy paste into the text field whenever we are asked for a password, like when working with certificates or encrypting disk images.

    I will try to fork the project to do it a little bit more friendly. Thanks a lot for the tool and for releasing the source code.

  8. Curtis Jackson says:

    Thank you thank you thank you thank you! from a 1Password user.

  9. Max says:

    Great script Dae! thanks a lot

  10. miguel says:

    is there anyway to use an app to map the trigger to a function key (or any other key for that matter)?

  11. Adam says:

    I love you for this!

  12. Ivan says:

    First I didn’t realise that the script has to be dragged to dock. After doing that – it just works.

    Passwords copied to clipboard from password manager are getting pasted to pass field for encrypted images without any problem.

    The easiest and the most elegant solution that I could find by far.

    Thanks a lot Dae:)

  13. Gene says:

    Hi,

    Great tool but it did not work for me on my MacBook Pro with the latest OS X.

    I figured out that I have to type at least one character in password field and then delete it before Force Paste will paste into the field. Now Force Paste saves me a lot of time.

    Thanks!

    • Dae says:

      Hi Gene, I also use MacBook Pro with the latest OS X 10.10.3 and Force Paste works straight away for me. I wonder why it doesn’t in your case?

      If you could record a small screencast using LICEcap or a similar app, possibly it’d give me a hint.

  14. David Joerg says:

    THANK YOU!

  15. Pingback: » Apple:Why can't I paste into the password dialog when mounting an encrypted disk image?

  16. sleepcircle says:

    Thanks! Super cool. I will treasure this always.

  17. Rosa says:

    You are absolutely a divine send!!! Thank you soooo much!!!

  18. Max_G says:

    Doe this also work in El Capitan?

  19. IT H8r says:

    Works very nicely in Citrix where they have the copy/paste disabled and you really don’t want to type that whole stinking URL into MS Explorer just to use some web site that is non-standard.

    Used this app and it typed directly to my Citrix window from the clipboard. Sweet!

  20. Dan Gildea says:

    Used LastPass this weekend to create really complex passwords for all my internet accounts, including Google Apps.

    After restarting my computer, my local Google Drive.app asked for the new password.
    Of course, I wasn’t able to just cut and paste this new incredibly complex password into the field in Google Drive.app.

    I went on a hunt and found Force Paste:
    https://dae.me/blog/1741/paste-text-even-when-prohibited-in-os-x-password-dialogs-etc/
    It solved my problem immediately.

  21. Clark Carneal says:

    This is a fabulous little app. Thank you so much!

  22. Rick B. says:

    This is a very helpful and awesome tool.

    I’m trying to paste a complex password that uses ‘ü’, but when I copy it and ForcePaste does its thing, it’s change to a regular ‘a’

    Is there a work around for this?

    • Dae says:

      Thanks, but I’m afraid this can’t be fixed easily. The problem lies in AppleScript’s “keystroke”, which only outputs characters immediately available on a typical English keyboard. It won’t type Russian letters either. I’m afraid I can’t do anything about that :/

  23. Richard Smith says:

    Thank you so much. A great tool and saved me hours of work. Truly appreciated !

  24. John Basile says:

    Dae
    Love the App. I have a dialog that comes up every hour.. ask for my credentials, name & password… royal pain in the ass.

    Anyway, is there a script/app to use a keyboard short cut that enters the cursor in the userName field, paste in the name, then goes on to the password field.. and past in the password from your script…then hits return…boy would that be nice!

  25. Patrick J. says:

    Amazing app! Drag the Force Paste.app into your desktop dock and remember to use the shortcut: press command + V together, at the same time, to force paste to a secure login box. Highly recommended app for Mac OS X users!

  26. Remco says:

    Thank you so much for this! I need to work with a website of which the makers are under the illusion that pasting is “insecure” so they prefer the user to manually enter all info. This is a life saver.

  27. Steve says:

    Does not work osx 10.6.8

    • Dae says:

      I don’t have any 10.6.8 systems at my disposal anymore, but I think it should work. What happens exactly when you click the app, it doesn’t start or it just doesn’t do anything? Can you open AppleScript Editor, copy/paste this code and click run?

      • Steve says:

        I am not sure this is a place for all I know is the app crashes with the following report which I hope may help

        Exception Type: EXC_BAD_ACCESS (SIGSEGV)
        Exception Codes: KERN_INVALID_ADDRESS at 0xfffffffffffffff8
        Crashed Thread: Unknown

        (remaining lines stripped by dae)

        • Dae says:

          Thanks, Steve. I think if you manage compile it yourself on your system, it will work. Here’s how you can do this:

          Step 1. Download the code and extract the contents of the archive into a folder on your Desktop called “Force-Paste-master”.

          Step 2. Click the magnifying glass icon at the top-right corner of the screen to open spotlight search and use it to open Terminal.

          Step 3. In Terminal, run the following command one after another:

          cd ~/Desktop/Force-Paste-master/
          chmod +x build.sh
          ./build.sh

          If everything goes well, you’ll find the app in that directory on your Desktop.

  28. russell says:

    I have been problems with OS X sierra crashing my copy and paste between apps. It only pastes in the same app it copied from. I thought I would give this a shot, and low and behold, when Sierra fails to paste, force paste actually works!~

    Thanks.

  29. Chris says:

    Trying to change my remote management password but can’t get to paste. Just keeps the same old password no matter what. I moved to dock, tried script. Same result. Am I doing something wrong or is it still working for everyone?

    OS Sierra, latest.

    Thanks,

    Chris

  30. jeb says:

    need it to paste the windows 8 password running in a virtual machine but isn’t working

  31. DanielB says:

    Hi Dae,

    Thank you very much for this tool which is currently a lifesaver for me and speeds up a very repetitive workflow.

    I was wondering if it would be possible for me to add some basic text replacement functionality to the script?

    The tool I use does not support OS X’s native text replacement, and I would like to accomplish something like that.

    Example: copied text contains “cuz”, Force Paste corrects that and pastes “cause”.

    It would be great if you could provide some insight on that.

    Thanks in advance!

    • Dae says:

      Hi Daniel – yes, of course. Clone the repo, open main.scpt in your favorite code editor, grab the code of findAndReplaceInText() function from here and use it on input variable, for example:

      set input to findAndReplaceInText(input, "cuz", "cause")

      In Terminal, cd to the working directory and run ./build.sh to build the app with your changes.

  32. Hobbes says:

    Fantastic. I tried to add a delay of 50ms between each stroke (doing this over a VDI connection which misses key strokes if they’re too fast…) and save it as a .app, but this does not work. I suppose it’s not that simple to add 50ms to the .app version?

  33. john says:

    Awesome little app! Thank you.

  34. Ceridwen says:

    I’m trying to run this script on 10.12.6, and while I can build it, when I try to run it from the Finder I never see a dock icon. I can run it from the terminal (open “Force Paste.app”) but it only pastes into the terminal there, not into the password dialog I need it to paste into.

  35. Karthik says:

    Thanks for this awesome tool…really saved lot of time for me and my team.
    In the applescript you had provided, you had used set numbers_key_codes to {82, 83, 84, 85, 86, 87, 88, 89, 91, 92}
    What is the logic behind using “key code” in the script, trying to understand…

  36. John Baker says:

    It still works, and it works great! A real time and frustration saver! Thank you!

  37. Erwin says:

    Wow thanks… works perfectly

  38. Scott says:

    Hi Dae. Can’t seem to get ForcePaste to work on Mojave. Getting this error even after dragging into to Privacy/Accessibility:

    Force Paste is not allowed to send keystrokes.
    System Events got an error: Force Paste is not allowed to send keystrokes. (1002)

    I’m not advanced with script etc so that probably doesn’t help. Any fix would be much appreciated.

  39. Picard says:

    If you insert

    key code 36

    as line 3 from bottom, the script will hit the enter button for you as well.

    That is:

    set numbers_key_codes to {82, 83, 84, 85, 86, 87, 88, 89, 91, 92}

    set input to do shell script “pbpaste”

    if (input is not missing value and length of input is less than 250) then
    tell application “System Events”
    repeat with char in the characters of input
    try
    key code numbers_key_codes’s item (char + 1)
    on error
    keystroke char
    end try
    end repeat
    key code 36
    end tell
    end if

  40. Mark says:

    Force paste works about 99% of the time for me, but everyone once and awhile it will not paste the correct characters in. So for example if the password has an @ it will paste a 2, or if the password has a ! in it, it will put a 1. It also is not honoring capitalized letters either when it doesn’t honor the @ or !, any ideas as to what could be causing this?

  41. Adam says:

    Hi,
    This little app is awesome but I’d like to ask is it possible to adjust the script that way that the app will paste every time the same key string (e.g. my very long password) whenever I press the app icon? At my work I’m using many applications and I have to type my password every time I’m logging in which is very time consuming. Now before I use Force Paste I have to copy my password from text file using CMD+C. I’d like Force Paste to remember my password all the time.
    Thank you very much in advance for your help and feedback.

    • Dae says:

      Hi Adam, here you go:

      set input to "mylongpassword"
      
      set numbers_key_codes to {82, 83, 84, 85, 86, 87, 88, 89, 91, 92}
      
      tell application "System Events"
      	repeat with char in the characters of input
      		try
      			key code numbers_key_codes's item (char + 1)
      		on error
      			keystroke char
      		end try
      	end repeat
      end tell

      Change mylongpassword to whatever you want.

      Fork the repo from GitHub, replace the contents of main.scpt with the code above and run the build script.

      • Adam says:

        Hi Dae,
        thank you very much for your help. The script you’ve written above works fine and thanks to it I’m saving a lot of time now.

        I tested another script which is working the same way:

        on run {input, parameters}

        tell application “System Events” to keystroke “mylongpassword”

        return input
        end run

Leave a Reply

Your email address will not be published. Required fields are marked *