One of the more irritating problems with the Windows command prompt is that you can’t paste anything into the window using the keyboard easily—it requires using the mouse. Here’s how to fix that problem.
The solution, as with many Windows shortcomings, is to use a quick AutoHotkey script to enable pasting from the keyboard. What it actually does is take the clipboard contents and use the SendInput function to send the keystrokes really quickly to the console window.
But first… here’s another way to do it.
The Alternate Built-In Way to Paste from the Keyboard
There is actually a way to paste something using the keyboard, but it’s not terribly convenient to use. What you’ll have to do is use the Alt+Space keyboard combination to bring up the window menu, then hit the E key, and then the P key. This will trigger the menus and paste into the console.
Once you get used to doing it, it really isn’t so bad… but who wants to use a different combination for one application than the rest of Windows?
The AutoHotkey Script Ctrl+V Awesomeness
You’ll need to first make sure that you’ve got AutoHotkey installed, and then create a new AutoHotkey script or add the following to your existing script. We’ve also provided a download in case there are any formatting problems.
#IfWinActive ahk_class ConsoleWindowClass
What this script does is simply use the SendInput function to send the data into the window, which is a lot faster than any other method.
Note: the script doesn’t paste line breaks very well. If you’ve got a better solution for that, feel free to let us know in the comments and we’ll update the post.
Downloadable AutoHotkey Script
Simply grab the script, save it anywhere, and then double-click on it to start it. You can kill it through the tray icon if you want—if you’d like to hide the tray icon, add #NoTrayIcon to the top of the script.
Programmer by day, geek by night, The Geek, also known as Lowell Heddings, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on Google+ if you'd like.
- Published 08/16/10