The Hotkeys Macro Interpreter

 

 

 

After a hotkey and its associated macro code has been created with the Hotkeys Event Recorder or Macro Editor the Macro Interpreter checks the code for syntax and logic errors and must be error free before it can run. Any errors are highlighted and reported in the Hotkeys Editor and once the macro code is error free the Macro Interpreter can execute the code.

Click here for a complete description of the macro code syntax.

A macro program has 4 attributes: a description of the macro, the activating hotkey, an enable flag, and the code. The code is represented by lines of text that the Macro Interpreter  interprets as instructions for the Windows OS to perform. The interpreter starts processing lines of code sequentially from the top (line 1) to the bottom (last line) of the macro.

There are 2 methods for running a macro: by pressing the associated hotkey, or by clicking the Run button on the Hotkeys Editor or the List Hotkeys form. It's important to note that for a macro to function correctly the same conditions must exist in the Windows environment as when the macro was created. The macro must also begin from the same starting point (the topmost Windows application). It's almost guaranteed that the macro will fail otherwise and possibly with undesired consequences. For this reason the Hotkeys program offers to delay the start of the macro by a time specified by the user to ensure that the focus is placed in the appropriate window.

ReadClip changes its taskbar icon to to indicate when a macro is running. Click on this icon or press the Escape key to stop a running macro.

The following code sample demonstrates a macro designed to compare 2 selected sections of text from any 2 documents. The macro samples the Windows clipboard contents until it detects 2 sections of text, then compares them. The results of the comparison are then loaded into Notepad.

 

 

 

 

  #Compare 2 sections of text for differences
[SETCLIP ""]
[TOG=0]
[LOOP X=1-1000]
    [GETCLIP S]
    [IF S<>""]
        [CANCEL IF S="quit"]
        [IF TOG=0]
            [TOG=1]
            [FILEA="C:\TMP\FILEA.TXT"]
            [SAVECLIP FILEA]
        [ELSE]
            [FILEB="C:\TMP\FILEB.TXT"]
            [SAVECLIP FILEB]
            [QUITLOOP]
        [ENDIF]
        [SETCLIP ""]
    [ENDIF]
    [WAIT .5]
[ENDLOOP]
[CMD="COMSPEC FC "&FILEA&" "&FILEB&" >c:\compare.txt"]
[COMMAND CMD]
[WAIT 1]
[KILLFILE FILEA]
[KILLFILE FILEB]
[COMMAND "notepad.exe c:\compare.txt"]

See additional code samples here.