AutoHotkey has powerful commands that let your computer type, click, and move the mouse for you. We’re going to look at two screencasts (5 minutes each) giving examples on how it works, and then elaborate on it after.
In the first one we mainly focus on the Send command, and it’s friends SendInput and SendPlay. We haven’t touched Hotkeys yet so you don’t have a way to ask it to send keys (they’re next!). For trying this out you can put Sleep 10000 at the top of your script, giving you 10 seconds to set up for the rest of your script.
In case you can’t read what I’m typing, letters and numbers are entered in the source by pressing them on a keyboard, e.g., Send abc123 does exactly what you expect.
If you want to send other keys, you put them in curly brackets. It could be Send {Enter} or Send {F1}{F2}{F10} and the alpha-numeric characters can be mixed in there. There are four symbols that are considered “modifiers.” They are ! which is the Alt key on your keyboard, ^ which is Control, + which is shift, and # which is the Windows/Super key (it often has a flag on it.)
The second video leaves off where the first ends. I ended up having more to say than I expected. We mainly go over some example uses such as changing fonts in Notepad by navigating to Format->Fonts and then choosing the next one (pressing down) and finally pressing enter to dismiss the options window. We didn’t even see the Fonts window because it happened so fast!
We also introduce a very useful took called “AutoIt3 Window Spy.” AutoIt and AutoHotkey have a bit of history… well AutoHotkey was started with code from AutoIt2. While some better Spy tools have been made, AutoIt3′s Spy does the job and comes packaged with our language.
Here is the code that will flip through Notepad fonts. Try typing some text first and then running the script. Remember, we’re using Sleep for now because we haven’t done hotkeys yet.
SendMode, Input
; Gives you 10 seconds to get into Notepad
; This is a comment by the way and will be ignored by AutoHotkey
Sleep 10000
Send !o
Send f
Send {Down}
Send {Enter}