| September 2008 | ||||||||
|---|---|---|---|---|---|---|---|---|
| Sun | Mon | Tue | Wed | Thu | Fri | Sat | ||
| 1 | 2 | 3 | 4 | 5 | 6 | |||
| 7 | 8 | 9 | 10 | 11 | 12 | 13 | ||
| 14 | 15 | 16 | 17 | 18 | 19 | 20 | ||
| 21 | 22 | 23 | 24 | 25 | 26 | 27 | ||
| 28 | 29 | 30 | ||||||
Thanks to Lifehacker.com website, I recently discovered AutoHotKey, a keyboard and mouse macro creator. It allows, by running small scripts, to automate some tasks, to create or change your keyboard shortcuts and more.
First thing first : HOWTO use AutoHotKey ?
Download it from the official web site ; install it ; create a new text file ; rename it with a ".ahk" extension. There, you have your first AutoHotKey script... Yes it's empty, but it's a script ! Continue the reading for a code example (or scroll down and stop wasting time correcting poor English and typos).
So far I use AHK (that's both AutoHotKey acronym and scripts extensions) for two purposes. The first thing I've done after downloading and installing was to change my CAPSLOCK behavior. Honestly, does anyone use it ? And if I really had to enter a long CAPITALIZED text I would use notepad++ command ! The previously mentioned useless key is now a shortcut launcher : CAPSLOCK+a launches Firefox ; CAPSLOCK+z launches Firefox (with special arguments) ; CAPSLOCK+e launches the explorer and so on. The script is still evolving and I'm not used to it yet, but I've never hit the CAPSLOCK button like I did last week.
The second script I've written was to simplify coding in my favorite language : OCAML (I'll will create Java, Python and C versions latter... maybe). But how could it be helping a coder ? An simple example is when you want to insert comments in your program you have to enter the starting sequence "(*" ("/*" in C and Java) type your human destined text and enter the closing sequence "*)" ("*/" in C and Java). With the ocaml.ahk script you can just hit the CAPSLOCK+c combination to have a full "(**)" as if you've typed it and guess what. Your caret is right in the middle, where you can right your comments. An other example is function declaration, CAPSLOCK+; create the function declaration frame and position your caret at the function name place.
Here's my script but beware, it's intended to be used for AZERTY (frenchy) keyboards with OCAML language. Well, to be honest ot's intended to show that AHK is cool, it's not a definitive version and will get more and more usefull.
; this is a script intended to empower productivity when coding in OCAML language
SetCapsLockState AlwaysOff
CapsLock & c::Send, (**){LEFT}{LEFT} ;create commentary field
CapsLock & 3::Send, ""{LEFT} ;create a pair of quote (or string field)
CapsLock & 4::Send, {{}{}}{LEFT} ;create {}
CapsLock & 5::Send, (){LEFT} ;create ()
CapsLock & 6::Send, {CTRLDOWN}{ALTDOWN}(){CTRLUP}{ALTUP}{LEFT} ;create []
;CapsLock & {LEFT}:: ;will jump to the previous (,[ or {
;CapsLock & {RIGHT}:: ;will jump to the next ), ] or }
CapsLock & i::Send, let{SPACE}{SPACE}={ENTER}{TAB}{ENTER}{BACKSPACE}in{UP}{UP}{END}{LEFT}{LEFT}
CapsLock & .::Send, let{SPACE}{SPACE}={ENTER}{TAB}{ENTER}{BACKSPACE}`;`;{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}
CapsLock & ENTER::Send, {ENTER}{TAB}
I think the Scheme (or every LISP based language) version would be even more power-full. It would, when well used, avoid parenthesis problems. In Java it'll simplify all the "public synchronized void whatever () {}" boring thing...
Updates will be posted as comments.
Send a message
Search for members