Quick start

What is a macro

How Quick Macros works

Quick Macros window

Creating new macro, menu or toolbar

Adding macro commands

Recording

Adding menu items and toolbar buttons

Launching macros, menus and toolbars

How to know that a macro is running

How to end a running macro

How to assign a toolbar to a window

How to create an "auto-hide" toolbar

Managing toolbars

How to create text-replacement ("autotext") macros

Can macros run in any program?

Can two macros run simultaneously?

Can I automate background windows?

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 dot (.)?

Disabling commands, adding comments

Using strings; inserting newlines and quotes

Repeating

Using variables

Top 20 commands

 

Tutorials

Video tutorials

Reference

Programming in QM (if, goto, functions, etc)

What is a macro

A macro is a list of commands that are executed when the macro runs. The commands can perform the same actions as you can do manually: type text, click menus, run files, etc. To launch a macro, you can assign it a trigger (eg a hotkey), 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.

How Quick Macros works

In the Quick Macros window you can create macros and items of other types (functions, toolbars, etc). You create a macro for each task you want to automate. You can assign it a trigger, eg a hotkey.

 

While Quick Macros is running, it watches for these triggers. On a trigger event (eg a hotkey pressed) it executes the macro to which the trigger is assigned. Quick Macros also manages your toolbars and menus.

Quick Macros window

To show the Quick Macros window, click icon in the system notification area (by the clock) or in the Start menu.To hide - click the X (Close) button.

 

Window parts:

Top - menu and toolbars.

Left - list of QM items (macros, functions, menus, toolbars, etc).

Middle - code editor. Here you edit text (list of commands) of the currently selected QM item.

Bottom - output (errors and other messages), find, tips, status bar.

Creating new macro, menu or 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.

Adding macro commands

Macros are stored as simple text. Usually each command is in a separate line.

 

To add macro commands, you can use dialogs from the code toolbar. However QM does not provide dialogs for all commands. You can find commands and dialogs using the Find help, functions, tools field (above the code editor), or in Reference, or in lists.

 

The simplest way to add keyboard and mouse commands - record.

Recording

You can record keys and mouse. You can record complete macro, or only some parts.

 

To start recording, click the Record button on the toolbar, or press Ctrl+Shift+Alt+R. When recording is finished, click Insert or ... button in 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 instead 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).

Adding menu items and toolbar buttons

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 "$system$\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 code toolbar, or drag the file from the desktop or Windows Explorer. To add other commands, use other dialogs from the code toolbar. To add a separator, type - or |. To add icons, use the Icons dialog.

Launching macros, menus and toolbars

You can use various ways to launch a macro:

 

The Run button on the QM toolbar.

A hotkey, mouse, window, or other trigger. To assign a trigger click the Properties button on the toolbar.

Place the macro in a custom menu or toolbar. Open the menu or toolbar, and drag the macro to the code editor. You can attach toolbars to windows.

Schedule the macro to run at a certain time. Click the Schedule button in the Properties dialog.

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.

Autotext list commands are executed when you type certain text.

 

Menus, toolbars and functions can be launched using the same ways as macros.

How to know that a macro is running

When a macro is running, the QM tray icon is red . When QM items of other types (functions, menus, etc) are running, the tray icon does not change. It also does not change if the macro has option 'Run simultaneously'. You can see running items in the 'Running items' pane in QM window or in the Threads dialog in QM tray menu.

How to end a running macro

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 with Pause. Also if the macro has option 'Run simultaneously'. Then use the 'Running items' pane in QM window or the Threads dialog in QM tray menu. Or, if you use the AddTrayIcon function, you can Ctrl+click the tray icon added by it.

 

Or, you can use special code in the macro or function. Example:

 

rep
	ifk(F12) ret ;;end if F12 is pressed
	 ...

How to assign a toolbar to a window

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. May need to edit or remove window name, eg remove the name of the currently open document.

How to create an "auto-hide" toolbar

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.

Managing toolbars

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. Use the right-click menu to change toolbar style or open to edit.

 

If you have lost a toolbar (it is running but invisible), right click it in the 'Running items' pane in QM window and select 'Move Here' or 'Reset'.

How to create text-replacement ("autotext") macros

Don't need to create separate macros for each text replacement. Create one or several autotext lists that contain multiple replacements. Assign Autotext or Keyboard trigger.

Can macros run in any program?

Macros can run in any Windows program. You can make a macro to run only in a certain program(s).

 

In some programs, triggers and some macro commands may not work. The reason usually is either security-related or the program uses a nonstandard input method. Make sure that: 1. In Options -> General is selected Administrator or uiAccess, not User. 2. In Options -> Triggers is checked low level hook for keyboard and mouse.

Can two macros run simultaneously?

By default, multiple macros cannot run simultaneously. If a macro (macro2) is launched while a macro is already running, macro2 will not run. Several instances of the same macro also will not run simultaneously.

 

A macro can run simultaneously with other macros if you select 'Run simultaneously' in Properties -> Macro properties. Read more.

 

Multiple functions always can run simultaneously, as well as several instances of the same function.

Can I automate backround windows?

Macros cannot send keys and mouse clicks to a background window without activating it. However, it is often possible (but not so easy, and will not always succeed) to replace keyboard and mouse commands with other commands that usually can work in the background. To insert such commands, use dialogs from the code toolbar's "Window, controls" menu.

Can I run a macro without running QM?

Yes. You can create executable programs from macros and functions.

Can macro run when an error occurs?

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 (eg 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

What is the System folder and other default items in the list?

Many QM features are written in QM language. It includes code toolbar dialogs, Dialog Editor and many functions that you can use in macros. All this is in the System folder.

 

The Samples folder is only for learning. You can delete it.

What is the list that pops up when I type dot (.)?

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 categories - collections of related functions. When you double click a category in the list, pops up another list containing functions from that category.

Disabling commands, adding comments

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

Using strings; inserting newlines and quotes

Strings (text) must be enclosed in double quotes. In strings, use '' (two ') for ". Use [] for new line. Example:

 

out "This is[]a multiline  string[]with ''double quotes''."

 

The same without replacing quotes etc:

 

str s=
 This is
 a multiline string
 with "double quotes".
out s

 

In dialogs (in the code toolbar), type exact text, without quotes. To use a variable in a dialog field where text is required, enclose it in parentheses (except when there is a checkbox or other control to specify that it is a variable).

 

See also: variables in strings

Repeating

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

Using variables

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 of the code 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

Top 20 commands

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 with ' )
key F12 ;;press F12
key LLLL ;;press Left Arrow 4 times
key Cv ;;press Ctrl+V
key A{ep} ;;press Alt+E+P
paste

Paste text. This command also can be entered through the Text dialog. Examples:

paste "New Zealand" ;;paste text
"New Zealand" ;;the same (the paste keyword can be omitted)
paste s ;;paste variable s
out

Display something (numbers, strings, variables, etc) in QM output. Useful when debugging macros or learning/testing various 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, wait for

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