As I have already stated, one of my favourite tools that I install right away on a fresh machine is the AutoHotkey. It makes life a bit easier shortening the way to perform common tasks. Among other features, it provides a way to associate keyboard shortcuts with a scripted outcome.
To use these, you just need to install the program, and start a script. If you like the script to run by default, add a shortcut to your Startup folder.
I run these scripts in the startup folder, and keep them in My Dropbox folder, so if I make some improvements, it gets synchronized across all computers I work on.
So here are some scripts I use. If you want, you can download the whole thing here.
General
I never use Caps Lock, so I disable it.
; Caps Lock - disabled CapsLock:: *CapsLock:: Return
It’s really useful to keep a window on top sometimes (Windows key + t).
; Win+T - toggle the active window on top #t:: WinSet, AlwaysOnTop, Toggle, A
This will perform a default action on the selected file name (Windows key + o). What’s even better, it will open a full URL (starts with http://…).
; Win+o - copy selection to clipboard and open file #o:: clipboard = Send, ^c ClipWait, 2 If ErrorLevel = 0 Run %clipboard% Return
Disable Alt + Enter to send a message in GTalk (I found myself making this mistake quite often).
; Alt+Enter GTalk disabled #IfWinActive ahk_class Chat View >!Enter:: <^>!Enter:: Return
Clipboard
I have created a combined script to run some transformations on the text copied to clipboard. Here are the pieces doing the work, but in the final script, these are combined.
My keyboard shortcuts for these start with Windows key + V and then
L – paste without line breaks, as a single line.
C – paste as a CamelCase (useful to programmers)
T – output As A Title (useful for writing)
_ – replace spaces with underscores.
V – paste without formatting (a blessing when you copy from a rich text editor).
? – short help to remind of these shortcuts ;)
Piece by piece
Paste without formatting
SendInput {Raw}%clipboard%
Paste without line breaks, as a single line.
StringReplace, ClipBoard, ClipBoard, `r`n, , All SendPlay ^v
Paste as a CamelCase or Title, depending on pressed key.
cl = %clipboard% output = Loop, parse, cl, %A_Space%, %A_Space%%A_Tab% { str = %A_LoopField% StringUpper, str, str, T If (key = "c") output = %output%%str% Else output = %output% %str% } ClipBoard = %output% SendInput %clipboard%
Replace blank characters with underscore.
StringReplace, ClipBoard, ClipBoard, %A_Space%, _, All StringReplace, ClipBoard, ClipBoard, `,, _, All StringReplace, ClipBoard, ClipBoard, ., _, All SendInput %clipboard% ClipBoard := oCB
Here’s the full “paste special” script…
#v:: Input, key, L1, , -,_,l,c,t,v,? If ErrorLevel = Match { oCB := ClipBoardAll If key = l { StringReplace, ClipBoard, ClipBoard, `r`n, , All SendPlay ^v ClipBoard := oCB } If (key = "c" or key = "t") { cl = %clipboard% output = Loop, parse, cl, %A_Space%, %A_Space%%A_Tab% { str = %A_LoopField% StringUpper, str, str, T If (key = "c") output = %output%%str% Else output = %output% %str% } ClipBoard = %output% SendInput %clipboard% ClipBoard := oCB } If (key = "-" or key = "_") { StringReplace, ClipBoard, ClipBoard, %A_Space%, _, All StringReplace, ClipBoard, ClipBoard, `,, _, All StringReplace, ClipBoard, ClipBoard, ., _, All SendInput %clipboard% ClipBoard := oCB } If key = v SendInput {Raw}%clipboard% ; help message If key = ? { MsgBox, 64, Paste special options , ( window + v `n - or _ replace space, comma and dot with underscore `n l text in one line `n c CamelCase `n v paste as plain text ) ,10 } } Return
Paste in Command Prompt
It’s a great improvement when you can also paste using Ctrl + v in the Command Prompt.
#IfWinActive ahk_class ConsoleWindowClass ^V:: SendInput {Raw}%clipboard% Return
There’s plenty of other scripts to be found on forums, and some on Lifehacker as well.
Any experiences with AutoHotkey? Feel free to comment below.
Leave a Reply