Macro construction


This section introduces you to the macro construction process.

Creating the macro

You now have two options to create the macro, the quick or in-depth option.  

The quick option allows you to import, review and run the complete macro or, alternatively, the in-depth option shows you how to construct the macro step by step and introduces you to the subtleties of the individual actions involved.

Quick option - import

Flexi-deck allows you to save FD components for reuse in other FD projects. To this end you can export Macros, Menus and even individual Menu Buttons.  These can be imported as required and offer a way to exchange complete FD functions that can be shared with other interested parties, especially those using the same application.

The complete macro can be downloaded from here. Save on your system and import as follows (in the example below it has been saved in the Documents folder):


      

The macro will now appear in your Macro Editor (as per Step 1 of the in-depth tutorial below).  Highlight the macro within the folder structure and review the actions that form the Macro.

The beauty of the macro structure is that it can be read like a recipe with the function of the individual actions hopefully being self-explanatory.

Review the individual steps below for a more in depth description of the individual actions or run the macro as described here.

A successful replay of a macro relies on the sequence of events being exactly the same on each system and within similar timings.  For example, any actions that are waiting for a UI element to exist will have a maximum wait time defined.  If, for what ever reason, the UI element is not seen within this time (it is too dangerous to have an option 'wait indefinitely'!), an error dialog will be shown and will offer you the option to highlight the failing action.  This will allow you to review why the issue occurred and adjust the macro accordingly, such as in this instance increasing the wait time (assuming the UI element does eventually appear!).

Similarly, if your system displayed extra or different on-screen dialogs to that expected by the macro, you would need to adjust or add an action to deal with those differences.

In-depth option - Step by step construction

​At any time during the construction process, once the action has been defined you can select the Run Action option to run the action or, if you need to retain focus on the target application, you can use the Run Selected Action system wide keystroke shortcut as defined in the Preferences dialog (default Cmd+Ctrl+A)

Step 1 - Create a Macro, QTSR, within your project folder using the add macro button and describe its function.

Select the QTSR Macro in the folder structure so that it is listed in the Actions section as the Macro being configured.

You are now going to add the actions required to complete the task at hand.  For each action required you will select the add action button and select the required Action from the action list:


Step 2 - Start by loading the QuickTime application using the Activate Application action.

Note we need to specify 'Pause until the application has activated' before the next steps are performed.

You can now select the 'Run Action' to invoke the QuickTime application so you can perform the next step. The QuickTime file menu will be shown.

Step 3 - Now select the menu item to initiate the screen recording using the Pick Menu Item action.

Add the Pick Menu Item action to the Macro and select the Menu item field:

 

At this point the editor will enter menu item highlight mode.

Select the QuickTime File menu and move the system pointer over the New Screen Recording menu item and hit Return to select (or whatever UI select key is defined in the Preferences dialog).

Because the New Screen Recording option has an associated keystroke option () we could utilise the Perform Keystroke action to enter Control+Command+N at this point rather than the Pick Menu Item action.  Its often the case that there are alternative ways to satisfy any given step.

The name of the item will now be reflected in the Action settings.

You now need to manually select the same menu item, New Screen Recording, so you can perform the next step.  This will load the QuickTime record dialog:

Step 4 - Wait for the screen recording dialog to exist

We need to ensure the dialog exists before selecting the record button.

Select the Wait for UI Element action and select the UI Element field. The editor will now enter the UI element selection mode. Select the Screen Recording red button in the center of the record dialog.

To cater for slower systems we are setting the wait time for 5 seconds.

Step 5 - Select the record button to start the recording.

Given that we don't actually know where the record dialog is located we are not going to select the record button via a mouse positional click but by another method that does not rely on positioning by sending a press command to the UI element associated with the record button.  Flexi-deck offers a number of UI element based actions that could be used at this point but for the purpose of this demo we are using the Send Command to UI Element to direct a 'Press' request to the record button.

Select the 'UI element:' field. At this point the editor will enter UI highlight mode.  Move the system pointer over the UI item you wish to select (in this case the red record button ) and hit Return to select.  The UI details will be reflected in the action option:


At this point, if the macro was executed, it would start the recording process and QuickTime would issue the follow option.

To satisfy this request we now need to generate a click. However, we have found that if the 2nd click is issued too quickly, before this text is shown, then the click is ignored and therefore the recording session would not start.  To avoid this occurring we can add a Wait for UI element to exist and wait for the UI element used to display the text.

Step 6 - Wait for QuickTime to be ready to accept the next click

Select the Wait for UI Element action and select the UI element field. The editor will now enter the UI element selection mode.

Select the QuickTime screen record button such that the text is shown on the screen.  Position the system pointer over the text to highlight the UI element and select Return.

The UI element is now reflected in the Wait for UI element action. To cater for slow systems we have increased the wait time to 5 seconds.

Step 7 - Initiate the full screen recording by clicking on the screen.

Select the Click Action with sub function 'Screen Position' to satisfy this requirement. Given that QuickTime only requires a click anywhere on the screen to initiate the full screen recording then the default position of 0,0 will suffice and does not to to be 'Set' elsewhere.

At this point you have a macro that will start a QuickTime full screen recording such that you can now manually select the 'recording' button in the menu bar to stop the recording. We are now going to extend the macro to stop the recording when required, save the recording to a named file and close the 'movie' screen.

Prior to initiating the next steps we are going to wait for the recording icon to appear in the menu bar item  as an indication that recording process has started.

Step 8 - Add a Wait for UI Element to ensure the stop recording button is on display in the Menu Bar.

With the stop recording button shown in the menu we can perform the next step.

Step 9 - Utilise a Show message box action to request that the OK button be selected when the recording is complete.

When the macro is executed the processing will be suspended until the OK button is manually selected.

Step 10 - Select the 'recording' icon in the menu bar to stop the recording

You now need to use a Send Command to UI Element action to stop the recording.

Prior to selecting the UI Element you need to start a screen recording so that the record button is seen in the menu bar and the screen activity is being recorded.  You can now select the UI Element field, place the system pointer over the record button and hit Return.  The record button is now reflected in the UI Element field along with the command to be performed on the UI element:

However, we cannot stop the recording before the stop recording button in the menu bar is active and ready to be pressed (when the button is initially shown in the menu bar the center dot is grey and turns back once active and able to be selected - which in some cases can take up to 5 seconds) hence we utilise the UI advanced editor to ensure the button is 'enabled' before the press action is performed:

Select the down arrow control to invoke the advance UI Element Editor and set Enabled as shown below:

If you now run the action or manually click the record button the recorded screen activity is now presented in a movie window ready to be saved.

Step 11 - Delete any previous saved movie if it exists

Prior to saving the file we need to delete any previous saved file of the same name. We are going to save in the Home folder so we are going to use the Execute Shell Command action to run a command to delete the file, being 'rm ~/FDQTSR.mov'.



Step 12 - Save file and close the movie window and quit QuickTime.  

If you have followed these instructions thus far then hopefully you have a good understanding of how the actions are used to perform the required task. The remaining actions are used to save and close the movie file and quit QuickTime.

  • 11 Use Wait for UI Element action to wait for movie dialog to be on screen (following the request to stop recording)
  • 12 Use the Pick Menu Item to select the Save file option.  

You now need to manually invoke the Save procedure so you can perform the next steps.

  • 13 Use Wait for UI Element to wait for the save dialog to be loaded (select the Save button as the UI Element)
  • 14 Use a Keystroke action to select the Home folder (Command + Shift + h) 
  • 15 Once the save dialog is loaded we are using a keystroke action to type in the file name FDQTSR, followed by the return key to invoke the save
  • 16 Use a Wait for UI element 'not to exist' to wait for the file save to complete (select the Save button as the UI Element - it is expecting the file to save within 5 seconds - increase if required)
  • 17 Use Close Window action to close the 'FDQTSR' window.
  • 18 Quit Application action to close QuickTime

Running the macro

With this macro now complete, you can select the Run Macro button to test the Macro and ensure it performs as expected.

This should run on the majority of systems without error but there are no guarantees. You may need to make minor adjustments to UI element wait thresholds. If a macro fails in a detectable manner the macro playback mechanism shows an error dialog with an option to highlight the failing action to help you investigate the problem.


It should rerun the entire procedure each time you select Run Macro.

Search