Saturday, February 9, 2013

Autohotkey Beginners Tutorial

Autohotkey: A Beginner's Move On

Autohotkey is a Superpowerful Scripting Language available at
It's more Powerful than you can imagine.Believe me,the day I started using it I was amazed how I was using a PC in this universe without Autohotkey. I mean it's so so easy,yet so effective and fast.

By it ,you can

  • Automate almost anything by sending keystrokes and mouse clicks. You can write a mouse or keyboard macro by hand or use the macro recorder.
  • Create hotkeys for keyboard, joystick, and mouse. Virtually any key, button, or combination can become a hotkey.
  • Expand abbreviations as you type them. For example, typing "btw" can automatically produce "by the way".
  • Create custom data-entry forms, user interfaces, and menu bars. See GUI for details.
  • Remap keys and buttons on your keyboard, joystick, and mouse.
  • Respond to signals from hand-held remote controls via the WinLIRC client script.
  • Run existing AutoIt v2 scripts and enhance them with new capabilities.
  • Convert any script into an EXE file that can be run on computers that don't have AutoHotkey installed.

  • So Lets Start

    Well the autohotkey tutorial is a good place to learn autohotkey.It comes as a fair book full of all Hotkeys and commands that you need to know.It's well structured and full of links and examples that will help you get moving. But if you want a quick guide that can increase you productivity with autohotkey in no time this is for you.

    You can start with creating shortcuts for opening files and documents.

    ; a SEmicolon (;) is used for comment.
    ;Here ! stands for Alt and 'n' Is Key N
    run notepad.exe
    ;runs notepad
    ^d:: ;  ^ is ctrl
    run d:/my docs/mydoc.doc  

    You can also use Autohotkey as a Text Expander

    ::btw::by the way
    ;This expands Btw to "by the way" when followed by a Space,comma or semicolon.
    ;Also you can use "Send" command to create hotstrings. !n:: run notepad.exe Winwait, ahk_class Notepad ;Winwait waits for the Specified window to appear. Send Hi, There ;Here Alt + n runs notepad and waits for it. When the window opens it prsses or Writes Hi, There return

    Use #Ifwinactive command to make same hotkeys perform different functions in different windows.

    #IfWinActive ahk_class CabinetWClass   ;Cabinetwclass is class name for windows explorer 
    ;Use "WINDOWS SPY" utility in Autohotkey Pacakage for getting class name for different windows.
    run notepad.exe
    #IfWinActive ahk_class notepad    ; ahk_class notepad is notepad window  
    run d:/mydoc.doc 

    Okay, what the above program does is that it opens notepad when you press alt+n in windows explorer and opens mydoc.doc when you press alt+n in Notepad. But, here when when you press Alt+n in paint nothing will happen. Alt + n will have no effect in any other window.

    You can Remap Keys...

    Suppose you have a keyboard where you have your "T" key or any other key/keys missing and you dont want to get to the mechanic and lose some bucks only for that mere purpose. Here comes Autohotkey to the Rescue.Remapping in Ahk is as easy as creating a Ms word Document. Have a Look---

    ;This will make End Key behave as "T" [HArdly any one uses End]
    Remapping may not work in certain games and applications & keys might go back to their original functions.

    Perform same Tasks again and again ..

    Suppose you have to scroll down a large folder of Photos or files such slowly that you can watch them.
    Loop 1
    Send {Down}
    Sleep, 1000   ;Sleep is used to delay execution.Here 1000 denotes time in ms.  1000 ms = 1 sec
    ;The down key will be pressed 100 times
    Exitapp             ;Here Alt + a when pressed will exit the script conatining the loop and Scrollong Down (here) will Stop.

    You can increase that 100 to as much as you like.
    Use an Exitapp command as above to end scripts when you like.


    • Have a look at the given Autohotkey manual.It is your utlimate guide into the world of Autohotkey.
    • If you use Autohotkey and create custom scripts,it is advisable that you create a single script and not many scripts for each function.This is because it is seen that a standard Ahk Script consumes some 6mb's of Ram or close to 6mb's when it runs,Also the size of a script has minimal impact on Ram.So if you run 4 scripts for 4 functions or so they will cost you 6 X 4 = 24 mbs of RAM.So it is highly recommended to have a SINGLE Master Script.
    • Download Scite for Autohotkey -- A Gui IDE for Autohotkey.
    • Always add an EXITAPP command to your Script.
    • Always end a Hotkey declaration with" Return".
    • Use { .... } to specify regions of #Ifwinactive and other condition based commands
    • Go here to see Some of my special AHK Scripts which I am SuperSure you will enjoy.

    No comments:

    Post a Comment