Creating a Keyboard Macro or Mouse Macro

Auto Hotkey

Creating a Keyboard Macro or Mouse Macro

A macro is a series of scripted actions that is "played" upon demand. The most common activity of a macro is to send simulated keystrokes and mouse clicks to one or more windows. Such windows respond to each keystroke and mouse click as though you had performed it manually, which allows repetitive tasks to be automated with high speed and reliability.

Although macros can be written by hand, you might find it easier to write long ones with the aid of a macro recorder such as the Recorder script written by Titan/polyethene. It watches what you type and where you click, and keeps track of which window is active. It transcribes these actions into a working macro that can later be "played back" at a faster speed.

One of the most convenient ways to play back a macro is to assign it to a hotkey or hotstring. For example, the following hotkey would create an empty e-mail message and prepare it for a certain type recipient, allowing you to personalize it prior to sending:

^!s::  ; Control+Alt+S hotkey.
if !WinExist("Inbox - Microsoft Outlook")
    return  ; Outlook isn't open to the right section, so do nothing.
WinActivate  ; Activate the window found by the above command.
Send ^n  ; Create new/blank e-mail via Control+N.
WinWaitActive Untitled Message
Send {Tab 2}Product Recall for ACME Rocket Skates  ; Set the subject line.
Send {Tab}Dear Sir or Madam,{Enter 2}We have recently discovered a minor defect ...  ; etc.
return  ; This line serves to finish the hotkey.

Hotkey macros like the above are especially useful for tasks you perform several times per day. By contrast, macros used less often can each be kept in a separate script accessible by means of a shortcut in the Start Menu or on the desktop.

To start creating your own macros and hotkeys right away, please read the Quick-start Tutorial.

 

-- Home --