Conditional Statements (IF/ENDIF)

Conditional Statements

Macro Recorder allows adding conditional statements to a macro. A conditional statement (or "an IF statement") is a statement that can be expressed in "if...then..." form. The IF statement controls the execution of a block of commands (or a single command) depending on whether the condition is TRUE.

How IF statements are processed

If the condition is TRUE, Macro Player executes the subsequent commands that follow the IF statement.
If the condition is FALSE, flow control skips to the ENDIF statement.

Example

A conditional statement example of use (in human language):

  • [IF] the File Exists
  • Delete the file
  • [ENDIF]

    Conditional Statement Types

    Macro Recorder offers various IF statements:

  • "IF Message" which displays a message with YES and NO buttons (evaluates to TRUE if user presses YES)
  • "IF File Exists" which searches for a file (evaluates to TRUE if user presses YES)
  • "IF Window Exists" which searches for a Window with a specified caption (evaluates to TRUE if the caption is found)
  • "IF Pixel Color Equals" check the pixel color at the given coordinates (evaluates to TRUE if the color matches)
  • "IF Image found" searches the screen for an image
  • "IF window in focus" check if specified window is currently in focus
  • "IF process exists" checks if a process with specified name is currently running
  • "IF Clipboard equals" compares the clipboard to specified string
  • etc

    "Waiting For" something using IF-statements

    Macro Recorder can be used to "wait for" something using the built-in IF statements. With this feature, for instance, you can make Macro Recorder "watch" the hard disk, and perform some actions, when a particular file appears in a folder. Another example: with the following script Macro Recorder will wait until some particular text appears in the clipboard, and then exit:

    LABEL : start
    IF CLIPBOARD EQUALS : test
    GOTO : end
    ENDIF
    DELAY : 5000
    GOTO : start
    LABEL : end
    As you can see, this macro checks the clipboard every 5 seconds, and if the text in the clipboard is "test", the macro exits.

    IMPORTANT: after inserting an IF-statement remember to insert a corresponding ENDIF

    .

    © JitBit Software Macro Recorder homepage