Command Reference - Action Examples
|
Actions used: |
In this example, we'll run a PowerPoint presentation after checking to see if the user has a PowerPoint viewer installed. If they don't, we'll give them the option to install a viewer.
Here's what the action list looks like:
.png)
First, we use a "Control Structure - LABEL" action to create a label for our GOTO action to jump to later so it can try to get the path to the user's PowerPoint viewer again after the installation if we need to install a viewer.

Next, we use a "File - Get Default Viewer" action to get the user's default viewer for PowerPoint files, if they have one. If they do, the full path to it will be stored in a variable called %PowerPointViewer%.

This action will generate an error if it fails. Since we'll be handling that ourselves, we don't need the user to be told about the error, so we'll change the User Notification settings on the On Error tab for this action from "Verbose" to "None".

Next, we use a "Control Structure - IF" action to test whether the "File - Get Default Viewer" action failed. If the action was successful, %LastErrorNum% will be 0, so we use a != operator to create an expression that will be true if %LastErrorNum% is not 0.

If the "File - Get Default Viewer" failed, then the user probably doesn't have a PowerPoint viewer installed...in which case, we want to ask them if they want to install a viewer. So, we use a "Dialog - Message Box" action to ask them a simple YES/NO question.

The text on the button that the user presses will be stored in the variable %Result%. Since we're only giving the user two options (yes and no), we only need to test for one of them...in this case, we'll use a "Control Structure - IF" action to see if the user pressed the "NO" button.

If they pressed the No button, then our conditional expression (%Result% = "NO") will be true, and the actions in this IF block will be performed. In that case, we'll use a "Control Structure - RETURN" action to exit from this action list, aborting the whole PowerPoint viewing attempt.
Then we use a "Control Structure - END IF" to end this inner IF block.
Next, we use a "File - Execute" action to run the PowerPoint viewer's installer, which we distributed in the same folder as our application.

Then we use a "Control Structure - GOTO" action to jump back to the LABEL that we placed at the start of this action script, to get the full path to the newly installed PowerPoint viewer (and try installing again if the installation failed...).

Then we use a "Control Structure - END IF" action to end our outer IF block.
Finally, we use a "File - Execute" action to run the PowerPoint viewer (either the user's own, or the one on the CD) and pass it the path to our presentation as a command line argument. In order to make our AutoPlay application wait for the user to close the viewer before continuing, we've enabled the Wait for program to finish before continuing option.

Note that we've surrounded the command line arguments in quotation marks because our filename has spaces in it.
Here's a link to the finished example, as an AutoPlay Media Studio 4.0 actions XML file that you can import into an action list:
Running_a_PowerPoint_presentation_(advanced).zip
(Note: save this file to your hard drive and use a tool like WinZip to extract the XML file)