Why Do Sites Prevent Pasting?
Some stupid web sites (and OSX dialogs) disable the ability to paste into them, usually for passwords.
v, or right click and select paste, you have to type it in manually.
Maybe they think this is increasing security, but in reality it’s just frustrating.
And if you use a password manager like I do, this is super inconvenient.
There’s a good chance that I’m going to type in my 27 character random password wrong, and have to do it again.
This happened for the last time a few days ago, so I wrote a little script to get around that: mac-paste.
tell application "System Events" repeat with char in the characters of (the clipboard) keystroke char end repeat end tell
All this does is go through the clipboard contents one character at a time, and simulates keystrokes for each character as if you had typed it yourself. They can’t block that.
How to Set This Up
The script is really simple, but setting it up to work is kind of a pain.
I set this up to use the hotkey
v (Control-Option-Command-V), but of course you can use whatever makes sense for you.
1. Create a service using Automator
Launch Automator (I just hit
⌘-Space and use spotlight)
Click “File” > “New”
Select “Quick Action” and click “Choose” (this used to be called “Service”)
In the top right hand of the window, set dropdowns so that ‘Workflow recieves “no input” in “any application”’
In the second column containing the long list, search for “apple” and double-click “Run AppleScript” - this adds the “Run AppleScript” window on the right
Paste the code from the
mac-paste.scpt file into the text box (you can click the little hammer icon to get nice formatting)
Click “File” > “Save…”, and save this as “MacPaste” (or whatever name you want)
2. Create the hotkey shortcut
In System Preferences, click “Keyboard” > “Shortcuts”
Select “Services” in the sidebar
Find “MacPaste” under “General”, and select it
Click “Add Shortcut”
v (Control-Option-Command-V) to assign that shortcut (or whatever shortcut you want)
3. Allow this shortcut to use Accessibility features (for System Events)
(You should only have to set this up for your first Automator action)
In System Preferences, click “Security & Privacy” > “Privacy”
Select “Accessibility” in the sidebar
Click the padlock in the lower left to allow changes (you will have to type your password)
Click on the + sign, and add Automator from /Applications
4. Allowing applications to use this
For every application you will use this with, you have to give them Accessibility permissions
For example, running this the first time with Chrome, it will pop up this dialog, just hit OK:
And it will probably pop up this dialog as well, hit OK again:
Then you will need to give Chrome Accessibility permissions as well
Now no one can stop your pasting