Minimizing efforts using AutoHotKey



In windows the most usual way to open up a file, directory or executable is to navigate all the way through path and then double clicking the target file, way too annoying.Another approach is to keep shortcuts on the desktop, okay better than the tradition method but still requires a lot of effort, if you are a geek you may not want to do so much hard work. Hence I looked for a way even easier and what I found is AutoHotKey. Since last 2 days I’m using this awesome tool and I find it pretty easy to employ.


AutoHotkey is a powerful and easy to use scripting language for desktop automation on Windows. In simpler words it lets you define your own shortcuts for certain (set of) operations like opening a file or directory, expanding abbreviations, creating your custom GUI like menu bar, message-box and so on.

To get AutoHotKey working:-
1. Download and Install AutoHotKey, download from here.
2. Right click on the empty area of your desktop.
3. Click on  New>AutohotKey script
4. Right click on the newly created ahk script file and click on edit
5. Paste this on it:

;This will open C:/ drive
#^c:: run C:\
return
We’ll see the working of this script later.
6. Click on this AHK script file, and you will see the green H logo on the taskbar.

Now you have your first AHK script running, to test press Ctrl + Win + C keys on keyboard and you will see C: drive open on your moniter.

AHK Scripting:

AutoHotKey uses its own scripting language, which lets you define you controls. These are the things that will get you started.
1. Keys: AHK(AutoHotKey) scripts uses some characters to depict keyboard button keys
Ex:-
# for window key
! for Alt Key
^ for CTRL key
+ for shift
a,b,c…z are intact 0,1,2…9 are intact
Numpad0, Numpad1… Numpad9 for NumPad keys.


2.  Sample Script: Here goes the sample script that opens Chrome browser on finding the combination Win + Ctrl + C
;This will open C:/ drive
#^c::
run C:\
return
Semicolon ( ; ) is used to write a comment, any text written after semicolon will be ignored, it’s just to increase the readability.
#^C :- As you might have guessed, stand for the key combination Window +  Ctrl + C.
Run c:\ :- Run is the command which opens the C: drive here, you will also use run command to open a website, or any file.
Return:- It declares the end of the operation that is to be perfomed for Ctrl + Win + C key combination.

Run

Run command can be used in following ways:-
1. To open a website

#^!f::
run http://hackaholic.in ;run command followed by website URl
return

2. To run a program

;This script will execute Mozzila firefox
#^m::
run "C:\Program Files\Mozilla Firefox\firefox.exe" ; run command  followed by the path of exe file
return

3. To open a directory
#^d::
run C:\Documents and Settings\%username%\My Documents  ;run command followed by path of directory
return
Remember: Don’t forget to put return at the end of the script module, the script will run even if you don’t use it but will cause unexpected result.

Expand abbreviations: so that every time you write btw, it will get replaced by “by the way”.
::btw::by the way
return

Now, when you create a AHK script put it into the startup folder (C:\Documents and Settings\%username%\Start Menu\Programs\Startup), so every time you turn your PC on, your script will get executed and you don’t need to click on it manually. AHK contains many other things which are beyond the scope of this tutorial, that you will learn by doing, remember the more you experiment the more you learn.

Hasta La Vista.