AutoHotkey - automatically solve Problems

AutoHotkey autohotkey.com/ comes handy if you want to solve complex tasks, like some software does not work the way you want. See examples below.

Install

As of 2011-10-25, works in the XP mode of Win7 (not tested under Win7 yet).

Unfortunately the newest version of AHK does no more include the most important part, the macro recorder called "AutoKeyWriter". This little tool is needed to create all those quick scripts, because you don't want to remember everything yourself, right?

The recorder records everything you do, and presents it to you as a text file suitable for AHK, such that you can later replay it on demand, or automate things like in the examples section below.

This tool can be found in the ZIP file of the old installer. It is not yet extended to output Unicode, so the Save button is useless now.

Use AutoScriptWriter

  • Change into the folder where you have "AutoScriptWriter" copied.
  • Start "AutoScriptWriter.exe" from there
  • Click on the red "Record" button on the top left
  • Do what you want to record
  • Click on the animated "Stop" button
  • Mark the portion of the text which seems suitable for you
  • Copy it via the Clipboard (right mouse button, the usual way)
  • Do not use the "Save" button, it does not write Unicode files yet.

Use AHK

  • Start it via "Start" "Programs" "AutoHotkey" "AutoHotkey".
  • If started the first time it creates a file AutoHotkey.ahk for you in the Documents directory.
  • You do not need to open the editor, because AHK starts after you have closed the edit. So decline if it asks to show the script first.
  • In the tray there now is a green "H". This tells you, that AHK is running.
  • Right click on it and select "Edit this script".
  • An editor (notepad) comes up and shows you the script. Keep this editor open all the time.
  • If you edited the script, then save it in the editor. Keep the editor open afterwards until you really know you never need to edit it again ;)
  • To make AHK reload the new script (it is compiled into some internal form), right click on the green "H" in the tray and select "Reload This Script". You need to repeat that every time you saved the script in the editor. (Yes, this is somewhat annoying.)
  • You can "open" AHK to see what's going on. Again via the tray and choosing "Open". It's simple.

Examples

Automate Acronis True Image Restore

While restoring an Acronis True Image (Acronis 9.0 which is rather old today) I came accross the problem that some files could not be restored due to some invalid filenames. Apparently IE is able to store filenames into it's cache which cannot be restored.

The problem with Acronis is, that each time such a file is encountered, the restore stops and asks for confirmation (to ignore this file). There is no option to skip these popups. And because IE caches are bit, zillion of such popups must be answered, which is more than annoying, it makes the restore feature more or less useless.

However there is help. AHK can save the day. Here is a short script:


; WIN+Z
#z::
loop {
WinWait, Error on Backup Operation, 
IfWinNotActive, Error on Backup Operation, , WinActivate, Error on Backup Operation, 
WinWaitActive, Error on Backup Operation, 
Send, i
}

  • Save it into AutoHotkey.ahk (best is: Replace the complete contents of the file if you are sure you do not need it anymore.)
  • Let AHK reload the script
  • And then press Win+Z
Now the script runs in background. Each time the confirmation window pops up, AHK immediately answers it by pressing the "i" key for ignore. You now can sit back, relax, and look at the fireworks on your your screen while the restore takes place. (At my side I had several hundred files ignored this way.)

Don't forget to use "Show Log" to look at all the errors afterwards. Just to be sure that nothing important got automatically ignored.