GUI Control Types


Table of Contents

Text

Unmodifiable text with no border; often used to label other controls.

Example: Gui, Add, Text,, Please enter your name:

In this case, the last parameter is the string to display. It may contain linefeeds (`n) to start new lines. In addition, a single long line can be broken up into several shorter ones by means of a continuation section.

If a width (W) is specified in Options but no rows (R) or height (H), the text will be word-wrapped as needed, and the control's height will be set automatically.

Since the control's contents are in the last parameter of the Gui command, literal commas do not need to be escaped. This is also true for the last parameter of all other commands.

A g-label such as gMySubroutine may be listed in the control's options. This would cause the MySubroutine label to be launched automatically whenever the user clicks the text. This can be used to simulate an underlined, blue hyperlink as shown in the following working script:

Gui, Font, underline
Gui, Add, Text, cBlue gLaunchGoogle, Click here to launch Google.
Gui, Font, norm
Gui, Show
return

LaunchGoogle:
Run www.google.com
return

A double-click can be detected by checking whether A_GuiControlEvent contains the word DoubleClick.

Edit

An area where free-form text can be typed.

Example: Gui, Add, Edit, r9 vMyEdit, Text to appear inside the edit control (omit this parameter to start off empty).

The control will be multi-line if it has more than one row of text. For example, specifying r3 in Options will create a 3-line edit control with the following default properties: a vertical scroll bar, word-wrapping enabled, and the Enter key captured as part of the input rather than triggering the window's default button.

To start a new line in a multi-line edit control, the last parameter (contents) may contain either a solitary linefeed (`n) or a carriage return and linefeed (`r`n). Both methods produce literal `r`n pairs inside the Edit control. However, when the control is saved to its variable via Gui Submit or GuiControlGet, each `r`n in the text is always translated to a plain linefeed (`n). To write the text to a file, follow this example: FileAppend, %MyEdit%, C:\Saved File.txt

If the control has word-wrapping enabled (which is the default for multi-line edit controls), any wrapping that occurs as the user types will not produce linefeed characters (only the Enter keystroke can do that).

Although multi-line edit controls are limited to 64 KB of text on Windows 95/98/Me, they may have as much as 4 GB of text on Windows NT/2k/XP or later. As the user enters text, more memory is allocated as needed.

In v1.0.35+, a g-label such as gMySubroutine may be listed in the control's options. This would cause the MySubroutine label to be launched automatically whenever the user changes the contents of the control.

Edit Options (to remove an option rather than adding it, precede it with a minus sign):

Number: Prevents the user from typing anything other than digits into the field. Note: It is still possible to paste non-digits into it. Also, an alternate way of forcing a numeric entry is to attach an UpDown control to the Edit.

Lowercase: The characters typed by the user are automatically converted to lowercase.

Uppercase: The characters typed by the user are automatically converted to uppercase.

Limit: Restricts the user's input to the visible width of the edit field. Alternatively, to limit input to a specific number of characters, include a number immediately afterward. For example, Limit10 would allow no more than 10 characters to be entered.

Password: Hides the user's input (such as for password entry) by substituting masking characters for what the user types. If a non-default masking character is desired, include it immediately after the word Password. For example, Password* would make the masking character an asterisk rather than the black circle (bullet), which is the default on Windows XP. Note: This option has no effect for multi-line edit controls.

ReadOnly: Prevents the user from changing the control's contents. However, the text can still be scrolled, selected and copied to the clipboard.

Multi: Makes it possible to have more than one line of text. However, it is usually not necessary to specify this because it will be auto-detected based on height (H), rows (R), or contents (Text).

WantReturn: Specify -WantReturn (that is, a minus sign followed by WantReturn) to prevent a multi-line edit control from capturing the Enter keystroke. Pressing Enter will then be the same as pressing the window's default button (if any). In this case, the user may press Control-Enter to start a new line.

WantTab [v1.0.38.03+]: Causes a tab keystroke to produce a tab character rather than navigating to the next control. Without this option, the user may press Control-Tab to produce a tab character inside a multi-line edit control. Note: Although WantTab also works in a single-line edit control, each tab character is displayed (but not stored) as an empty-box character.

Tn: The letter T may be used to set tab stops inside a multi-line edit control (since tab stops determine the column positions to which literal TAB characters will jump, they can be used to format the text into columns). If the letter T is not used, tab stops are set at every 32 units. If the letter T is used only once, tab stops are set at every n units across the entire width of the control. For example, Gui, Add, Edit, vMyEdit r16 t64 would double the default distance between tab stops. To have custom tab stops, specify the letter T multiple times as in the following example: Gui, Add, Edit, vMyEdit r16 t8 t16 t32 t64 t128. One tab stop is set for each of the absolute column positions in the list, up to a maximum of 50 tab stops.

-Wrap (minus wrap): Turns off word-wrapping in a multi-line edit control. This style cannot be changed via GuiControl. Instead, the control and its window must be destroyed and recreated with the new setting. Alternatively, two overlapping edit controls can be created, one with wrapping enabled and the other without it. The one not currently in use can be kept empty and hidden.

UpDown [v1.0.35+]

A pair of arrow buttons that the user can click to increase or decrease a value. By default, an UpDown control automatically snaps onto the previously added control (usually an Edit, but can also be Text, ListBox, and a few other types). This previous control is known as the UpDown's buddy control. The most common example is a "spinner", which is an UpDown attached to an Edit control. For example:

Gui, Add, Edit
Gui, Add, UpDown, Range1-10, 5

In the example above, the Edit control is the UpDown's buddy control. Whenever the user presses one of the arrow buttons, the number in the Edit control is automatically increased or decreased.

Specify the UpDown's starting position as the last parameter (if omitted, it starts off at 0 or the number in the allowable range that is closest to 0).

When the Gui Submit command is used, the control's associated output variable (if any) receives the current numeric position of the UpDown. If the UpDown is attached to an Edit control and you do not wish to validate the user's input, it is best to use the UpDown's value rather than the Edit's. This is because the UpDown will always yield an in-range number, even when the user has typed something non-numeric or out-of-range in the Edit control. On a related note, numbers with more than three digits get a thousands separator (such as comma) by default. These separators are stored in the Edit's output variable but not that of the UpDown.

If the UpDown has a g-label, it will be launched whenever the user clicks one of the arrow buttons or presses an arrow key on the keyboard. Each launch of the g-label also stores the UpDown's position in its associated output variable (if any).

UpDown Options:

Range: Sets the range to be something other than 0 to 100. After the word Range, specify the minimum, a dash, and maximum. For example, Range1-1000 would allow a number between 1 and 1000 to be selected; Range-50-50 would allow a number between -50 and 50; and Range-10--5 would allow a number between -10 and -5. The minimum and maximum may be swapped to cause the arrows to move in the opposite of their normal direction. The broadest allowable range is -2147483648-2147483647. However, Windows 95 and NT4 require Internet Explorer 5.0 or later to support a range broader than -32767-32767. Finally, if the buddy control is a ListBox, the range defaults to 32767-0 for verticals and the inverse for horizontals (Horz).

Wrap: Causes the control to wrap around to the other end of its range when the user attempts to go beyond the minimum or maximum. Without Wrap, the control stops when the minimum or maximum is reached.

Left: Puts the UpDown on the left side of its buddy rather than the right.

Horz: Make's the control's buttons point left/right rather than up/down. By default, Horz also makes the control isolated (no buddy). This can be overridden by specifying Horz 16 in the control's options.

-16 (minus 16): Causes a vertical UpDown to be isolated; that is, it will have no buddy. This also causes the control to obey any specified width, height, and position rather than conforming to the size of its buddy control. In addition, an isolated UpDown tracks its own position internally. That position can be retrieved normally such as by Gui Submit.

Picture (or Pic)

An area containing an image (see last two paragraphs for supported file types). The last parameter is the filename of the image, which is assumed to be in A_WorkingDir if an absolute path isn't specified.

Example: Gui, Add, Picture, w300 h-1, C:\My Pictures\Company Logo.gif

To retain the image's actual width and/or height, omit the W and/or H options. Otherwise, the image is scaled to the specified width and/or height. To shrink or enlarge the image while preserving its aspect ratio, specify -1 for one of the dimensions and a positive number for the other. For example, specifying "w200 h-1" would make the image 200 pixels wide and cause its height to be set automatically. If the picture cannot be loaded or displayed (e.g. file not found), the control is left empty and its width and height are set to zero.

A g-label such as gMySubroutine may be listed in the control's options. This would cause the MySubroutine label to be launched automatically whenever the user clicks the picture. A double-click can be detected by checking whether A_GuiControlEvent contains the word DoubleClick.

To use a picture as a background for other controls, the picture should normally be added prior to those controls. However, if those controls are input-capable and the picture has a g-label, create the picture after the other controls and include 0x4000000 (which is WS_CLIPSIBLINGS) in the picture's Options. This trick also allows a picture to be the background behind a Tab control or ListView.

Icons, cursors, and animated cursors: In addition to loading .ico, .cur, and .ani files, icons may also be loaded from EXE and DLL files that contain them. To use an icon group other than the first one in the file, include in Options the word Icon followed by the number of the group. In the following example, the default icon from the second icon group would be used: Gui, Add, Picture, Icon2, C:\My Application.exe. Note: Specifying an icon group number causes a different icon loading method to be used, which might prevent a .ani file from being animated. It also prevents AltSubmit described in the next paragraph from taking effect.

Specifying the word AltSubmit in Options tells the program to use Microsoft's GDIPlus.dll to load the image, which might result in a different appearance for GIF, BMP, and icon images. For example, it would load an ICO/GIF that has a transparent background as a transparent bitmap, which allows the BackgroundTrans option to take effect. If GDIPlus is not available (see next paragraph), AltSubmit is ignored and the image is loaded using the normal method.

All operating systems support GIF, JPG, BMP, ICO, CUR, and ANI images. On Windows XP or later, additional image formats such as PNG, TIF, Exif, WMF, and EMF are supported. Operating systems older than XP can be given support by copying Microsoft's free GDI+ DLL into the AutoHotkey.exe folder (but in the case of a compiled script, copy the DLL into the script's folder). To download the DLL, search for the following phrase at www.microsoft.com: gdi redistributable

Due to an OS bug, animated cursors scaled to a size greater than 90x90 on Windows 95/98/Me might crash the script.

Button

A pushbutton, which can be pressed to trigger an action. In this case, the last parameter is the name of the button (shown on the button itself), which may include linefeeds (`n) to start new lines.

Example: Gui, Add, Button, Default, &OK

The example above uses the ampersand (&) to cause the O to be underlined, making it a shortcut key. It also includes the word Default in its Options to make OK the default button. The default button's action is automatically triggered whenever the user presses ENTER, except when the keyboard focus is on a different button or a multi-line edit control having the "WantReturn" style. To later change the default button to another button, follow this example, which makes the Cancel button become the default: GuiControl, +default, &Cancel. To later change the window to have no default button, follow this example: GuiControl, -default, &Cancel

If a button lacks an explicit g-label, an automatic label is assumed. For example, if the first GUI window contains an OK button, the ButtonOK label (if it exists) will be launched when the button is pressed. For GUI windows other than the first, the window number is included in front of the button's automatic label, e.g. 2ButtonOK.

If the text on the button contains spaces, ampersands, linefeeds (`n) or carriage returns (`r), its automatic label will omit those characters. For example, a button titled "&Cancel" would have an automatic label of ButtonCancel. Similarly, a button titled "Save && Exit" would have an automatic label of ButtonSaveExit.

Checkbox

A small box that can be checked or unchecked to represent On/Off, Yes/No, etc.

Example: Gui, Add, Checkbox, vShipToBillingAddress, Ship to billing address?

The last parameter is a label displayed next to the box, typically used as a prompt or description of what the checkbox does. It may include linefeeds (`n) to start new lines. If a width (W) is specified in Options but no rows (R) or height (H), the control's text will be word-wrapped as needed, and the control's height will be set automatically. The checkbox's associated output variable (if any) receives the number 1 for checked, 0 for unchecked, and -1 for gray/indeterminate.

Specify the word Check3 in Options to enable a third state that displays a gray checkmark instead of a black one (the gray state indicates that the checkbox is neither checked nor unchecked). Specify the word Checked or CheckedGray in Options to have the checkbox start off with a black or gray checkmark, respectively. In v1.0.26+, the word Checked may optionally be followed immediately by a 0, 1, or -1 to indicate the starting state. In other words, "Checked" and "Checked%VarContainingOne%" are the same.

A g-label such as gMySubroutine may be listed in the control's options. This would cause the MySubroutine label to be launched automatically whenever the user clicks or changes the checkbox.

Radio

Radio button. A small empty circle that can be checked (on) or unchecked (off).

Example: Gui, Add, Radio, vMyRadioGroup, Wait for all items to be in stock before shipping.

These controls usually appear in radio groups, each of which contains two or more radio buttons. When the user clicks a radio button to turn it on, any others in its radio group are turned off automatically (the user may also navigate inside a group with the arrow keys). A radio group is created automatically around all consecutively added radio buttons. To start a new group, specify the word Group in the Options of the first button of the new group -- or simply add a non-radio control in between, since that automatically starts a new group.

For the last parameter, specify the label to display to the right of the radio button. This label is typically used as a prompt or description, and it may include linefeeds (`n) to start new lines. If a width (W) is specified in Options but no rows (R) or height (H), the control's text will be word-wrapped as needed, and the control's height will be set automatically.

Specify the word Checked in Options to have the button start off in the "on" state. In v1.0.26+, the word Checked may optionally be followed immediately by a 0 or 1 to indicate the starting state: 0 for unchecked and 1 for checked. In other words, "Checked" and "Checked%VarContainingOne%" are the same.

The radio button's associated output variable (if any) receives the number 1 for "on" and 0 for "off". However, if only one button in a radio group has a variable, that variable will instead receive the number of the currently selected button: 1 is the first radio button (according to original creation order), 2 is the second, and so on. If there is no button selected, 0 is stored.

A g-label such as gMySubroutine may be listed in the control's options. This would cause the MySubroutine label to be launched automatically whenever the user turns on the button. Unlike the single-variable mode in the previous paragraph, the g-label must be specified for each button in a radio group for which the label should be launched. This allows the flexibility to ignore the clicks of certain buttons. Finally, a double-click can be detected by checking whether A_GuiControlEvent contains the word DoubleClick.

DropDownList (or DDL)

A list of choices that is displayed in response to pressing a small button. In this case, the last parameter is is a pipe-delimited list of choices such as Choice1|Choice2|Choice3.

Example: Gui, Add, DropDownList, vColorChoice, Black|White|Red|Green|Blue

To have one of the items pre-selected when the window first appears, include two pipe characters after it. Alternatively, include in Options the word Choose followed immediately by the number to pre-select. For example, Choose5 would pre-select the fifth item. To change the choice or add/remove entries from the list after the control has been created, use GuiControl.

Specify either the word Uppercase or Lowercase in Options to automatically convert all items in the list to uppercase or lowercase. Specify the word Sort to automatically sort the contents of the list alphabetically (this also affects any items added later via GuiControl). The Sort option also enables incremental searching whenever the list is dropped down; this allows an item to be selected by typing the first few characters of its name.

When the Gui Submit command is used, the control's associated output variable (if any) receives the text of the currently selected item. However, if the control has the AltSubmit property, the output variable will receive the item's position number instead (the first item is 1, the second is 2, etc.).

A g-label such as gMySubroutine may be listed in the control's options. This would cause the MySubroutine label to be launched automatically whenever the user selects a new item.

Use the R or H option to control the height of the popup list. For example, specifying R5 would make the list 5 rows tall. If both R and H are omitted, the list will automatically expand to take advantage of the available height of the user's desktop (however, operating systems older than Windows XP will show 3 rows by default).

The separator between fields may be changed to something other than pipe (|). For example Gui +Delimiter`n would change it to linefeed and Gui +DelimiterTab would change it to tab (`t).

ComboBox

Same as DropDownList but also permits free-form text to be entered as an alternative to picking an item from the list.

Example: Gui, Add, ComboBox, vColorChoice, Red|Green|Blue|Black|White

In addition to allowing all the same options as DropDownList above, the word Limit may be included in Options to restrict the user's input to the visible width of the ComboBox's edit field. Also, the word Simple may be specified to make the ComboBox behave as though it is an Edit field with a ListBox beneath it.

When the Gui Submit command is used, the control's associated output variable (if any) receives the text of the currently selected item. However, if the control has the AltSubmit property, the output variable will receive the item's position number instead (the first item is 1, the second is 2, etc.). If either case, if there is no selected item, the output variable will be set to the contents of the ComboBox's edit field.

A g-label such as gMySubroutine may be listed in the control's options. This would cause the MySubroutine label to be launched automatically whenever the user selects a new item.

ListBox

A relatively tall box containing a list of choices that can be selected. In this case, the last parameter is is a pipe-delimited list of choices such as Choice1|Choice2|Choice3.

Example: Gui, Add, ListBox, vColorChoice, Red|Green|Blue|Black|White

To have list item(s) pre-selected when the window first appears, include two pipe characters after each (the Multi option is required if more than one item is to be pre-selected). Alternatively, include in Options the word Choose followed immediately by a single item number to pre-select. For example, Choose5 would pre-select the fifth item. To change the choice or add/remove entries from the list after the control has been created, use GuiControl.

When the Gui Submit command is used, the control's associated output variable (if any) receives the text of the currently selected item. However, if the control has the AltSubmit property, the output variable instead receives the item's position number (the first item is 1, the second is 2, etc.).

A g-label such as gMySubroutine may be listed in the control's options. This would cause the MySubroutine label to be launched automatically whenever the user selects a new item. If the user double-clicks an item, the built-in variable A_GuiControlEvent will contain the string DoubleClick rather than Normal. In v1.0.36+, the variable A_EventInfo will contain the position of the item that was double-clicked (1 is the first item, 2 is the second, etc.).

When adding a large number of items to a ListBox, performance may be improved by using GuiControl, -Redraw, MyListBox prior to the operation, and GuiControl, +Redraw, MyListBox afterward (requires v1.0.36+).

ListBox Options:

Sort: Automatically sorts the contents of the list alphabetically (this also affects any items added later via GuiControl). The Sort option also enables incremental searching, which allows an item to be selected by typing the first few characters of its name.

Multi: Allows more than one item to be selected simultaneously via shift-click and control-click (to avoid the need for shift/control-click, specify the number 8 instead of the word Multi). In this case, Gui Submit stores a pipe delimited list of item-strings in the control's output variable. However, if the AltSubmit option is in effect, Gui Submit stores a pipe-delimited list of item numbers instead. For example, 1|2|3 would indicate that the first three items are selected. To extract the individual items from the string, use a parsing loop such as this example:

Loop, parse, MyListBox, |
{
	MsgBox Selection number %A_Index% is %A_LoopField%.
}

The separator between fields may be changed to something other than pipe (|). For example Gui +Delimiter`n would change it to linefeed and Gui +DelimiterTab would change it to tab (`t).

ReadOnly: Prevents items from being visibly highlighted when they are selected (but Gui Submit will still store the selected item).

Tn [v1.0.30+]: The letter T may be used to set tab stops, which can be used to format the text into columns. If the letter T is not used, tab stops are set at every 32 units. If the letter T is used only once, tab stops are set at every n units across the entire width of the control. For example, "Gui, Add, ListBox, vMyListBox t64" would double the default distance between tab stops. To have custom tab stops, specify the letter T multiple times as in the following example: Gui, Add, ListBox, vMyListBox t8 t16 t32 t64 t128. One tab stop is set for each of the absolute column positions in the list, up to a maximum of 50 tab stops.

ListView: See the ListView page.

Hotkey

A box that looks like a single-line edit control but instead accepts a keyboard combination pressed by the user. For example, if the user presses Control+Alt+C on an English keyboard layout, the box would display "Ctrl + Alt + C".

When the Gui Submit command is used, the control's associated output variable (if any) receives the hotkey modifiers and name, which are be compatible with the Hotkey command. Examples: ^!C, +!Home, +^Down, ^Numpad1, !NumpadEnd. If there is no hotkey in the control, the output variable is made blank. Note: Some keys are displayed the same even though they are retrieved as different names. For example, both ^Numpad7 and ^NumpadHome might be displayed as Ctrl + Num 7.

By default, the control starts off with no hotkey specified. To instead have a default, specify its modifiers and name as the last parameter as in this example: Gui, Add, Hotkey, vMyHotkey, ^!p
The only modifiers supported are ^ (Control), ! (Alt), and + (Shift). See the key list for available key names.

In v1.0.35.01+, a g-label such as gMySubroutine may be listed in the control's options. This would cause the MySubroutine label to be launched automatically whenever the user changes the hotkey. Each launch of the g-label also stores the hotkey in control's associated output variable (if any). Note: the g-label is launched even when an incomplete hotkey is present. For example, if the user holds down the Control key, the g-label is launched once and the output variable contains only a caret (^). When the user completes the hotkey, the label is launched again and the variable contains the complete hotkey.

To restrict the types of hotkeys the user may enter, include the word Limit followed by the sum of one or more of the following numbers:

1: Prevent unmodified keys
2: Prevent Shift-only keys
4: Prevent Control-only keys
8: Prevent Alt-only keys
16: Prevent Shift-Control keys
32: Prevent Shift-Alt keys
64: This value is not supported (it will not behave correctly).
128: Prevent Shift-Control-Alt keys.

For example, Limit1 would prevent unmodified hotkeys such as letters and numbers from being entered, and Limit15 would require at least two modifier keys. If the user types a forbidden modifier combination, the Control+Alt combination is automatically and visibly substituted.

The Hotkey control has limited capabilities. For example, it does not support mouse/joystick hotkeys or the Windows key (LWin and RWin). One way to work around this is to provide one or more checkboxes as a means for the user to enable extra modifiers such as the Windows key.

DateTime [v1.0.35+]

A box that looks like a single-line edit control but instead accepts a date and/or time. A drop-down calendar is also provided.

Example: Gui, Add, DateTime, vMyDateTime, LongDate

The last parameter may be one of the following:

(omitted): When omitted, the locale's short date format is used. For example, in some locales it would look like: 6/1/2005

LongDate: Uses the locale's long date format. For example, in some locales it would look like: Wednesday, June 01, 2005

Time: Shows only the time using the locale's time format. Although the date is not shown, it is still present in the control and will be retrieved along with the time in the YYYYMMDDHH24MISS format.

(custom format): Specify any combination of date and time formats. For example, M/d/yy HH:mm would look like 6/1/05 21:37. Similarly, dddd MMMM d, yyyy hh:mm:ss tt would look like Wednesday June 1, 2005 09:37:45 PM

Letters and numbers to be displayed literally should be enclosed in single quotes as in this example: 'Date:' MM/dd/yy 'Time:' hh:mm:ss tt. By contrast, non-alphanumeric characters such as spaces, tabs, slashes, colons, commas, and other punctuation do not need to be enclosed in single quotes. The exception to this is the single quote character itself: to produce it literally, use four consecutive single quotes (''''), or just two if the quote is already inside an outer pair of quotes.

DateTime Usage

To have a date other than today pre-selected, include in Options the word Choose followed immediately by a date in YYYYMMDD format. For example, Choose20050531 would pre-select May 31, 2005. To have no date/time selected, specify ChooseNone. This will also create a checkbox inside the control that is unchecked whenever the control has no date. Whenever the control has no date, Gui Submit and GuiControlGet will retrieve a blank value (empty string).

The time of day may optionally be present. However, it must always be preceded by a date when going into or coming out of the control. The format of the time portion is HH24MISS (hours, minutes, seconds), where HH24 is expressed in 24-hour format; for example, 09 is 9am and 21 is 9pm. Thus, a complete date-time string would have the format YYYYMMDDHH24MISS.

When specifying dates in the YYYYMMDDHH24MISS format, only the leading part needs to be present. Any remaining element that has been omitted will be supplied with the following default values:
MM: Month 01
DD: Day 01
HH24: Hour 00
MI: Minute 00
SS: Second 00

Within the drop-down calendar, the today-string at the bottom can be clicked to select today's date. In addition, the year and month name are clickable and allow easy navigation to a new month or year.

Keyboard navigation: Use the Up/Down arrow keys, NumpadPlus/Minus, and Home/End to increase or decrease the control's values. Use LeftArrow and RightArrow to move from field to field inside the control. Within the drop-down calendar, use the arrow keys to move from day to day; use PageUp/Down to move backward/forward by one month; use Ctrl-PageUp/Down to move backward/forward by one year; and use Home/End to select the first/last day of the month.

When the Gui Submit command is used, the control's associated output variable (if any) receives the selected date and time in YYYYMMDDHH24MISS format. Both the date and the time are present regardless of whether they were actually visible in the control.

If the control has a g-label, the label is launched whenever the user changes the date or time. For each launch, the control's associated output variable (if any) is automatically updated with the currently selected date/time.

Windows 95 and NT4 require DLL versions at least as new as those distributed with Internet Explorer 3.0 to support DateTime controls.

DateTime Options:

Range: Restricts how far back or forward in time the selected date can be. After the word Range, specify the minimum and maximum dates in YYYYMMDD format (with a dash between them). For example, Range20050101-20050615 would restrict the date to the first 5.5 months of 2005. Either the minimum or maximum may be omitted to leave the control unrestricted in that direction. For example, Range20010101 would prevent a date prior to 2001 from being selected and Range-20091231 (leading dash) would prevent a date later than 2009 from being selected. Without the Range option, any date between the years 1601 and 9999 can be selected. The time of day cannot be restricted.

1: Specify the number 1 in Options to provide an up-down control to the right of the control to modify date-time values, which replaces the of the drop-down month calendar that would otherwise be available.

2: Specify the number 2 in Options to provide a checkbox inside the control that the user may uncheck to indicate that no date/time is selected. Once the control is created, this option cannot be changed.

Right: The drop-down calendar will drop down on the right side of the control instead of the left.

MonthCal [v1.0.35+]

A relatively tall control that displays all the days of the month in calendar format. The user may select a single date or a range of dates.

Example: Gui, Add, MonthCal, vMyCalendar

To have a date other than today pre-selected, specify it as the last parameter in YYYYMMDD format (e.g. 20050531). A range of dates may also be pre-selected by including a dash between two dates (e.g. 20050525-20050531).

It is usually best to omit width (W) and height (H) for a MonthCal because it automatically sizes itself to fit exactly one month. To display more than one month vertically, specify R2 or higher in Options. To display more than one month horizontally, specify W-2 (W negative two) or higher. These options may both be present to expand in both directions.

The today-string at the bottom of the control can be clicked to select today's date. In addition, the year and month name are clickable and allow easy selection of a new year or month.

Unlike DateTime's drop-down calendar, keyboard navigation is generally not supported in a MonthCal.

When the Gui Submit command is used, the control's associated output variable (if any) receives the selected date in YYYYMMDD format (without any time portion). However, when the multi-select option is in effect, the minimum and maximum dates are retrieved with a dash between them (e.g. 20050101-20050108). If only a single date was selected in a multi-select calendar, the minimum and maximum are both present but identical. StringSplit can be used to separate the dates. For example, the following would put the minimum in Date1 and the maximum in Date2: StringSplit, Date, MyMonthCal, -

If the MonthCal has a g-label, each launch of it updates the control's associated output variable (if any) with the currently selected date or range. By default, the label is launched only when: 1) the user changes the selection; or 2) every two minutes in case a new day has arrived (this behavior is a quirk of the OS). However, if the word AltSubmit is in the control's Options (v1.0.35.09+), the g-label is launched more often and the built-in variable A_GuiControlEvent will contain the word Normal for a change of the date, the number 1 for a click of a date, and the number 2 when the MonthCal releases "mouse capture". For example, if the user double-clicks a new date, the label would be launched five times: Once with with Normal, twice with 1, and twice with 2. This can be used to detect double clicks by measuring the time between instances of the number 1.

When specifying dates in the YYYYMMDD format, the MM and/or DD portions may be omitted, in which case they are assumed to be 1. For example, 200205 is seen as 20020501, and 2005 is seen as 20050101.

Windows 95 and NT4 require DLL versions at least as new as those distributed with Internet Explorer 3.0 to support MonthCal controls.

MonthCal Options:

Range: Restricts how far back or forward in time the calendar can go. After the word Range, specify the minimum and maximum dates in YYYYMMDD format (with a dash between them). For example, Range20050101-20050615 would restrict the selection to the first 5.5 months of 2005. Either the minimum or maximum may be omitted to leave the calendar unrestricted in that direction. For example, Range20010101 would prevent a date prior to 2001 from being selected and Range-20091231 (leading dash) would prevent a date later than 2009 from being selected. Without the Range option, any date between the years 1601 and 9999 can be selected.

Multi: Multi-select. Allows the user to shift-click or click-drag to select a range of adjacent dates (the user may still select a single date too). This option may be specified explicitly or put into effect automatically by means of specifying a selection range when the control is created. For example: Gui, Add, MonthCal, vMyCal, 20050101-20050108. Once the control is created, this option cannot be changed.

4: Specify the number 4 in Options to display week numbers (1-52) to the left of each row of days. Week 1 is defined as the first week that contains at least four days.

8: Specify the number 8 in Options to prevent the circling of today's date within the control.

16: Specify the number 16 in Options to prevent the display of today's date at the bottom of the control.

Slider

A sliding bar that the user can move along a vertical or horizontal track. The standard volume control in the taskbar's tray is an example of a slider.

Example: Gui, Add, Slider, vMySlider, 50

Specify the starting position of the slider as the last parameter. If the last parameter is omitted, the slider starts off at 0 or the number in the allowable range that is closest to 0.

The user may slide the control by the following means: 1) dragging the bar with the mouse; 2) clicking inside the bar's track area with the mouse; 3) turning the mouse wheel while the control has focus; or 3) pressing the following keys while the control has focus: Arrow keys, Page-up, Page-down, Home, and End.

When the Gui Submit command is used, the control's associated output variable (if any) receives the current numeric position of the slider. The position is also stored in the output variable whenever the control's g-label is launched.

If the slider has a g-label, by default it will be launched only when the user has stopped moving the slider (such as by releasing the mouse button after having dragging it). However, if the word AltSubmit is in the control's Options, the g-label is launched for all slider events and the built-in variable A_GuiControlEvent will contain one of the following digits or strings:

0: The user pressed the Left-arrow or Up-arrow key.
1: The user pressed the Right-arrow or Down-arrow key.
2: The user pressed the Page-up key.
3: The user pressed the Page-down key.
4: The user moved the slider via the mouse wheel, or finished a drag-and-drop to a new position.
5: The user is currently dragging the slider via the mouse; that is, the mouse button is currently down.
6: The user pressed the Home key to send the slider to the left or top side.
7: The user pressed the End key to send the slider to the right or bottom side.
Normal: The user has finished moving the slider, either via the mouse or the keyboard. Note: With the exception of mouse wheel movement (#4), the g-label is launched again for the "normal" event even though it was already launched for one of the digit-events above.

Slider Options:

Vertical: Makes the control slide up and down rather than left and right.

Invert: Reverses the control so that the lower value is considered to be on the right/bottom rather than the left/top. This is typically used to make a vertical slider move in the direction of a traditional volume control. Note: The ToolTip option described below will not obey the inversion and therefore should not be used in this case.

Range: Sets the range to be something other than 0 to 100. After the word Range, specify the minimum, a dash, and maximum. For example, Range1-1000 would allow a number between 1 and 1000 to be selected; Range-50-50 would allow a number between -50 and 50; and Range-10--5 would allow a number between -10 and -5.

Center: The thumb (the bar moved by the user) will be blunt on both ends rather than pointed at one end.

Left: The thumb (the bar moved by the user) will point to the top rather than the bottom. But if the Vertical option is in effect, the thumb will point to the left rather than the right.

NoTicks: No tickmarks will be displayed.

TickInterval: Provides tickmarks at the specified interval. After the word TickInterval, specify the interval at which to display additional tickmarks (if the interval is omitted, it is assumed to be one). For example, TickInterval10 would display a tickmark once every 10 positions.

ToolTip: Creates a tooltip that reports the numeric position of the slider as the user is dragging it. To have the tooltip appear in a non-default position, specify one of the following instead: ToolTipLeft or ToolTipRight (for horizontal sliders); ToolTipTop or ToolTipBottom (for vertical sliders). Windows 95 and NT4 require Internet Explorer 3.0 or later to support this option.

Line: Specifies the number of positions to move when the user presses one of the arrow keys. After the word Line, specify number of positions to move. For example: Line2

Page: Specifies the number of positions to move when the user presses the Page-up or Page-down key. After the word Page, specify number of positions to move. For example: Page10

Thick: Specifies the length of the thumb (the bar moved by the user). After the word Thick, specify the thickness in pixels (e.g. Thick30). To go beyond a certain thickness on Windows XP or later, it is probably necessary to either specify the Center option or remove the theme from the control (which can be done by specifying -Theme in the control's options).

Buddy1 and Buddy2: Specifies up to two existing controls to automatically reposition at the ends of the slider. Buddy1 is displayed at the left or top side (depending on whether the Vertical option is present). Buddy2 is displayed at the right or bottom side. After the word Buddy1 or Buddy2, specify the variable name of an existing control. For example, Buddy1MyTopText would assign the control whose variable name is MyTopText. Windows 95 and NT4 require Internet Explorer 3.0 or later to support this option.

The above options can be changed after the control is created via GuiControl.

Progress

A dual-color bar typically used to indicate how much progress has been made toward the completion of an operation.

Example: Gui, Add, Progress, w300 h20 cBlue

Specify the starting position of the bar as the last parameter (if omitted, the bar starts off at 0 or the number in the allowable range that is closest to 0). To later change the position of the bar, follow these examples, all of which operate upon a progress bar whose associated variable name is MyProgress:
GuiControl,, MyProgress, +20 ; Increase the current position by 20.
GuiControl,, MyProgress, 50 ; Set the current position to 50.

For horizontal Progress Bars, the thickness of the bar is equal to the control's height. For vertical Progress Bars it is equal to the control's width.

Progress Options

Vertical: Makes the bar rise or fall vertically rather than move along horizontally. Windows 95 and NT4 require Internet Explorer 3.0 or later to support this option.

Cn: Changes the bar's color. Specify for n one of the 16 primary HTML color names or a 6-digit RGB color value. Examples: cRed, cFFFF33, cDefault. If the C option is never used (or cDefault is specified), the system's default bar color will be used.

BackgroundN: Changes the bar's background color. Specify for n one of the 16 primary HTML color names or a 6-digit RGB color value. Examples: BackgroundGreen, BackgroundFFFF33, BackgroundDefault. If the Background option is never used (or BackgroundDefault is specified), the background color will be that of the window or tab control behind it.

Range: Sets the range to be something other than 0 to 100. After the word Range, specify the minimum, a dash, and maximum. For example, Range0-1000 would allow a numbers between 0 and 1000; Range-50-50 would allow numbers between -50 and 50; and Range-10--5 would allow numbers between -10 and -5. On Windows 95 and NT4, negative ranges and ranges beyond 65535 will not behave correctly unless Internet Explorer 3.0 or later is installed.

-Smooth (minus Smooth): Displays a length of segments rather than a smooth continuous bar. Specifying -Smooth is also one of the requirements to show a themed progress bar on Windows XP or later. The other requirement is that the bar not have any custom colors; that is, that the C and Background options be omitted. Windows 95 and NT4 require Internet Explorer 3.0 or later to support this option.

The above options can be changed after the control is created via GuiControl.

GroupBox

A rectangular border/frame, often used around other controls to indicate they are related. In this case, the last parameter is the title of the box, which if present is displayed at its upper-left edge.

Example: Gui, Add, GroupBox, w400 h300, Geographic Criteria

Tab

A relatively large control containing multiple pages, each of which contains other controls. From this point forward, these pages are referred to as "tabs".

Example: Gui, Add, Tab,, General|View|Appearance|Settings

The last parameter above is a pipe-delimited list of tab names. To have one of the tabs pre-selected when the window first appears, include two pipe characters after it. Alternatively, include in Options the word Choose followed immediately by the number to pre-select. For example, Choose5 would pre-select the fifth tab. To change the selected tab, add tabs, or remove tabs after the control has been created, use GuiControl.

After creating a Tab control, subsequently added controls automatically belong to its first tab. This can be changed at any time by following these examples:

Gui, Tab   ; Future controls are not part of any tab control.
Gui, Tab, 3   ; Future controls are owned by the third tab of the current tab control.
Gui, Tab, 3, 2   ; Future controls are owned by the third tab of the second tab control.
Gui, Tab, Name   ; Future controls are owned by the tab whose name starts with Name (not case sensitive).
Gui, Tab, Name,, Exact  ; Same as above but requires exact match (case sensitive too). [v1.0.37.03+]

It is also possible to use any of the examples above to assign controls to a tab or tab-control that doesn't yet exist (except in the case of the Name method). But in that case, the relative positioning options described below are not supported.

Positioning: When each tab of a Tab control receives its first sub-control, that sub-control will have a special default position under the following conditions: 1) The X and Y coordinates are both omitted, in which case the sub-control is positioned at the upper-left corner of the tab control's interior (with a standard margin); 2) The X+n and/or Y+n positioning options are specified, in which case the sub-control is positioned relative to the upper-left corner of the tab control's interior. For example, specifying "x+10 y+10" would position the control 10 pixels right and 10 pixels down from the upper left corner.

Sub-controls do not necessarily need to exist within their Tab control's boundaries: they will still be hidden and shown whenever their tab is selected or de-selected. This behavior is especially appropriate for the "buttons" style described below.

When the Gui Submit command is used, the control's associated output variable (if any) receives the name of the currently selected tab. However, if the control has the AltSubmit property, the output variable will receive the tab's position number instead (the first tab is 1, the second is 2, etc.).

A g-label such as gMySubroutine may be listed in the control's options. This would cause the MySubroutine label to be launched automatically whenever the user changes to a new tab. If the tab control has both a g-label and an output variable, the output variable will be set to the previously selected tab name -- or number in the case of AltSubmit -- whenever the user switches to a new tab.

Keyboard navigation: The user may press Control-PageDown/PageUp to navigate from page to page in a tab control; if the keyboard focus is on a control that does not belong to a Tab control, the window's first Tab control will be navigated. Control-Tab and Control-Shift-Tab may also be used except that they will not work if the currently focused control is a multi-line Edit control.

Each window may have no more than 255 tab controls. Each tab control may have no more than 256 tabs (pages).

Tab Options:

-Background (minus followed by the word background): Overrides the window's custom background color and uses the system's default Tab control color. In v1.0.32+, specify +Theme -Background to give make the Tab control conform to the current desktop theme. However, most control types will look strange inside such a Tab control because their backgrounds will not match that of the tab control. This can be fixed for some control types (such as Text) by adding BackgroundTrans to their options.

-Wrap: Prevents the tabs from taking up more than a single row (in which case if there are too many tabs to fit, arrow buttons are displayed to allow the user to slide more tabs into view).

Buttons: Creates a series of buttons at the top of the control rather than a series of tabs (in this case, there will be no border by default because the display area does not typically contain controls).

Left/Right/Bottom: Specify one of these words to have the tabs on the left, right, or bottom side instead of the top. See TCS_VERTICAL for limitations on Left and Right.

Related

Gui, GuiControl, GuiControlGet, Menu