Iris Classon
Iris Classon - In Love with Code

Mapping CapsLock to cut, copy and paste

I’m on a mission. My new laptop, Lenovo, is giving me a lot problems which im sure you heard about if you follow me on Twitter and you can expect a few blog posts on how I end up solving some of them. As I’m remapping my keys I thought I’d share my new use for CapsLock, cut, copy and paste.

Bk29axNCIAAyFPG

This script will cut when pressing shift and CapsLock, copy when clicking just the CapsLock key once, and paste on double click.

I’m using AutoHotKey which you might already know I love. And a certain person likes to make fun of the way I pronounce the name :)

Here is a brief introduction to AutoHotKey

And an example of toggling screen resolutions

Download AutoHotKey, and create a file with an .ahk extension. Write the script, and double click on the file to execute it. Its nothing fancy:

~CapsLock::
if (A_PriorHotkey <> “~CapsLock” or A_TimeSincePriorHotkey > 500)
{
KeyWait, CapsLock
SendInput, ^c
return
}

 

SendInput, ^v
return

+CapsLock::
SendInput, ^x
return

Setting CapsLock off:

SetCapslockState AlwaysOff

Setting up a startup script (run the script when you start the computer) can be done a few different ways.

The easiest way is adding the script to the startup folder:

C:\Users[UserName]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

4-10-2014 11-00-01 PM

Or use the Task Scheduler. Add a new task, add an action to start a program, add the script path (this is just a mock as I’m on a another computer), and make sure you let the task run even if not on AC power.

4-10-2014 10-18-10 PM

4-10-2014 10-18-38 PM

4-10-2014 10-19-04 PM

Comments

Leave a comment below, or by email.
StevenMcD
4/10/2014 2:44:58 PM
Thank you so much for this! 
todd brooks
4/10/2014 2:48:54 PM
Interesting.  I've mapped double-tapping on CapsLock to Control-F4 (child doc close).  This is especially handy in VS and browsers, where I can easily, without leaving the home row, close docs after saving/editing,etc.  CapsLock will still work, if I press Shift-CapsLock to toggle. 
Rickard N
4/11/2014 5:21:15 AM
You should paste the script as code in your blog, Iris. You get strange quotemarks when copy+pasting from ordinary text...

Also, for some reason I don't understand, the script does not seem to work in Sublime Text... Double-tap capslock does Ctrl+C and then Ctrl+V. But only in Sublime Text!? :S 
Iris Classon
4/16/2014 12:07:47 PM
Reply to: Rickard N
Sorry about that, I blogged from the phone.

Strange with Sublime, I cannot see why- but tested and yes the paste doesn't quite seem to work. I'll pass on the question to SO, thank you! 
Macs
5/1/2014 10:18:44 AM
Reply to: Rickard N
I've noticed this too in Sublime and a couple of other programs. Sublime must override something that stops it.

Isn't CapLocks the most pointless key?! I've mapped mine to F15 and use it to manage my music.

http://www.macsdickinson.com/productivity/manage-spotify-with-autohotkey/ 


Last modified on 2014-04-10

comments powered by Disqus