Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

AutoHotKey: Automate Windows with a Third-party Scripting Language

If you are the type of person who finds keyboard inputs such as HotKeys convenient for controlling Windows, read on. AutoHotKey is a simple scripting language that will allow you to extend HotKey functionality and send inputs to applications.


advertisement
f you're like me you're always looking for ways to increase productivity. This search can involve lots of different technologies. One limitation on technology usage is its applicability to the scope of a problem, if you need to open 20 documents in Open Office and run a filter to convert them to Docbook the best solution would probably not involve writing Java. For these simple operations one tends to use scripting languages that have interfaces appropriate to the task at hand.

There are problems inherent in using a scripting language:

  1. You will need to learn the interfaces the language provides for your task.
  2. Sometimes your preferred language does not provide any easy interface, so you are stuck either doing the task manually, doing the task in a difficult manner, or learning a new language for the task.
In the example of converting 20 documents to Docbook you'd probably find it makes sense to do this task manually because time constraints make this temporarily the most productive solution.

In Windows, which I expect a lot of us have to deal with in one way or another, there is a solution; it is to use the graphical nature of Windows to automate things. This solution provides several benefits:

  1. Often the interfaces provided by a program menu or hotkey combination are not matched directly by the API of a particular program, thus something that can be represented by one or two mouse clicks must be done by many lines in a scripting language.
  2. By being able to send keystrokes and mouse movements directly to an application you can create a cross-application scripting language that will use the same interfaces for a large number of applications.
There are a number of ways to automate keystrokes and other user inputs in Windows, but the best I have found for my needs is the AutoHotKey scripting language.



Running AutoHotKey
As its name implies, AutoHotKey is useful for making HotKeys. A HotKey is a sequence of concurrent keystrokes that will cause an application to do something—an example is the well-known Ctrl-Alt-Del keystroke combination.

AutoHotKey scripts have the extension .ahk; when right-clicked you can choose to run or compile the script. When you choose to run the script it will be loaded into your taskbar and can be accessed from there.

You can run multiple AutoHotKey scripts at the same time; all of them will load in the taskbar. If you are using the scripts to catch keyboard or other user interface input you will have to make sure that concurrently running scripts do not have key collisions or conflict in other ways (see Figure 1).

Figure 1. The screen shot shows an AutoHotKey script running in Taskbar with the right-click context menu selected, the big green H is the icon for an AutoHotKey script.
AutoHotKey can do pretty much anything a normal scripting language can. It has the ability to build GUIs and interact with protocols such as http, but where it really shines is catching data from user interface devices and sending user interface device data to running applications. In this article I will focus on catching and sending keyboard data to applications as an example of this functionality.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap