DAC Conditional Scripting

You can implement conditional scripting within the DAC application using a combination of the “onCondition” and “label” commands. In the following video example, I check for the existence of an image using the “storeAssertImageAt” command and then proceed based on whether that image exists (that is, whether the “no updates available” box shows up).

 

There are four main commands at play here:

  1. “storeAssertImageAt”

In the above example, the image I am looking for is the box below the main Desktop Recorder GUI, “There are currently no updates available”. If the image is NOT available, I know updates ARE available and I want to update the application.

(Note: the “storeEval” command below “storeAssertImageAt” changes the message to output

  1.  

onCondition

Note the specific “JavaScript” expression here - it utilizes the “return” keyword to return either true or false. If true, the script jumps to the label specified on “Label on True”. If false, the script jumps to the label specified on “Label on False”. Note that it is currently not possible to jump backwards in the script at this time - both labels need to be present after the “onCondition” command.

  1.  

label (on False)

Updates are available - proceed the script from this point.

  1.  

label (on True)

Updates are not available - proceed the script from this point, skipping all of the update steps as they are not necessary and could cause script failure.

Example using storePixelColor

{ "command": "storePixelColor", "args": { "key": "lowerLeftCorner", "x": 60, "y": 930 }, "ignore_timing": true }, { "command": "onCondition", "args": { "expression": "if (${lowerLeftCorner_red} > 240) {return true;} else {return false;}", "labelOnTrue": "maxTrue", "labelOnFalse": "maxFalse" }, "ignore_timing": true },
  1. Store the pixel color at location X:Y

  2. Test if ${<key>_red} (the red component of the pixel color stored in storePixelColor) is greater than 240 and jump to appropriate label

Can't find what you're looking for? Send an E-mail to support@apica.io