Using Controls

 

This example provides a simple demonstration of using the window controls with the Windows calculator. Start the calculator program, leave it running and return to Macro Express. (Depending on your version of Windows, click on the Windows Start button, enter calculator in the Search field and press enter. Or right click on the Windows Start button, select Run, enter calculator and click OK to start the program.)

 

Note: This macro will not work in Windows 10, since the calculator program in Windows 10 does not use window controls. 

 

Select a Macro Activation

For this example we will create a hot key activated macro.

 

1.From the Macro Express Pro - Explorer click on the New Macro icon to open the Create New Macro window.

2.HotKey should be the default Initial Activation and the blinking cursor should be in the HotKey edit box. If the cursor is not in the edit box, click on the edit box with the mouse to place it there.

3.Press the F3 key and then release it. F3 should appear in the edit box.

4.Enter "Clear Calculator" (without the quotes) in the Macro Nickname edit field.

5.Click OK to save the changes and open the Script Editor.

 

 

Set the Macro Scope

1.With the Script Editor open, click on the Scope tab.

2.Set the Current Scope to Global.

 

 

Naming the Variable

1.Click on the Variables tab.

2.Click on the Add button to open the Variable Properties window.

3.Type calc into the Variable Name field to assign the variable name as "calc".

4.Select Control Variables as the Variable Type.

5.When finished the screen should look like the example below.

6.Click OK to save.

 

 

Writing the Macro

Setting the Control Variable

1.Click on the Script tab.

2.Expand the Window Controls category of commands.

3.Double click on the Get Control command to open the Get Control window.

4.Place a check in the box next to Hide Macro Express.

5.Click on the Store the Control In field to display a Variables button.

6.Click on the Variables button and expand the Control Variables list.

7.Highlight the "calc" variable and click OK to save.

8.Click on the Launch Utility button to open the Capture Window Control window.

9.If the Calculator program is not visible on the screen open the Calc window.

10.Click on the blue X crosshairs on the Capture Window Control window and drag it over top of the "C" button on the calculator.

11.Release the mouse button to insert the control information into the Control Details panel.

12.Click the save button to save the information and return to the Get Control Window.

 

 

 

This window now displays the information stored to the "calc" variable as shown above.

Click OK to save this command and return to the Script Editor.

 

Clicking on the Control

1.Expand the Mouse category of commands.

2.Double click on the Mouse Click on Control command to open the Mouse Click on Control window.

3.In this window, the Command listed will be Mouse Click on Control.

4.Select Single Click which should be the default option.

5.Place the cursor in the Control edit box to display the Variables button.

6.Click on the Variables button and expand the Control Variables list.

7.Highlight the "calc" variable and click OK to save.

8.Make sure the button selected is the Left Button.

9.Click on the Advanced tab and ensure that Center is selected as the Click location.

10.Click OK to save.

 

 

Macro Script

The script instructs the macro to perform a single left mouse click on the "calc" variable, which is defined as the "C" button on the Calculator. The script should look like the following:

 

Get Control

Mouse Click on Control %calc%

 

Click on Save and Close to save the macro. Open the Macro Explorer to see the F3 macro with a nickname of Clear Calculator listed as an available macro.

 

 

Playing back the Macro

To test the macro, open the calculator program.  Enter some numbers into the calculator. With numbers displayed in the Calculator edit box, press the F3 button. This simulates clicking on the C button of the calculator and clears the display.