AutoIt (Macros)
From The Ultimate Programming Reference
(Difference between revisions)
Line 4: | Line 4: | ||
The pre-defined macros are generally used to provide easy access to system information like the location of the Windows directory, or the name of the logged on user. | The pre-defined macros are generally used to provide easy access to system information like the location of the Windows directory, or the name of the logged on user. | ||
+ | |||
+ | {| border="1" cellpadding="2" | ||
+ | |+Table of Macros | ||
+ | |- | ||
+ | ! @AppDataCommonDir|| path to Application Data | ||
+ | |- | ||
+ | ! @AppDataDir|| path to current user's Application Data | ||
+ | |- | ||
+ | ! @AutoItExe|| The full path and filename of the AutoIt executable currently running. For compiled scripts it is the path of the compiled script. | ||
+ | |- | ||
+ | ! @AutoItVersion|| Version number of AutoIt such as 3.0.81.0 | ||
+ | |- | ||
+ | ! @CommonFilesDir|| path to Common Files folder | ||
+ | |- | ||
+ | ! @Compiled|| Returns 1 if script is a compiled executable; otherwise, returns 0. | ||
+ | |- | ||
+ | ! @ComputerName|| Computer's network name. | ||
+ | |- | ||
+ | ! @ComSpec|| value of %comspec%, the SPECified secondary COMmand interpreter; | ||
+ | primarily for command line uses, e.g. Run(@ComSpec & " /k help | more") | ||
+ | |- | ||
+ | ! @CR|| Carriage return, Chr(13); sometimes used for line breaks. | ||
+ | |- | ||
+ | ! @CRLF|| = @CR & @LF ;occasionally used for line breaks. | ||
+ | |- | ||
+ | ! @DesktopCommonDir|| path to Desktop | ||
+ | |- | ||
+ | ! @DesktopDir|| path to current user's Desktop | ||
+ | |- | ||
+ | ! @DesktopHeight|| Height of the desktop screen in pixels. (horizontal resolution) | ||
+ | |- | ||
+ | ! @DesktopWidth|| Width of the desktop screen in pixels. (vertical resolution) | ||
+ | |- | ||
+ | ! @DesktopDepth|| Depth of the desktop screen in bits per pixel. | ||
+ | |- | ||
+ | ! @DesktopRefresh|| Refresh rate of the desktop screen in hertz. | ||
+ | |- | ||
+ | ! @DocumentsCommonDir|| path to Documents | ||
+ | |- | ||
+ | ! @error|| Status of the error flag. See the SetError function. | ||
+ | |- | ||
+ | ! @extended|| Extended function return - used in certain functions such as StringReplace. | ||
+ | |- | ||
+ | ! @FavoritesCommonDir|| path to Favorites | ||
+ | |- | ||
+ | ! @FavoritesDir|| path to current user's Favorites | ||
+ | |- | ||
+ | ! @GUI_CtrlId|| Last click control identifier. See the GUICtrlSetOnEvent function. | ||
+ | |- | ||
+ | ! @GUI_CtrlHandle|| Last click control handle. See the GUICtrlSetOnEvent function. | ||
+ | |- | ||
+ | ! @GUI_WinHandle|| Last click GUI window handle. See the GUICtrlSetOnEvent function. | ||
+ | |- | ||
+ | ! @HomeDrive|| Drive letter of drive containing current user's home directory. | ||
+ | |- | ||
+ | ! @HomePath|| Directory part of current user's home directory. To get the full path, use in conjunction with @HomeDrive. | ||
+ | |- | ||
+ | ! @HomeShare|| @HomeShare - Server and share name containing current user's home directory. | ||
+ | |- | ||
+ | ! @HOUR|| Hours value of clock in 24-hour format. Range is 00 to 23 | ||
+ | |- | ||
+ | ! @InetGetActive|| Is 1 if a InetGet download is currently active, otherwise is 0. | ||
+ | |- | ||
+ | ! @InetGetBytesRead|| During a InetGet download this is the number of bytes currently read. It is -1 when there is an error downloading. | ||
+ | |- | ||
+ | ! @IPAddress1|| IP address of first network adapter. Tends to return 127.0.0.1 on some computers. | ||
+ | |- | ||
+ | ! @IPAddress2|| IP address of second network adapter. Returns 0.0.0.0 if not applicable. | ||
+ | |- | ||
+ | ! @IPAddress3|| IP address of third network adapter. Returns 0.0.0.0 if not applicable. | ||
+ | |- | ||
+ | ! @IPAddress4|| IP address of fourth network adapter. Returns 0.0.0.0 if not applicable. | ||
+ | |- | ||
+ | ! @LF|| Line feed, Chr(10); typically used for line breaks. | ||
+ | |- | ||
+ | ! @LogonDNSDomain|| Logon DNS Domain. | ||
+ | |- | ||
+ | ! @LogonDomain|| Logon Domain. | ||
+ | |- | ||
+ | ! @LogonServer|| Logon server. | ||
+ | |- | ||
+ | ! @MDAY|| Current day of month. Range is 01 to 31 | ||
+ | |- | ||
+ | ! @MIN|| Minutes value of clock. Range is 00 to 59 | ||
+ | |- | ||
+ | ! @MON|| Current month. Range is 01 to 12 | ||
+ | |- | ||
+ | ! @MyDocumentsDir|| path to My Documents target | ||
+ | |- | ||
+ | ! @NumParams|| Number of parameters used to call the user functions | ||
+ | |- | ||
+ | ! @OSBuild|| Returns the OS build number. For example, Windows 2003 Server returns 3790 | ||
+ | |- | ||
+ | ! @OSLang|| Returns code denoting OS Language. See Appendix for possible values. | ||
+ | |- | ||
+ | ! @OSServicePack|| Service pack info in the form of "Service Pack 3" or, for Windows 95, it may return "B" | ||
+ | |- | ||
+ | ! @OSTYPE|| Returns "WIN32_NT" for NT/2000/XP/2003 and returns "WIN32_WINDOWS" for 95/98/Me | ||
+ | |- | ||
+ | ! @OSVersion|| Returns one of the following: "WIN_2003", "WIN_XP", "WIN_2000", "WIN_NT4", "WIN_ME", "WIN_98", "WIN_95" | ||
+ | |- | ||
+ | ! @ProgramFilesDir|| path to Program Files folder | ||
+ | |- | ||
+ | ! @ProgramsCommonDir|| path to Start Menu's Programs folder | ||
+ | |- | ||
+ | ! @ProgramsDir|| path to current user's Programs (folder on Start Menu) | ||
+ | |- | ||
+ | ! @ScriptDir|| Directory containing the running script. (Result does not contain a trailing backslash) | ||
+ | |- | ||
+ | ! @ScriptFullPath|| Equivalent to @ScriptDir & "\\" & @ScriptName | ||
+ | |- | ||
+ | ! @ScriptName|| Long filename of the running script. | ||
+ | |- | ||
+ | ! @SEC|| Seconds value of clock. Range is 00 to 59 | ||
+ | |- | ||
+ | ! @StartMenuCommonDir|| path to Start Menu folder | ||
+ | |- | ||
+ | ! @StartMenuDir|| path to current user's Start Menu | ||
+ | |- | ||
+ | ! @StartupCommonDir|| path to Startup folder | ||
+ | |- | ||
+ | ! @StartupDir|| current user's Startup folder | ||
+ | |- | ||
+ | ! @SW_DISABLE|| Disables the window. | ||
+ | |- | ||
+ | ! @SW_ENABLE|| Enables the window. | ||
+ | |- | ||
+ | ! @SW_HIDE|| Hides the window and activates another window. | ||
+ | |- | ||
+ | ! @SW_MAXIMIZE|| Maximizes the specified window. | ||
+ | |- | ||
+ | ! @SW_MINIMIZE|| Minimizes the specified window and activates the next top-level window in the Z order. | ||
+ | |- | ||
+ | ! @SW_RESTORE|| Activates and displays the window. If the window is minimized or maximized, the system restores it to its | ||
+ | 0riginal size and position. An application should specify this flag when restoring a minimized window. | ||
+ | |- | ||
+ | ! @SW_SHOW|| Activates the window and displays it in its current size and position. | ||
+ | |- | ||
+ | ! @SW_SHOWDEFAULT|| Sets the show state based on the SW_ value specified by the program that started the application. | ||
+ | |- | ||
+ | ! @SW_SHOWMAXIMIZED|| Activates the window and displays it as a maximized window. | ||
+ | |- | ||
+ | ! @SW_SHOWMINIMIZED|| Activates the window and displays it as a minimized window. | ||
+ | |- | ||
+ | ! @SW_SHOWMINNOACTIVE|| Displays the window as a minimized window. This value is similar to @SW_SHOWMINIMIZED, except the window is not activated. | ||
+ | |- | ||
+ | ! @SW_SHOWNA|| Displays the window in its current size and position. This value is similar to @SW_SHOW, except the window is not activated. | ||
+ | |- | ||
+ | ! @SW_SHOWNOACTIVATE|| Displays a window in its most recent size and position. This value is similar to @SW_SHOWNORMAL, except the window is not actived. | ||
+ | |- | ||
+ | ! @SW_SHOWNORMAL|| Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time. | ||
+ | |- | ||
+ | ! @SystemDir|| path to Windows' System (or System32) folder | ||
+ | |- | ||
+ | ! @TAB|| Tab character, Chr(9) | ||
+ | |- | ||
+ | ! @TempDir|| Path to the temporary files folder. | ||
+ | |- | ||
+ | ! @UserProfileDir|| Path to current user's Profile folder. | ||
+ | |- | ||
+ | ! @UserName|| ID of the currently logged on user. | ||
+ | |- | ||
+ | ! @WDAY|| Numeric day of week. Range is 1 to 7 which corresponds to Sunday through Saturday. | ||
+ | |- | ||
+ | ! @WindowsDir|| path to Windows folder | ||
+ | |- | ||
+ | ! @WorkingDir|| Current/active working directory. (Result does not contain a trailing backslash) | ||
+ | |- | ||
+ | ! @YDAY|| Current day of year. Range is 1 to 366 (or 365 if not a leap year) | ||
+ | |- | ||
+ | ! @YEAR|| Current four-digit year | ||
+ | |} | ||
+ | |||
+ | [[Category:AutoIt]] |
Revision as of 11:49, 26 March 2006
Macros
AutoIt has an number of Macros that are special read-only variables used by AutoIt. Macros start with the @ character instead of the usual $ so are easy to tell apart. As with normal variables you can use macros in expressions but you cannot assign a value to them.
The pre-defined macros are generally used to provide easy access to system information like the location of the Windows directory, or the name of the logged on user.
@AppDataCommonDir | path to Application Data |
---|---|
@AppDataDir | path to current user's Application Data |
@AutoItExe | The full path and filename of the AutoIt executable currently running. For compiled scripts it is the path of the compiled script. |
@AutoItVersion | Version number of AutoIt such as 3.0.81.0 |
@CommonFilesDir | path to Common Files folder |
@Compiled | Returns 1 if script is a compiled executable; otherwise, returns 0. |
@ComputerName | Computer's network name. |
@ComSpec | value of %comspec%, the SPECified secondary COMmand interpreter;
primarily for command line uses, e.g. Run(@ComSpec & " /k help | more") |
@CR | Carriage return, Chr(13); sometimes used for line breaks. |
@CRLF | = @CR & @LF ;occasionally used for line breaks. |
@DesktopCommonDir | path to Desktop |
@DesktopDir | path to current user's Desktop |
@DesktopHeight | Height of the desktop screen in pixels. (horizontal resolution) |
@DesktopWidth | Width of the desktop screen in pixels. (vertical resolution) |
@DesktopDepth | Depth of the desktop screen in bits per pixel. |
@DesktopRefresh | Refresh rate of the desktop screen in hertz. |
@DocumentsCommonDir | path to Documents |
@error | Status of the error flag. See the SetError function. |
@extended | Extended function return - used in certain functions such as StringReplace. |
@FavoritesCommonDir | path to Favorites |
@FavoritesDir | path to current user's Favorites |
@GUI_CtrlId | Last click control identifier. See the GUICtrlSetOnEvent function. |
@GUI_CtrlHandle | Last click control handle. See the GUICtrlSetOnEvent function. |
@GUI_WinHandle | Last click GUI window handle. See the GUICtrlSetOnEvent function. |
@HomeDrive | Drive letter of drive containing current user's home directory. |
@HomePath | Directory part of current user's home directory. To get the full path, use in conjunction with @HomeDrive. |
@HomeShare | @HomeShare - Server and share name containing current user's home directory. |
@HOUR | Hours value of clock in 24-hour format. Range is 00 to 23 |
@InetGetActive | Is 1 if a InetGet download is currently active, otherwise is 0. |
@InetGetBytesRead | During a InetGet download this is the number of bytes currently read. It is -1 when there is an error downloading. |
@IPAddress1 | IP address of first network adapter. Tends to return 127.0.0.1 on some computers. |
@IPAddress2 | IP address of second network adapter. Returns 0.0.0.0 if not applicable. |
@IPAddress3 | IP address of third network adapter. Returns 0.0.0.0 if not applicable. |
@IPAddress4 | IP address of fourth network adapter. Returns 0.0.0.0 if not applicable. |
@LF | Line feed, Chr(10); typically used for line breaks. |
@LogonDNSDomain | Logon DNS Domain. |
@LogonDomain | Logon Domain. |
@LogonServer | Logon server. |
@MDAY | Current day of month. Range is 01 to 31 |
@MIN | Minutes value of clock. Range is 00 to 59 |
@MON | Current month. Range is 01 to 12 |
@MyDocumentsDir | path to My Documents target |
@NumParams | Number of parameters used to call the user functions |
@OSBuild | Returns the OS build number. For example, Windows 2003 Server returns 3790 |
@OSLang | Returns code denoting OS Language. See Appendix for possible values. |
@OSServicePack | Service pack info in the form of "Service Pack 3" or, for Windows 95, it may return "B" |
@OSTYPE | Returns "WIN32_NT" for NT/2000/XP/2003 and returns "WIN32_WINDOWS" for 95/98/Me |
@OSVersion | Returns one of the following: "WIN_2003", "WIN_XP", "WIN_2000", "WIN_NT4", "WIN_ME", "WIN_98", "WIN_95" |
@ProgramFilesDir | path to Program Files folder |
@ProgramsCommonDir | path to Start Menu's Programs folder |
@ProgramsDir | path to current user's Programs (folder on Start Menu) |
@ScriptDir | Directory containing the running script. (Result does not contain a trailing backslash) |
@ScriptFullPath | Equivalent to @ScriptDir & "\\" & @ScriptName |
@ScriptName | Long filename of the running script. |
@SEC | Seconds value of clock. Range is 00 to 59 |
@StartMenuCommonDir | path to Start Menu folder |
@StartMenuDir | path to current user's Start Menu |
@StartupCommonDir | path to Startup folder |
@StartupDir | current user's Startup folder |
@SW_DISABLE | Disables the window. |
@SW_ENABLE | Enables the window. |
@SW_HIDE | Hides the window and activates another window. |
@SW_MAXIMIZE | Maximizes the specified window. |
@SW_MINIMIZE | Minimizes the specified window and activates the next top-level window in the Z order. |
@SW_RESTORE | Activates and displays the window. If the window is minimized or maximized, the system restores it to its
0riginal size and position. An application should specify this flag when restoring a minimized window. |
@SW_SHOW | Activates the window and displays it in its current size and position. |
@SW_SHOWDEFAULT | Sets the show state based on the SW_ value specified by the program that started the application. |
@SW_SHOWMAXIMIZED | Activates the window and displays it as a maximized window. |
@SW_SHOWMINIMIZED | Activates the window and displays it as a minimized window. |
@SW_SHOWMINNOACTIVE | Displays the window as a minimized window. This value is similar to @SW_SHOWMINIMIZED, except the window is not activated. |
@SW_SHOWNA | Displays the window in its current size and position. This value is similar to @SW_SHOW, except the window is not activated. |
@SW_SHOWNOACTIVATE | Displays a window in its most recent size and position. This value is similar to @SW_SHOWNORMAL, except the window is not actived. |
@SW_SHOWNORMAL | Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time. |
@SystemDir | path to Windows' System (or System32) folder |
@TAB | Tab character, Chr(9) |
@TempDir | Path to the temporary files folder. |
@UserProfileDir | Path to current user's Profile folder. |
@UserName | ID of the currently logged on user. |
@WDAY | Numeric day of week. Range is 1 to 7 which corresponds to Sunday through Saturday. |
@WindowsDir | path to Windows folder |
@WorkingDir | Current/active working directory. (Result does not contain a trailing backslash) |
@YDAY | Current day of year. Range is 1 to 366 (or 365 if not a leap year) |
@YEAR | Current four-digit year |