Resources (macro resources)

In macros you sometimes use images or other binary (non-text) data. There are several ways to store such data:

 

Each macro (or other QM item) can have any number of resources. They are stored in the same QM file. They are deleted when you delete the macro; copied when you clone or export the macro. You can think about macro resources like about email message attachments.

 

Resources have names. Case-sensitive. Some names are recognized by QM as images:

 

In macros use resource name with "resource:" prefix. Example: "resource:email.ico".

 

Functions that support resources:

 

In the code editor QM displays images below lines with image resource name and file path strings. Even if the strings are in comments, if enclosed in ". To show/hide images, use toolbar button 'Images in code editor'. You also can display images in output and function help.

 

In Options you can set to record screenshots when recording mouse clicks or using the Mouse dialog. QM saves the recorded images in macro resources with names that begin with "~:", and inserts the names in macro text as comments. Auto-deletes unused screenshot resources, for example when you delete macro text containing "~:..." and then close the macro.

 

When creating exe, QM looks for strings that begin with "resource:" or "image:" and adds the macro resources to exe resources (it's a different thing, although similar). Then in exe QM functions get data from these exe resources. Supports multiline strings. Use #exe addfile if QM does not auto-add a resource, eg if if its full name string is not used in macro.

 

Exe resource type and name (or id) of auto-added macro resources depends on macro resource name. If it contains colon, eg "A:B", in exe A will be resource type, and B name. Else exe resource name will be the same as macro resource name, and type depends on macro resource name: if it ends with ".bmp", ".ico", ".cur" or ".ani", type will be RT_BITMAP, RT_GROUP_ICON, RT_GROUP_CURSOR or RT_ANICURSOR, else RT_RCDATA. If type or name string begins with an integer number 1-65535, in exe resources it will be numeric (id), else string. For example, if macro resource name is "10 info.ico", in exe it will be RT_GROUP_ICON resource with id 10. Note that if exe has icon resources with string names, Windows Explorer displays wrong icon; to avoid it, all icon resources added to exe should have numeric names.

 

Sub-functions cannot have resources, but can use resources of parent QM item.

 

To manage macro resources, you can use:

 

The 'Resources' dialog

You can find the dialog in the Tools menu or toolbar.

 

At the left are listed all QM items (macros etc) that have resources. At the right are displayed resources of the selected item.

 

Special items at the left:

 

At the right side you can manage resources of the selected item: