Creating new macro, menu or toolbar
Adding menu items and toolbar buttons
Launching macros, menus and toolbars
How to know that a macro is running
How to assign a toolbar to a window
How to create an "auto-hide" toolbar
How to create text-replacement ("autotext") macros
Can macros run in any program?
Can two macros run simultaneously?
Can macros run in the backround?
Can I run a macro without running QM?
Can the macro run when an error occurs?
What is the System folder and other default items in the list?
What is the list that pops up when I type a period (.)?
Disabling commands, adding comments
Using strings; inserting newlines and quotes
Programming in QM (if, goto, functions, etc)
A macro is a list of commands that are executed when the macro runs. The commands can perform the same actions as you do manually each day: type text, click menus, run files, etc. To launch a macro, you can assign it a trigger (e.g., hot key), or place it in a toolbar, or use some other way. That is, instead of manually doing the same sequence of actions again and again, you can place it in a macro, and launch it with just a single click or keystroke.
Macros are easy to create. In many cases, you can simply record your actions (click the Record button on the toolbar, ...).
In the Quick Macros window, you can create macros, as well as items of other types (functions, toolbars, etc). You create a macro for each task you want to automate. You can assign it a trigger (e.g., hot key), or place it in a toolbar or menu.
Quick Macros runs continuously (although normally it is hidden most of the time). It watches for triggers that are assigned to macros. When a trigger occurs (e.g., hot key pressed), is launched the macro to which the trigger is assigned. When the macro runs, are executed commands it contains. Quick Macros also manages your toolbars and menus.
To show the Quick Macros window, click
icon in the system tray or in the Start menu.
Window parts:
Left side - list of QM items - macros, functions, menus, toolbars, TS menus.
Right side - text (list of commands) of the currently selected item.
Bottom-right - QM output or tips. In the output are displayed error descriptions and other messages.
Bottom - status bar.
Top - menu, toolbar, floating toolbar.
You create a macro for each task you want to automate. To create new macro, click the New Macro button on the toolbar, and type a name in the small field that appears at the top of the list. To create an item of other type (function, toolbar, etc), use the popup menu that appears when you click the small arrow beside the New Macro button.
Macros are stored as simple text. Usually, each command is stored in a separate line.
To add macro commands, you can use dialogs from the floating toolbar. However, QM does not provide dialogs for all commands, and therefore you have to type other commands directly. You can find all commands listed in the Reference topic. You can also type a period (.) to view and insert available commands, functions, etc.
The simplest way to add macro commands - record.
You can record keystrokes, mouse, and some other commands. You can record complete macro, or only some parts.
To start recording, click the Record button on the toolbar. When recording is finished, click Insert or other button in the QM Recording dialog.
Recorded macro often is not perfect. You have to review and possibly edit it. For example, recorded macro may run too fast, and you have to insert delays or change the wait time in wait commands. Recorded window names often contain document name, which causes error when running the macro when there is open other document. In this case, remove document name.
When recording, it is recommended to use the keyboard insted of the mouse (where possible), especially to select menu items (use Alt and underlined letters). It is because menus and other objects next time may be in another place, even when recorded mouse coordinates are relative to window (default).
Menu text is simply a list of macro commands. Each command is preceded by some text (label), space and colon. The same with toolbars. Each line creates menu item or toolbar button, which will execute the command.
Example:
Macro18 :mac "Macro18" Notepad :run "notepad.exe" - Email :key "my@ema.il" * text.ico Login :key "abcd"; key T; key "1234"; key Y * text.ico

To quickly add a macro, drag and drop it from the list to the menu/toolbar text. To add a file, use the Run File dialog from the floating toolbar, or drag the file from the desktop or Windows Explorer. To add other commands, use other dialogs from the floating toolbar. To add a separator, type - or |. To add icons, use the Icons dialog.
You can use various ways to launch a macro:
You can use the Run button on the QM toolbar.
You can assign it a hot-key, mouse, window, or other trigger. To assign a trigger click the Properties button on the toolbar.
You can place it in a toolbar. Open the toolbar and drag the macro onto the toolbar text. Similarly, you can place it in a popup menu. A toolbars can be attached to a window.
You can schedule it to run at a certain time or on some other event. Click the Schedule button in the Properties dialog.
You can create a shortcut on the desktop. Click the Shortcut button in the Properties dialog.
Other programs can launch QM macros using command line.
You can use the mac command to launch it from another macro.
T.S. menu commands are executed when you type a text.
Menus, toolbars, T.S. menus and functions can be launched using the same ways as macros.
When a macro is running, the QM tray icon is red
.
When items of other types (functions, menus, etc) are running, the tray icon
does not change. You can see running functions in the Threads dialog (in the
tray icon menu) and in the Running Items list (menu Run -> View Active Items).
When a macro is running, the QM tray icon is red. To end running macro manually, press Pause key (you can change this in Options). If input is blocked (BlockInput is used in the macro), at first press Ctrl+Alt+Delete.
If it is a function, you cannot end it using Pause. Right click the QM tray icon, click Threads, select the function and click End Thread. Or use the Running Items list (menu Run -> View Active Items). Or, if you use the AddTrayIcon function to add a separate icon, you can Ctrl+click it.
Or, you can place special code in the macro or function. Example:
rep ifk(F12) ret ;;exit if F12 is pressed ...
Assign it a window trigger. To assign a window trigger, select Window in the Properties dialog, drag the "Drag" picture and drop onto the window. You may have to edit or remove window name, e.g., remove the name of the currently open document.
Click menu File -> New -> Templates -> Toolbar Top or Bottom, or Toolbar Left or Right. To launch it, you for example can assign a mouse trigger. Or, launch it at startup.
You can drag toolbars with the right mouse button. To drag or delete buttons, Shift+Drag. You can drag macros, files and Internet links and drop onto a toolbar. To change toolbar style, or quickly open to edit, use the right-click menu.
If you have lost a toolbar (it is running but invisible), check View Active Items in the Run menu, right click a toolbar in the Running Items list, and click Move Here or Reset.
In QM, instead of creating separate macro for each replacement, you create one or several T.S. menus, and place the replacements there.
Macros can run in any Windows program. You can make a macro to run only in a certain program(s).
Some triggers may not work in DOS and console programs, especially in full screen mode and on Windows Vista. Try low level hooks (in Options). Also, macros may not run properly in some games.
Several macros cannot run simultaneously. If a macro (macro2) is launched while a macro is already running, macro2 will not run. Similarly, several instances of the same macro cannot run simultaneously.
Several functions can run simultaneously. If a function is launched while a macro or function is already running, they will run simultaneously.
Macros that use keyboard, mouse and some other commands, cannot run in the background. However, it is often possible (but not so easy, and will not always succeed) to replace keyboard and mouse commands to other commands that usually can work in the background. To insert such commands, use dialogs from the floating toolbar's "Windows, Controls" menu.
Yes. You can create executable programs from macros and functions.
When a macro is launched, at first it is compiled. This includes error checking. If the macro contains errors, it is not executed. Error description is displayed in the QM output, and error place is highlighted.
When macro runs, some commands may fail (e.g., due to a missing file or window). Then macro ends. To continue on run-time error, you can use err. Example:
run "abc.exe" ;;macro would end if file "abc.exe" does not exist err ;;allows macro to continue when an error occurs in the preceding command
Many QM features are written in QM language. It includes the floating toolbar, all dialogs from it, the Dialog Editor, and many useful functions that you can use in macros. All this code is placed in the System folder. That is why you should add System to each file you use (by default, it is added automatically). The System folder actually is loaded from separate file System.qml.
Macros in the Default Macros folder aren't necessary but can be useful to you.
The Samples folder is absolutely not necessary, and is provided only for learning.
The list contains functions and other identifiers that you can use in macro. Double click an item in the list to insert it in macro. At the top of the list, are listed categories - collections of related functions. When you double click a category in the list, pops up another list containing functions from that category.
Lines that begin with a space are disabled. This also can be used to add comments. To quickly disable/enable single line, right click the selection bar (thin gray bar at the left of the macro text). To disable/enable several lines, select them and right click the selection bar. To add comments at the end of line, use two semicolons.
Example:
comments key Cv ;;press Ctrl+V
Strings (text) must be enclosed in double quotes. To insert a double quote in a string, use '' (two apostrophes). To insert a newline, use [].
All this is true when you enter strings directly. When you enter strings through dialogs (except the Keys dialog), all this is done automatically.
Example:
out "This is[]multiline string[]with ''double quotes''"
Assume you want to repeatedly execute two commands:
lef 100 200 key Y
Insert rep before. Then select the commands and press Tab key. This tab-indents the selected lines:
rep lef 100 200 key Y
Repeat 10 times:
rep 10 lef 100 200 key Y
See also: Programming in QM
You can use variables almost everywhere in code. To store numeric integer values, use variables of type int. To store floating-point values - double. To store text - str. Example:
without variables lef 100 200 "Notepad" use variables str s="Notepad" ;;declare str variable s, and store "Notepad" int x y ;;declare int variables x and y x=100 y=x*2 lef x y s
To share a variable between macros, declare it with +:
int+ global_var
You can use variables in dialogs (floating toolbar). To use a variable in a text field, enclose it in parentheses. Parentheses are not used in fields that accept numeric values.
See also: Programming in QM
Creating and understanding macros is easier if you know the following 20 commands. Some of them can be entered using dialogs, or recorded, but often it is quicker to write them directly.
| lef, rig | Click mouse left or right button. To enter these commands, you can record, or use the Mouse dialog. Examples: lef 100 200 ;;left click at 100x200 pixels lef 90 40 "Notepad" ;;left click at 90x40 pixels in Notepad window |
| key | Press keyboard keys. Type text. To type text, enclose the text into quotes. To enter other keys, you can record, or use the Keys dialog. Examples: key "Australia" ;;type text '"Australia" ;;type text (key can be replaced to ' ) key F12 ;;press F12 key LLLL ;;press Left Arrow four times key Cv ;;press Ctrl+V key A{ep} ;;press Alt+E+P |
| outp | Paste text. This command also can be entered through the Text dialog. Examples: outp "New Zealand" ;;paste text "New Zealand" ;;paste text (outp can be omitted) outp s ;;paste variable s |
| out | Display something (numbers, strings, variables, etc) in the QM output. Useful when debugging macros or learning (experimenting with) various commands and functions. This command also can be entered through the Text dialog. Examples: out "I am here" ;;display text out i ;;display variable i |
| mes | Display something in a message box. This command also can be entered through the Message Box dialog. Examples: mes "Important information" if(mes("Continue?" "" "YN")='N') ;;if the user clicks No ret ;;exit |
| run | Run file, open document, web page, etc. This command also can be entered through the Run File dialog or other dialogs from the same menu. Or, you can drag and drop a file from the desktop or Windows Explorer. Examples: run "C:\WINDOWS\system32\notepad.exe" run "http://www.quickmacros.com" |
| act | Activate window. This command also can be entered through the Window dialog. Example: act "Notepad" |
| win | Find window and return window handle that can be used in other commands. This command also can be entered through the Find Window Or Control dialog. Example: int hwnd=win("Internet Explorer" "IEFrame") act hwnd |
| wait | Insert simple delay, or wait for some event (e.g., window). This command also can be entered through the Wait dialog. Examples: wait 5 ;;wait 5 seconds 0.5 ;;wait 0.5 second (wait can be omitted) wait 30 "Internet Explorer" ;;wait max 30 s for Internet Explorer |
| mac | Launch a macro. This command usually is used in menus and toolbars. To enter it quickly, drag and drop the macro from the list. Example: mac "Macro9"
Note: mac is not used to call functions. The launched macro is independent from the current macro, and the current macro does not wait for it. |
| err | Continue macro if an error occurs. Example: wait 2 "Window" ;;wait for Window max 2 s, and then throw error err ;;on error continue |
| ret | Exit (end current macro or function). Example: if(i=0) ret ;;if variable i is 0, exit |
| goto | Go to another line. Example: if(i>=10) goto g1 ;;if variable i is >= 10, go to the g1 label out "This line is executed only if i is < 10" g1 out "This line is executed always" |
| if, else | Execute or skip commands if certain condition is true. The commands must be preceded by a tab, unless they are in the same line. Example: if i<5 ;;if variable i is less than 5, execute the following two commands out "variable i is < 5" i+1 else ;;else execute the following one command out "variable i is >= 5" |
| rep, break | Repeatedly execute commands. The commands must be preceded by a tab, unless they are in the same line. Examples: rep 10 ;;press Right Arrow 10 times key R
Repeat while variable i is <= 5: int i ;;declare variable i rep i+1 if i>5 out "i is > 5" break ;;exit the loop out i |
| int, str | Declare variables. Use int for numeric integer variables. Use str for string variables. Examples: str s="Notepad" ;;declare str variable s, and store "Notepad" int x y ;;declare int variables x and y int+ g_var ;;declare global int variable g_var |