Example:
Opening a web page in the user's default browser

Actions used:

Control Structure - ELSE

Control Structure - END IF

Control Structure - IF

File - Open

Internet - Check Connection

In this example, we'll show you how to open a web page in the user's default browser. To make things interesting, we'll test whether the user can connect to the site, and if they can't (maybe they don't have an Internet connection), we'll open a local copy of the website instead.

Here's what the action list looks like:

First, we use an "Internet - Check Connection" action to see if the user can connect to our website. The "Internet - Check Connection" action lets you specify the URL that it will use to determine whether an Internet connection exists...this is just a website that the action will attempt to connect to. ("If we can reach this web site, we must be online.") This makes it pretty handy for testing whether the user can reach a specific site, too.

The "Internet - Check Connection" action will store "TRUE" in the %IsConnected% variable if it was able to connect to the site, so we'll use a "Control Structure - IF" action to test the value of %IsConnected% and then act accordingly.

The IF action's conditional expression is simple enough: just test the value inside %IsConnected% to see whether it's true or false. If it's true, do the stuff in the "true" part of the IF block (between the IF action and the ELSE action). If it's false, do the stuff in the "false" part of the IF block (between the ELSE action and the END IF action) instead.

First let's take care of the "true" part of the IF block. Since the user has a valid connection to the Internet (in fact, to the very site we want to open!), let's get down to business and actually open the web page. All that takes is a single, solitary "File - Open" action.

The "File - Open" action will automatically use the user's default browser to open the web site. (This is the same thing that happens if you choose Start -> Run from the Start menu in Windows and type the URL in there.)

Next, we use a "Control Structure - ELSE" action to split the IF block into two parts: the part above the ELSE, that will be used if the IF statement is true; and the part below the ELSE, that will be used if the IF statement is false.

We've already handled the "true" part, so now we'll handle the "false" part: loading a local copy of our website that we distributed with our AutoPlay application. Again we use a "File - Open" action, but this time we give it the path to the HTML file that we distributed with our application. In this case, the file is called index.html and is located in a subfolder called website inside the same folder that our application is running from.

The "File - Open" action takes advantage of the fact that the user's default web browser will be associated with .htm and .html files on the user's system. It basically tells Windows to "do an 'open' on this file," at which point Windows looks in the Registry to see what program is responsible for handling an "open" on that kind of file, starts that program, and says "okay, here's the file, go for 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:

(Note: save this file to your hard drive and use a tool like WinZip to extract the XML file)