jeeswg's documentation extension tutorial

Helpful script writing tricks and HowTo's
User avatar
jeeswg
Posts: 2682
Joined: 19 Dec 2016, 01:58
Location: UK

jeeswg's documentation extension tutorial

25 Jun 2017, 02:43

This is part of a set of beginner's tutorials:
- beginner tutorial [to come]
- strings tutorial
- mathematics tutorial [to come]
- documentation extension tutorial

The documentation extension is:
- tips on commands/functions separated by category
- things I would add to (or highlight) in the documentation

==================================================

LINKS:

[list every function/command/directive/variable/control flow statement]
list of every command/function/variable from across all versions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=27321&p=131642#p131642

[chm to txt]
[C:\Program Files\AutoHotkey\AutoHotkey.chm to a txt file]
htm to txt, AutoHotkey Help (chm file) to txt - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=26402

[chm to separate htm files]
[C:\Program Files\AutoHotkey\AutoHotkey.chm to separate htm files]
E.g. use 7-Zip.

[command/function list and parameter count/types]
conversion logic, v1 = -> v1 := -> v2, two-way compatibility - Page 5 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=27069&p=140146#p140146

[command/function list and parameters]
list of every command/function/variable from across all versions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=27321&p=130479#p130479

==================================================

CONTENTS:

>>>GUI: internal GUIs only
>>>GUI: internal/external GUIs, images
>>>GUI: notifications/dialogs
>>>interaction, files/folders, system
>>>objects
>>>strings/variables
>>>binary data
>>>dates
>>>Internet
>>>mathematics
>>>keyboard/mouse
>>>AutoHotkey control flow statements
>>>AutoHotkey main window menu items
>>>AutoHotkey modes/settings
>>>AutoHotkey itself (further commands/functions)
>>>(updated functions)
>>>(limits)

==================================================

>>>GUI: internal GUIs only
>>GuiXXX
>>IL_XXX
>>LV_XXX/SB_XXX/TV_XXX
>>MenuXXX

[WARNING] Gui: If the Gui command is present in a script, or a script that it includes, that script becomes #Persistent. It can only be closed via ExitApp or by the user. I.e. this prevents scripts with no hotkeys from closing.
[LIMIT] Gui: The Gui command does not support specifying a custom class name: it must be 'AutoHotkeyGUI', although this can be edited in the AutoHotkey exe file or live in the virtual memory. Note: dialogs and windows can be created via dll functions, with any chosen class name, but these windows cannot be handled by the Gui command.
[LIMIT] Gui: The Gui command does not support specifying a window with no icon.
[LIMIT] Gui: There are no built-in commands/functions for use with toolbar controls.

Code: [Select all] [Download] GeSHi © Codebox Plus

q:: ;create a simple GUI:
Gui, +HwndhWnd
Gui, Show, w300 h300
WinGetTitle, vWinTitle, % "ahk_id " hWnd
MsgBox, % vWinTitle
return


==================================================

>>>GUI: internal/external GUIs, images
>>ControlXXX/StatusBarXXX
>>ImageSearch/LoadPicture/PixelGetColor/PixelSearch
>>MenuSelect
>>ProcessXXX
>>WinXXX/GroupXXX
>>(also: #IfWinActive)

[LIMIT] ProcessSetPriority: There is no 'ProcessGetPriority' function.
[LIMIT] ControlGetText: There is no support for external treeviews.
[LIMIT] StatusBarGetText/StatusBarWait: only work on a control of the form ClassNN 'msctls_statusbar321', i.e. not on a second or custom status bar.
[NOTE] WinGetTransColor/WinGetTransparent: unfortunately, it is not possible to make one colour partially transparent using these commands (there may or may not be alternative methods to achieve this).
[NOTE] #IfWinActive: For '#IfWinActive WinCriteria', where 'WinCriteria' is not blank, then 'hWnd := WinExist()' will contain the hWnd of the window that matched WinCriteria when the hotkey was triggered, the 'Last Found Window'.
[NOTE] ImageSearch: To perform an image search on image data in memory, e.g. from a file, rather than live on the screen, use the custom function: Gdip_ImageSearch.
[NOTE] ImageSearch: The ErrorLevel values for ImageSearch can be confusing, it is: '0=found,1=not found,2=problem' (it is *not*: '0=not found,1=found').
[NOTE] WinGet/ControlGet: to get the window/control under the cursor use MouseGetPos.

Code: [Select all] [Download] GeSHi © Codebox Plus

;#IfWinActive and Last Found Window
#IfWinActive A ;matches any window (Last Found Window set)
q::
#IfWinActive ;matches any window (Last Found Window not set)
w::
hWnd := WinExist()
WinGetTitle, vWinTitle, % "ahk_id " hWnd
MsgBox, % vWinTitle
return


[Use the Acc library to get text from more control types:]
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

Code: [Select all] [Download] GeSHi © Codebox Plus

;e.g. LoadPicture:
hBitmap := LoadPicture(A_AhkPath) ;without type parameter, bitmap
hIcon := LoadPicture(A_AhkPath, "", vType) ;with type parameter, depends on the source

;e.g. ImageSearch:
ImageSearch, vPosX, vPosY, 0, 0, % A_ScreenWidth, % A_ScreenHeight, % "*84 HICON:*" hIcon


Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



[e.g. repeated ImageSearch/PixelSearch:]
[repeated ImageSearch][ImageSearch: click image every time it's found]
My first project: How hard/easy it is to develop a script for this? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=28023
[repeated PixelSearch][PixelSearch: click pixel every time it's found]
after 4 hours i decided i should get help lol - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=28516

For the full list of ahk_class/ahk_id/ahk_pid/ahk_exe/ahk_group see:
WinTitle & Last Found Window
https://autohotkey.com/docs/misc/WinTitle.htm

colour names and RGB values (color names):
Progress/SplashImage
https://autohotkey.com/docs/commands/Progress.htm
Black=000000
Silver=C0C0C0
Gray=808080
White=FFFFFF
Maroon=800000
Red=FF0000
Purple=800080
Fuchsia=FF00FF
Green=008000
Lime=00FF00
Olive=808000
Yellow=FFFF00
Navy=000080
Blue=0000FF
Teal=008080
Aqua=00FFFF

==================================================

>>>GUI: notifications/dialogs
>>FileSelect/DirSelect (previously: FileSelectFile/FileSelectFolder)
>>Exception
>>MsgBox/InputBox/ToolTip/TrayTip
>>(also previously: Progress/SplashImage/SplashTextOn)

[BACKGROUND] FileSelect: uses the Common File Dialog (pre-Windows Vista), and the Common Item Dialog (post-Windows Vista).
[LIMIT] FileSelect: has a different appearance depending on the operating system, you cannot choose the old style on a newer operating system.
[BACKGROUND] MsgBox: is based on the MessageBox dll function.
[BACKGROUND] InputBox: is based on the DialogBox dll function and a dialog resource inside the AutoHotkey exe (which can be inspected using Resource Hacker).
[LIMIT] MsgBox/InputBox: You cannot specify the font for MsgBox/InputBox commands. (The 'Font' parameter for InputBox is not implemented.)
[LIMIT] MsgBox: can cause a beep.

==================================================

>>>interaction, files/folders, system
>>ClipWait (also: Clipboard variable)
>>DllCall/PostMessage/SendMessage
>>SoundXXX/DriveXXX/SysGet/MonitorXXX (also: SoundBeep, SoundPlay)
>>FileXXX/DirXXX
>>IniXXX
>>RegXXX
>>RunXXX/Shutdown
>>(also: A_OSVersion, A_AppData)

[LIMIT] FileRead: does not support UTF-16 BE ('Unicode big endian' on Notepad), use LCMapStringW (DllCall).
[LIMIT] FileGetTime/FileSetTime: do not handle milliseconds, and only handle local time, not UTC time.
[LIMIT] FileAppend/FileCopy/FileMove: only work if the specified directory already exists.
[LIMIT] FileRead: use *c to read the contents of a binary file, unfortunately you cannot do *c4 for example, to read the first 4 bytes. [Fixed in AHK v2.]
[WARNING] FileRead/FileAppend: do not support all of the encodings listed at: Code Page Identifiers (Windows) http://msdn.microsoft.com/en-us/library/dd317756.aspx
[WARNING] FileAppend: uses 'End of line (EOL) translation' by default, (it replaces lone LFs with CRLFs), use * to prevent this.
[LIMIT] FileGetShortcut: cannot retrieve a lnk file's shortcut key. Although FileGetShortcut can specify a shortcut key.
[BACKGROUND] PostMessage/SendMessage: AHK has PostMessage/SendMessage commands, but PostMessage and SendMessage are also dll functions, and can be used with DllCall.
[NOTE] PostMessage/SendMessage: both send a message to a window/control, however, the SendMessage command waits until it receives a reply before moving on to the next line.
[WARNING] IniRead: 'To store a blank value (empty string), specify %A_Space%'.
[LIMIT] IniRead/IniWrite: use GetPrivateProfileString and WritePrivateProfileString which don't support UTF-8, although you could create an ANSI ini file, and convert the bytes to UTF-8 when reading/writing.
[NOTE] IniWrite: if the ini file does not already exist, it will create a UTF-16 LE/ANSI ini file depending on whether the AHK version is Unicode/ANSI.
[NOTE] IniRead/IniWrite: cannot handle all characters in a key name e.g. these 3: [=;
[LIMIT] RegWrite: There is no 'RegCreateKey' function to create empty registry keys (cf. RegWrite which creates registry values).
[NOTE] SoundBeep: can only play one sound at a time, even if you open multiple scripts.
[NOTE] Run: To keep a ComSpec window open after the task completes use switch: '/K'.
[LIMIT] A_AppData: There is no 'A_Recent' variable, for the Recent Items folder.
[NOTE] A_AppData: %A_AppData% is C:\Users\%A_UserName%\AppData\Roaming (%A_AppData% is not C:\Users\%A_UserName%\AppData) (e.g. on Windows 7).
[NOTE] A_OSVersion gives a friendly name in AHK v1, but gives a version number in AHK v2

value types, same order as they appear in Registry Editor (Windows 7):
[REG_SZ,REG_BINARY,REG_DWORD,REG_QWORD,REG_MULTI_SZ,REG_EXPAND_SZ]
REG_SZ String Value
REG_BINARY Binary Value
REG_DWORD DWORD (32-bit) Value
REG_QWORD QWORD (64-bit) Value
REG_MULTI_SZ Multi-String Value
REG_EXPAND_SZ Expandable String Value

root keys, same order as they appear in Registry Editor (Windows 7):
[HKEY_CLASSES_ROOT,HKEY_CURRENT_USER,HKEY_LOCAL_MACHINE,HKEY_USERS,HKEY_CURRENT_CONFIG]
[HKCR,HKCU,HKLM,HKU,HKCC]
HKCR HKEY_CLASSES_ROOT
HKCU HKEY_CURRENT_USER
HKLM HKEY_LOCAL_MACHINE
HKU HKEY_USERS
HKCC HKEY_CURRENT_CONFIG

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Download] GeSHi © Codebox Plus

q:: ;get Windows version number (e.g. Windows 7: 6.1.7601)
vVersion := DllCall("kernel32\GetVersion", UInt)
MsgBox, % Format("{}.{}.{:04}", vVersion & 0xFF, (vVersion >> 8) & 0xFF, (vVersion >> 16) & 0xFFFF)
return


Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



==================================================

>>>objects
>>Array/Object
>>ComObjXXX
>>IsObject
>>ObjXXX
>>Type

[NOTE] ObjAddRef/ObjRelease: Be careful with ObjAddRef and ObjRelease, and consider deleting objects when not needed e.g. oMyObj := "".
[LIMIT] Object: AHK objects do not have a Count method as standard.
[NOTE] Object: A key can have a value or child keys, but not both.

Code: [Select all] [Download] GeSHi © Codebox Plus

;all 4 are equivalent:
oMyArray := Array(), oMyArray := []
oMyObj := Object(), oMyArray := {}


Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



==================================================

>>>strings/variables
>>Chr/Ord (previously: Asc)
>>Deref
>>InStr/StrReplace
>>RegExMatch/RegExReplace
>>Sort
>>StrGet/StrPut
>>StringXXX
>>StrLen
>>StrUpper/StrLower
>>StrSplit/SplitPath
>>SubStr
>>Trim/LTrim/RTrim
>>(also: A_IsUnicode, if var in/contains list, if var is type)

[LIMIT] RegExMatch: In AHK Unicode, RegExMatch can only handle 2-byte pairs at 2-byte intervals, so is limited when handling ANSI/UTF-8/binary searches.
[NOTE] RegExMatch/RegExReplace: can be slow compared to other methods, e.g. sometimes using StrReplace multiple times can be faster than using RegExReplace.
[NOTE] RegExMatch/RegExReplace: 'Options)' is AHK-specific and is not a standard part of RegEx, although these options can usually be applied via standard RegEx instead.
[NOTE] RegExMatch/RegExReplace: There are some RegEx techniques that can be used that aren't in the AHK documentation, see: 'PCRE REGULAR EXPRESSION SYNTAX SUMMARY', at: pcresyntax specification http://www.pcre.org/original/doc/html/pcresyntax.html
[LIMIT] StrReplace: does not have a case sensitive parameter (cf. InStr). Use StringCaseSense to set the case sensitive/insensitive mode, or use RegExReplace to do a case sensitive/insensitive text replace.
[WARNING] Sort: uses unstable sort: e.g. if two items are regarded as identical e.g. 'A' and 'a' in a case-insensitive sort, the items may be swapped (the relative positions are not maintained). In a stable sort, identical items remain in their original order.
[WARNING (AHK V2)] InStr/SubStr/RegExMatch/RegExReplace: handle negative offsets differently.
[WARNING] Chr/Asc/Ord: differ in the range 128-255 depending on whether the AHK version is Unicode/ANSI.
[NOTE] StringXXX: StringXXX commands are generally deprecated, although StringCaseSense and StringLower/StringUpper are not deprecated.
[WARNING] A_IsUnicode: A_IsUnicode's value is 1 or blank (not 1 or 0).
[WARNING] if var is [not] type: a blank string returns a positive result for some types e.g. it is considered as alphanumeric/alpha.

for 'if var between/contains/in/is'
the position of the word 'not' is inconsistent:
if var [not] between low and high
if var [not] contains list
if var [not] in list
if var is [not] type

Code: [Select all] [Download] GeSHi © Codebox Plus

;e.g. SubStr get last n characters:
SubStr(vText, 1-n) ;AHK v1
SubStr(vText, -n) ;AHK v2
vIsV1 := !!SubStr(1,0)
SubStr(vText, vIsV1-n) ;two-way compatible


Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



==================================================

>>>binary data
>>NumGet/NumPut
>>VarSetCapacity
>>(also: StrGet/StrPut)

[LIMIT] NumGet/NumPut: There is no recommended example function for moving memory, use RtlMoveMemory (DllCall).
[WARNING] NumGet/NumPut: For NumGet/NumPut the default parameter used to be UInt, it is now UPtr.
[NOTE] NumGet/NumPut: Read/write numbers in little endian form, e.g. 0x01020304 gets written as 0x04030201.

Code: [Select all] [Download] GeSHi © Codebox Plus

q:: ;move memory
vData1 := "ABCDE"
vData2 := "abcde"
vSize := 4
;note: RtlMoveMemory parameter order is: 'dest, source' [NOT 'source, destination']
DllCall("kernel32\RtlMoveMemory", Ptr,&vData2, Ptr,&vData1, UPtr,vSize)
MsgBox, % vData2
return


Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



==================================================

>>>dates
>>DateAdd/DateDiff
>>FormatTime
>>(also: A_Now, A_NowUTC, A_MSec, A_TickCount)

[WARNING] FormatTime:

Code: [Select all] [Download] GeSHi © Codebox Plus

FormatTime, vWDay, % vDate, WDay
gives 2 even when the date is invalid.

The Winapi uses 2 main time structures:
FILETIME, intervals since 01/01/1601, 1 interval = 100 nanoseconds = 0.1 microseconds. 1 second = 10000000 intervals. 1 millisecond = 10000 intervals.
SYSTEMTIME, 'friendly', Y/M/WDay/D/H/M/S/MS
GetLocalTime (local time as SYSTEMTIME)
GetSystemTime (UTC time as SYSTEMTIME)
(no handy function?) (local time as FILETIME)
GetSystemTimeAsFileTime (UTC time as FILETIME)
Time Functions (Windows)
https://msdn.microsoft.com/en-us/library/windows/desktop/ms725473(v=vs.85).aspx

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



==================================================

>>>Internet
>>Download (previously: UrlDownloadToFile)

>>>mathematics
>>Abs
>>ASin/ACos/ATan
>>Ceil/Round/Floor
>>Exp/Ln/Log
>>Format
>>Mod
>>Random
>>Sin/Cos/Tan
>>Sqrt

[WARNING] Mod: In theory the Mod function could be used to truncate a number to n decimal places, however it uses a curious definition of Mod.
[NOTE] Mod: If the dividend is negative, the output is negative.
[NOTE] Random: To return a random integer, both range values should be integers, otherwise at least one range value should have a decimal point.

Mod function returning wrong value? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=14&t=29762

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



See 'FORMAT FUNCTION EXAMPLES' at:
jeeswg's characters tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=26486

==================================================

>>>keyboard/mouse
>>BlockInput/SendXXX (also: ControlClick, ControlSend)
>>Click/MouseXXX (also: A_CaretX/A_CaretY, A_Cursor)
>>GetKeyXXX/Hotkey/Input/KeyWait
>>(also: CoordMode, A_CoordModeXXX, SetXXX)

[WARNING] A_CaretX/A_CaretY: don't work correctly when multiple characters are selected.
[LIMIT] Hotkey: Not all hotkeys can be defined: Fn key, reserved Windows hotkeys, three-key hotkeys, not every key can act as a modifier key. LAlt can cause issues e.g. with menu bars.
[LIMIT] Hotkey: There is no 'Hotstring' command to create hotstrings dynamically (cf. Hotkey command).
[LIMIT] Hotkey: Not all hotstrings containing a colon (in the abbreviation/output) are possible.
[NOTE] Hotkey: A semicolon hotkey: '`;::' or 'SC027::', a ctrl+semicolon hotkey: '^;::' or '^SC027::'.
[NOTE] Click: Click's parameters can make it awkward to use.
[LIMIT] ControlSend: is a bit unreliable.
[NOTE] ControlSend: If ControlSend by itself doesn't work, sometimes doing a prior ControlFocus, before the ControlSend, does work. Note: using ControlFocus on an inactive window, does not mean that the current active window will lose focus.
[WARNING] ControlClick: is a bit unreliable, e.g. test on MS Paint, it can send clicks to all points between the current cursor position and the specified point, like dragging the mouse would.
[NOTE] SendXXX: Be aware of the {Raw} option, to send text, and avoid treating special characters like +^#!{} differently.
[NOTE] SendXXX: Be aware that sending CRLF (i.e. '`r`n' in AutoHotkey) will send 2 enters, not one.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



==================================================

>>>AutoHotkey control flow statements
>>Break/Continue
>>For/Loop/Until/While
>>Gosub/Goto
>>If/Else
>>Return
>>Throw
>>Try/Catch/Finally

[LIMIT] Break/Continue/Return: You cannot use Break/Continue/Return in a multi-statement expression, e.g. not possible: oMyObj := "", return
[WARNING] Loop: File loops do not handle long filenames.
[LIMIT] Loop: Registry loops return keys and values in reverse alphabetical order.
[LIMIT] Loop: There is no recommended example in the documentation for a traditional For loop function.

[traditional for loop via functions][for i = a to b (step c)]
Traditional For loop (i.e., step through a sequence) - Suggestions - AutoHotkey Community
https://autohotkey.com/board/topic/71225-traditional-for-loop-ie-step-through-a-sequence/

[traditional for loop via objects][for i = a to b (step c)]
For loop question - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/66916-for-loop-question/#entry423515
enum type and while loop - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/78869-enum-type-and-while-loop/

==================================================

>>>AutoHotkey main window menu items
>>Reload/Edit/Pause/Suspend/ExitApp
>>ListLines/ListVars/ListHotkeys/KeyHistory

[LIMIT] ListXXX/KeyHistory: The 'ListXXX'/'KeyHistory' information cannot be retrieved programmatically:
[WARNING] Reload: When the Reload command is used, lines underneath it can be still be executed (unlike with 'return' or 'Exit'), therefore it is recommended to put a 'return' line underneath it.

[AutoHotkey script information direct to variable]
ScriptInfo(): Get ListLines/ListVars/ListHotkeys/KeyHistory text - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=9656
[get variable text from other scripts]
DebugVars - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=24984
[get ScriptInfo() from other scripts]
test whether another script's hotkeys are still working (trigger hotkeys in another script) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=27839

==================================================

>>>AutoHotkey modes/settings
>>CoordMode/DetectHiddenXXX/SetXXX/StringCaseSense
>>Critical/Thread
>>(also: #NoTrayIcon, #UseHook, A_IsAdmin)

[WARNING/LIMIT] DetectHiddenWindows/StringCaseSense: In functions, if you change the setting for DetectHiddenWindows or StringCaseSense, you should change it back again before the function returns.
[WARNING] DetectHiddenWindows: 'bug'.
[NOTE] SetRegView: Be aware of the differences between the x64/x32 versions of the registry. Basically on x64 PCs, there are sometimes special x32 registry keys called Wow6432Node, for use with x32 programs.
[NOTE] #UseHook: makes some hotkeys that would work on Admin windows, no longer work.

DetectHiddenWindows bug? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=14&t=30010

==================================================

>>>AutoHotkey itself (further commands/functions)
>>EnvGet/EnvSet
>>Exit
>>Func
>>IsByRef/IsFunc/IsLabel
>>OnClipboardChange/OnExit/OnMessage
>>OutputDebug
>>RegisterCallback
>>SetTimer
>>Sleep
>>(also: #Include, #Persistent, #SingleInstance, A_Args)

[LIMIT] #Include: has limited flexibility e.g. you cannot use A_Desktop.
[NOTE] Exit: On a 'return' control flow statement, the script will return to the last sub (if any) that it came from, but with an 'Exit' command, the thread is ended immediately.

#SingleInstance options:
- #SingleInstance [force|ignore|off]
- force (default AHK v2): terminate existing instance, start new instance
- ignore: if another instance exists, do nothing, else, start new instance (e.g. useful to avoid interrupting downloads)
- off: start new instance (alongside other existing instances)
- (blank) (default AHK v1): if another instance exists, user is prompted to 'force' OR 'ignore', else, start new instance (in AHK v2, the 'blank' option no longer exists)

- #Persistent: ways to invoke persistence other than via #Persistent:
- hotkeys
- hotstrings
- Gui (even if not executed)
- OnMessage (even if not executed)
- #InstallKeybdHook
- #InstallMouseHook
- BlockInput: MouseMove subcommand (if the script is not already persistent: causes 'temporary persistence' once executed, until Suspend/Hotkey commands)
- Input (if the script is not already persistent: causes persistence once executed)

==================================================

>>>(updated functions)
(functions that have had major changes since AHK v1.0, 'AutoHotkey Basic')

(ahk_exe): specify process name/path, cf. ahk_class/ahk_id/ahk_pid/ahk_group
(A_OSVersion): more OSes added, but it is deprecated
(Icon Support): 'Negative icon numbers may be used to identify a group icon resource within an executable file'
CoordMode: 'Window' preferred over 'Relative' for coordinates relative to the active window.
DllCall: WStr/AStr/UPtr/Ptr introduced ('Str' depends on whether AHK version is Unicode/ANSI)
IniRead/IniWrite/IniDelete: 'Read, write or delete entire sections, or retrieve a list of all section names'
InStr: 'Searches for a given occurrence of a string, from the left or the right'
Loop: Files ('FDR' style) [cf. 'Loop, FilePattern']
Loop: Reg ('RootKey\SubKey' style) [cf. 'Loop, RootKey']
NumGet/NumPut: default type parameter is now UPtr [cf. UInt]
RegRead/RegWrite/RegDelete: 'RootKey\SubKey' style
SoundSet/SoundGet: 'improved support for Windows Vista and later'
SoundSetWaveVolume/SoundGetWaveVolume: 'improved support for Windows Vista and later'
WinGet: get process path via 'ProcessPath'

affected by whether AHK version is Unicode/ANSI:
Chr/Asc/Ord, FileRead/FileAppend, Transform

see also:
AutoHotkey_L New Features
https://autohotkey.com/docs/AHKL_Features.htm
Script Compatibility
https://autohotkey.com/docs/Compat.htm

==================================================

>>>(limits)
- a custom function can have at most 255 parameters
- when defining an object via [], it can have at most 255 keys (more keys can be added later) (StrSplit could be used instead)
- when defining an object via {}, it can have at most 127 keys (more keys can be added later)

see also:
[Variable Capacity and Memory]
Variables and Expressions
https://autohotkey.com/docs/Variables.htm#cap

Code: [Select all] [Download] GeSHi © Codebox Plus

q:: ;range -0x8000000000000000 to 0x7FFFFFFFFFFFFFFF

MsgBox, % 0x7FFFFFFFFFFFFFFF+0 ;9223372036854775807 ;max
MsgBox, % 0x7FFFFFFFFFFFFFFF+1 ;-9223372036854775808 ;wraps around

MsgBox, % -0x8000000000000000+0 ;-9223372036854775808 ;min
MsgBox, % -0x8000000000000000-1 ;9223372036854775807 ;wraps around
return


==================================================

>>>(AutoHotkey v2)
- ClipWait: the function returns 0 if it timed out, otherwise 1.

Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 4 guests