Multiple Choice Menu
The Multiple Choice Menu command displays a menu of options during macro playback. Choices can be displayed as either radio boxes (one selection out of the group) or as check boxes (select as many as wanted). The selection results are stored in a text string variable which can be tested for conditional processing of the macro.
üNote: To create Yes/No, True/False, or OK/Cancel type menu options, use the If Message command.
Script Editor > Expand Dialogs Category > Multiple Choice Menu
Menu Options
Choose whether to allow the user to choose only one valid selection or multiple selections.
Single Choice
With this option selected the user may only select one choice from the displayed list.
Sample Macro
This sample macro is based on the screen shot of the Create a Multiple Choice Menu window displayed in this topic. Essentially the macro will display a menu of four choices.
Select the desired option and click OK. The macro then continues based on the choice made. For example if A is selected, then the default web browser would load the Macro Express home page.
Macro Script Multiple Choice Menu: Prompt If Variable %T[1]% Equals A Web Site, "https://www.macros.com", using Default Web Browser End If If Variable %T[1]% Equals B Launch Program and Activate Window: Program "NOTEPAD", Window "notepad" End If If Variable %T[1]% Equals C Text Type (Simulate Keystrokes): Insight Software Solutions, Inc. End If If Variable %T[1]% Equals D FTP Site Connect to www/wintools.com End If |
Multiple Choice
The Multiple Choice option allows the user to select more than one choice from the displayed list. The correct logic must be inserted into the macro so that it can correctly handle more than one selection. A sample of how this would be done is shown below.
Sample Macro
Multiple Choice Menu: Prompt If Variable %T[1]% Contains A And If Variable %T[1]% Contains B Insert commands to perform End If If Variable %T[1]% Contains A And If Variable %T[1]% Contains C Insert commands to perform End If If Variable %T[1]% Contains A And If Variable %T[1]% Contains D Insert commands to perform End If If Variable %T[1]% Contains B And If Variable %T[1]% Contains C Insert commands to perform End If If Variable %T[1]% Contains B And If Variable %T[1]% Contains D Insert commands to perform End If If Variable %T[1]% Contains C And If Variable %T[1]% Contains D Insert commands to perform End If |
Result Options
Save Item Text
Selecting this item requires entering the menu list name used when writing the macro. Based on the example above, use If Variable T[1] = Go to Macro Express web site, If Variable T[2] = Run Notepad, etc. to create the rest of the Multiple Choice macro.
Save Item Value
Selecting this item requires entering the letter associated with the option. Based on the example above, use If Variable T[1] = A, If Variable T[2] = B, etc. to create the rest of the Multiple Choice macro.
üNote: Number of Menu Items Allowed
The number of menu choices permitted varies depending on which combination of Single/Multiple Choice and Item Value/Text is selected. Below are the various combinations and the possible number of menu items allowed.
Single Choice / Item Value |
No limit to the number of items in menu. |
Single Choice / Item Text |
No limit to the number of items in menu. |
Multiple Choice / Item Value |
Menu limited to 36 items. |
Multiple Choice / Item Text |
No limit to the number of items in menu. |
Destination Variable
This is the variable that receives the result of the user choices from the menu. The "If Variable" command is used to test the value of this variable to determine what choice has been selected by the user. The variable T[1] was selected in the window displayed above.
To ensure the menu functions correctly use the command "If Variable T[1] Equals A" to see if the user chose the first item in the Menu List. (Use "If Variable T[1] Equals B" to test for the second item in the Menu List, and so on.)
Position and Size the Multiple Choice Window
Choose from the options below to size, position and format the window.
Left/Top
Position the upper left hand corner of the Multiple Choice window "x" number of pixels from the top and left edges of the screen. Enter the pixel values to position the window.
Width/Height
Enter the pixel values to manually set the size of the Multiple Choice window. For example, entering a width of 500 and a height of 600 would generate a window size of 500 x 600 pixels. Insert the word Auto in the fields to have the window auto-sized, based on the contents of the menu.
Columns
Choose the number of columns to display in the Multiple Choice window. The default setting is Auto, which adds a second column when more than 10 items are listed in the menu.
Monitor
This option applies to systems that utilize more than one monitor. If a system has a single monitor, then leave the monitor setting to zero (0). Zero represents the single monitor or the left monitor if there is more than one monitor. One (1) represents a second monitor or the monitor to the right of the left monitor. Similarly, two (2) represents the third monitor or two monitors to the right of the left monitor, and so on.
Set Size and Position
Use this option to manually position the Multiple Choice window to the desired location. Also manually set the size of the Multiple Choice window. The Window Position and Size topic explains these options in detail.
Keep the Menu on Top
This option keeps the Multiple Choice menu visible on the screen (on top of other running applications) until the menu is closed.
Title
The Title contains the text that appears in the caption bar of the Window displaying the menu.
Prompt
The Prompt contains the text that appears right above the menu choices. This text should help the user understand why they are being prompted to make a choice. For example, if the menu contains a list of income ranges, the prompt could simply consist of something like "Please choose your income bracket".
Menu List
The Menu List contains the list of choices for the menu. Each corresponding letter (A, B, C...) represents a different choice in the menu. They are displayed in the order shown on this screen. If only 3 choices are entered (i.e. an entry for A, B and C), then the menu only shows the 3 entries.
Do not leave gaps in the entries or the menu will end up with blank items. In other words, use the first 3, 5 or however many entries needed. For example, don't just create entries for items A, D, E and G or the menu will display blank items for items B, C and F.
üNote: Text Variables may be placed in the Title, Description/Prompt and Menu List input fields. For example, place the variable T[1] (you would actually enter %T[1]%) in the "Description/Prompt" edit box.
-- Review the Multiple Choice Menu with Defaults sample macro in the samples.mex file, which is supplied with the program, for a working example of the Multiple Choice Menu. --
Make one of the Multiple Choice selections the Default Let's say you want option B to be your default selection. Use the Variable Set String command and select the Set Value Now option. Set the value of variable T[1] to B. Insert this command before your Menu command in the macro script. When the macro runs, option B will display as the default selection.
Allow users to select a menu item with the keyboard instead of clicking with the mouse Let's look at the Multiple Choice Menu image above. There are four entries in the Menu List. We want to set this up so that when the menu is displayed, the user can press a keystroke rather than click on their choice with the mouse. To do so we would modify the Menu List to look like the following:
A &Go to Macro Express web site B &Run Notepad C &Insert email tagline D &Connect to FTP site
You'll notice that an ampersand "&" has been placed in front of each item in the menu list. When the list is displayed during playback of the macro, the letter following the ampersand "&" will be underlined (set as the accelerator key). The user can then press the underlined letter for the choice they want. This will highlight their choice. Pressing the Enter key will perform the macro selection chosen.
The ampersand may be placed anywhere in the text string. It doesn't need to be placed before the first letter as in the example above. For example, we could set item A to read as follows: Go to &Macro Express web site. In this case the M is underlined and pressing the "M" key during playback will highlight this menu option.
Note 1: Be careful not to duplicate the underlined letters. Otherwise the first duplicate letter will be the default choice each time the letter is pressed.
Note 2: If you are using the If Variable Contains command with the Multiple Choice Menu and you have “Save Item Text” checked, be sure to change the text you are comparing so that it includes the ampersand "&". For example, change “If Variable %T[1]% contains "Choice One" to “If Variable %T[1]% contains "&Choice One".
Note 3: To insert an ampersand in the text that is not used as an accelerator, such as a menu item of "This & That", insert two ampersand symbols. Write the menu item as "This && That", so that it displays correctly when the macro runs. |