-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAHKL_Features.htm
224 lines (201 loc) · 16.8 KB
/
AHKL_Features.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE HTML>
<html lang="ru">
<head>
<title>AutoHotkey_L New Features | AutoHotkey</title>
<meta name="description" content='Learn the new features added in the AutoHotkey_L branch of AutoHotkey development, now simply known as "AutoHotkey 1.1".' />
<meta name="ahk:equiv-v2" content="index.htm" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="static/theme.css" rel="stylesheet" type="text/css" />
<script src="static/content.js" type="text/javascript"></script>
</head>
<body><h1>AutoHotkey_L New Features</h1>
<p>This document describes features added in the AutoHotkey_L branch of AutoHotkey development, now simply known as "AutoHotkey 1.1".</p>
<p class="warning"><strong>Caution:</strong> This document has been neglected in recent years and may be missing some of the more recent changes.</p>
<h2 id="flow">Control Flow</h2>
<table class="info">
<tr>
<th>Feature</th>
<th abbr="Descr">Description</th>
</tr>
<tr><td><a href="lib/Break.htm">Break <i>LoopLabel</i></a></td><td>Break out of a loop or any number of nested loops.</td></tr>
<tr><td><a href="lib/Continue.htm">Continue <i>LoopLabel</i></a></td><td>Continue a loop, even from within any number of nested loops.</td></tr>
<tr><td><a href="lib/For.htm">For <i>x</i>,<i>y</i> in <i>z</i></a></td><td>Loop through the contents of an object.</td></tr>
<tr><td><a href="lib/Until.htm">Loop Until</a></td><td>Loop until a condition is true. Applicable to any type of Loop.</td></tr>
<tr><td><a href="lib/Try.htm">Try</a>...<a href="lib/Catch.htm">Catch</a>...<a href="lib/Finally.htm">Finally</a></td><td>Provides structured exception handling.</td></tr>
<tr><td><a href="lib/Throw.htm">Throw</a></td><td>Throws an exception.</td></tr>
</table>
<h2 id="commands">Commands</h2>
<table class="info">
<tr>
<th>Feature</th>
<th abbr="Descr">Description</th>
</tr>
<tr><td><a href="lib/FileEncoding.htm">FileEncoding</a></td><td>Sets the default encoding for <a href="lib/FileRead.htm">FileRead</a>, <a href="lib/FileReadLine.htm">FileReadLine</a>, <a href="lib/LoopReadFile.htm">Loop Read</a>, <a href="lib/FileAppend.htm">FileAppend</a>, and <a href="lib/FileOpen.htm">FileOpen()</a>.<br><i>See also:</i> <a href="#enc">Text Encodings</a></td></tr>
<tr><td><a href="lib/Gui.htm">Gui</a></td><td>See <a href="#GUI_Enhancements">GUI Enhancements</a> below.</td></tr>
<tr><td><a href="lib/IniRead.htm">IniRead</a>/<a href="lib/IniWrite.htm">Write</a>/<a href="lib/IniDelete.htm">Delete</a></td><td>Read, write or delete entire sections, or retrieve a list of all section names.</td></tr>
<tr><td><a href="lib/Menu.htm#MenuIcon">Menu, Icon</a></td><td>Sets or removes a menu item's icon.</td></tr>
<tr><td><a href="lib/Run.htm">Run</a></td><td><a href="Compat.htm#Run">Improvements</a> were made to the way parameters are parsed.</td></tr>
<tr><td><a href="lib/Send.htm#Unicode">SendInput {U+nnnn}</a></td><td>Sends a Unicode character. Unicode characters may be used directly in Unicode builds.</td></tr>
<tr><td><a href="lib/SendLevel.htm">SendLevel</a></td><td>Controls which artificial keyboard and mouse events are ignored by hotkeys and hotstrings.</td></tr>
<tr><td><a href="lib/SetFormat.htm">SetFormat, IntegerFast, h|H</a></td><td>Set lower-case or upper-case hexadecimal format.</td></tr>
<tr><td><a href="lib/SetRegView.htm">SetRegView, RegView</a></td><td>Allows registry commands in a 32-bit script to access the 64-bit registry view and vice versa.</td></tr>
<tr><td><a href="lib/Transform.htm#HTML">Transform, HTML</a></td><td>Perform code page or HTML transformations.</td></tr>
<tr><td><a href="lib/WinGet.htm#ProcessPath">WinGet, ..., ProcessPath</a></td><td>Retrieves the full path and name of the process that owns a given window.</td></tr>
</table>
<h2 id="directives">Directives</h2>
<table class="info">
<tr>
<th>Feature</th>
<th abbr="Descr">Description</th>
</tr>
<tr><td><a href="lib/_If.htm">#If <i>expression</i></a></td><td>Similar to <a href="lib/_IfWinActive.htm">#IfWinActive</a>, but for arbitrary expressions.</td></tr>
<tr><td><a href="lib/_IfTimeout.htm">#IfTimeout</a></td><td>Sets the maximum time that may be spent evaluating a single #If expression.</td></tr>
<tr><td><a href="lib/_MenuMaskKey.htm">#MenuMaskKey</a></td><td>Changes which key is used to mask Win or Alt keyup events.</td></tr>
<tr><td><a href="lib/_Include.htm">#Include <Lib></a></td><td>Includes a script file from a function library folder.</td></tr>
<tr><td><a href="lib/_InputLevel.htm">#InputLevel</a></td><td>Controls which artificial keyboard and mouse events are ignored by hotkeys and hotstrings.</td></tr>
<tr><td><a href="lib/_Warn.htm">#Warn</a></td><td>Enables or disables warnings for selected conditions that may be indicative of developer errors.</td></tr>
</table>
<h2 id="functions">Functions</h2>
<table class="info">
<tr>
<th>Feature</th>
<th abbr="Descr">Description</th>
</tr>
<tr><td><a href="lib/ComObjActive.htm">ComObj...</a> --<br>ComObjActive<br>ComObjEnwrap/Unwrap<br>ComObjParameter<br>ComObjType</td><td><br>Retrieves a registered COM object.<br>Wraps/unwraps a COM object.<br>Wraps a value and type to pass as a parameter.<br>Retrieves a COM object's type information.</td></tr>
<tr><td><a href="lib/ComObjArray.htm">ComObjArray</a></td><td>Creates a SAFEARRAY for use with COM.</td></tr>
<tr><td><a href="lib/ComObjConnect.htm">ComObjConnect</a></td><td>Connects a COM object's event sources to functions with a given prefix.</td></tr>
<tr><td><a href="lib/ComObjCreate.htm">ComObjCreate</a></td><td>Creates a COM object.</td></tr>
<tr><td><a href="lib/ComObjError.htm">ComObjError</a></td><td>Enables or disables notification of COM errors.</td></tr>
<tr><td><a href="lib/ComObjFlags.htm">ComObjFlags</a></td><td>Retrieves or changes flags which control a COM wrapper object's behaviour.</td></tr>
<tr><td><a href="lib/ComObjGet.htm">ComObjGet</a></td><td>Returns a reference to an object provided by a COM component.</td></tr>
<tr><td><a href="lib/ComObjQuery.htm">ComObjQuery</a></td><td>Queries a COM object for an interface or service.</td></tr>
<tr><td><a href="lib/ComObjType.htm">ComObjType</a></td><td>Retrieves type information from a COM object.</td></tr>
<tr><td><a href="lib/ComObjValue.htm">ComObjValue</a></td><td>Retrieves the value or pointer stored in a COM wrapper object.</td></tr>
<tr><td><a href="lib/Throw.htm#Exception">Exception</a></td><td>Creates an exception object for <a href="lib/Throw.htm">Throw</a> (also provides limited access to the call stack).</td></tr>
<tr><td><a href="lib/FileOpen.htm">FileOpen</a></td><td>Provides object-oriented file I/O.</td></tr>
<tr><td><a href="lib/Func.htm#Func">Func</a></td><td>Retrieves a <a href="Objects.htm#Function_References">reference</a> to a function.</td></tr>
<tr><td><a href="lib/GetKey.htm">GetKeyName/VK/SC</a></td><td>Retrieves the name or text, virtual key code or scan code of a key.</td></tr>
<tr><td><a href="lib/InStr.htm">InStr</a></td><td>Searches for a given <em>occurrence</em> of a string, from the left or the right.</td></tr>
<tr><td><a href="lib/IsByRef.htm">IsByRef</a></td><td>Determines whether a ByRef parameter was supplied with a variable.</td></tr>
<tr><td><a href="Objects.htm">IsObject</a></td><td>Determines whether a value is an object.</td></tr>
<tr><td><a href="lib/StrPut.htm">StrPut</a> / <a href="lib/StrGet.htm">StrGet</a></td><td>Copies a string to or from a memory address, optional converting it between code pages.</td></tr>
<tr><td><a href="lib/Trim.htm">Trim</a></td><td>Trims certain characters from the beginning and/or end of a string.</td></tr>
<tr><td><a href="misc/RegExCallout.htm">RegEx (?C<i>Num</i>:<i>Func</i>)</a></td><td>Calls a function during evaluation of a regex pattern.</td></tr>
<tr><td><a href="#Function_Libraries">Function Libraries</a></td><td>New "local library" and <code>#Include <LibName></code>.</td></tr>
<tr><td><a href="Functions.htm#Variadic">Variadic Functions</a></td><td>Functions may accept a variable number of parameters via an array.</td></tr>
<tr><td><a href="#Static">Static Initializers</a></td><td>Static variables can now be initialized using any expression.</td></tr>
</table>
<h2 id="objects">Objects</h2>
<table class="info">
<tr>
<th>Feature</th>
<th abbr="Descr">Description</th>
</tr>
<tr><td><a href="Objects.htm">General</a></td><td>Behaviour and usage of objects in general.</td></tr>
<tr><td><a href="Objects.htm#Arrays">Object</a></td><td>Associative arrays which can be extended with other functionality.</td></tr>
<tr><td><a href="lib/Enumerator.htm">Enumerator</a></td><td>Allows items in a collection to be enumerated.</td></tr>
<tr><td><a href="lib/File.htm">File</a></td><td>Provides an interface to access a file. <a href="lib/FileOpen.htm">FileOpen()</a> returns an object of this type.</td></tr>
<tr><td><a href="lib/Func.htm">Func</a></td><td>Represents a user-defined or built-in function which can be called by the script.</td></tr>
<tr><td>ComObject</td><td>See ComObj functions above.</td></tr>
</table>
<h2 id="vars">Variables</h2>
<table class="info">
<tr>
<th>Feature</th>
<th abbr="Descr">Description</th>
</tr>
<tr><td>A_Is64bitOS</td><td>Contains 1 (true) if the OS is 64-bit or 0 (false) if it is 32-bit.</td></tr>
<tr><td>A_IsUnicode</td><td>In Unicode builds, this variable contains 1 (<i>true</i>). In ANSI builds it is not defined, so is effectively <i>false</i>.</td></tr>
<tr><td>A_FileEncoding</td><td>Contains the default encoding for various commands; see <a href="lib/FileEncoding.htm">FileEncoding</a>.</td></tr>
<tr><td>A_OSVersion</td><td>Supports Windows 7 and Windows 8; see <a href="Variables.htm#OSVersion">A_OSVersion</a>.</td></tr>
<tr><td>A_PriorKey</td><td>The name of the last key which was pressed prior to the most recent key-press or key-release ... <a href="Variables.htm#PriorKey">(More)</a></td></tr>
<tr><td>A_PtrSize</td><td>Contains the size of a pointer, in bytes. This is either 4 (32-bit) or 8 (64-bit).</td></tr>
<tr><td>A_RegView</td><td>The current registry view as set by <a href="lib/SetRegView.htm">SetRegView</a>.</td></tr>
<tr><td>A_ScriptHwnd</td><td>The unique ID (HWND/handle) of the script's hidden main window.</td></tr>
</table>
<h2 id="types">Datatypes</h2>
<table class="info">
<tr>
<th>Feature</th>
<th abbr="Descr">Description</th>
</tr>
<tr><td><a href="lib/DllCall.htm#ptr">Ptr</a></td><td>Equivalent to <i>Int</i> in 32-bit builds and <i>Int64</i> in 64-bit builds. Supported by <a href="lib/DllCall.htm">DllCall()</a>, <a href="lib/NumPut.htm">NumPut()</a> and <a href="lib/NumGet.htm">NumGet()</a>.</td></tr>
<tr><td><a href="lib/DllCall.htm#astr">AStr</a>, <a href="lib/DllCall.htm#astr">WStr</a></td><td>Supported only by <a href="lib/DllCall.htm">DllCall()</a>; see <a href="Compat.htm">Script Compatibility</a>.</td></tr>
</table>
<h2 id="unicode">Unicode</h2>
<table class="info">
<tr>
<th>Feature</th>
<th abbr="Descr">Description</th>
</tr>
<tr><td><a href="Compat.htm">Compatibility</a></td><td>How to deal with Unicode in DllCall(), etc.</td></tr>
<tr><td><a href="Scripts.htm#cp">Script Files</a></td><td>Using Unicode in script files.</td></tr>
<tr><td><a href="lib/Send.htm#Unicode">SendInput</a></td><td>Using Unicode with SendInput.</td></tr>
</table>
<h2 id="other">Other</h2>
<table class="info">
<tr>
<th>Feature</th>
<th abbr="Descr">Description</th>
</tr>
<tr><td><a href="misc/WinTitle.htm#ahk_exe">ahk_exe</a></td><td>Windows can be identified by the name or path of the process (EXE file) which owns them.</td></tr>
<tr><td><a href="Scripts.htm#idebug">Debugging</a></td><td>Interactive debugging features (line by line execution etc.).</td></tr>
<tr><td><a href="#Error_Handling">Error Handling</a></td><td>Try/catch/throw and increased usefulness for A_LastError.</td></tr>
<tr><td><a href="#GUI_Enhancements">GUI Enhancements</a></td><td>Various enhancements to the Gui command and related.</td></tr>
<tr><td><a href="#icons">Icon Support</a></td><td>Resource identifiers and improved support for various icon sizes.</td></tr>
<tr><td><a href="Compat.htm">Other Changes</a></td><td>Changes affecting script compatibility.</td></tr>
<tr><td><a href="AHKL_ChangeLog.htm">Version History</a></td><td>History of AutoHotkey_L revisions.</td></tr>
</table>
<h2 id="Error_Handling">Error Handling</h2>
<p>Many commands support using <a href="lib/Try.htm">try</a>/<a href="lib/Catch.htm">catch</a> instead of ErrorLevel for error handling. For example:</p>
<pre class="NoIndent">try
{
FileCopy, file1.txt, C:\folder
FileDelete, C:\folder\old.txt
}
catch
MsgBox An error occured!</pre>
<p>Additionally, the following commands now set <a href="Variables.htm#LastError">A_LastError</a> to assist with debugging: FileAppend, FileRead, FileReadLine, FileDelete, FileCopy, FileMove, FileGetAttrib/Time/Size/Version, FileSetAttrib/Time, FileCreateDir, RegRead, RegWrite, RegDelete.</p>
<h2 id="Function_Libraries">Function Libraries</h2>
<p>In addition to the user library in <code>%A_MyDocuments%\AutoHotkey\Lib</code> and standard library in the AutoHotkey directory, functions may be auto-included from the "local library" which resides in <code>%A_ScriptDir%\Lib</code>. For more information, see <a href="Functions.htm#lib">Libraries of Functions</a>.</p>
<p><a href="lib/_Include.htm">#Include <LibName></a> explicitly includes a library file which may be located in any one of the function libraries.</p>
<h2 id="GUI_Enhancements">GUI Enhancements</h2>
<p>A number of enhancements have been made to the <a href="lib/Gui.htm">Gui</a> command and related:</p>
<ul>
<li>A <a href="lib/Gui.htm#MultiWin">name or HWND</a> can be used instead of a number between 1 and 99 when referring to a GUI.</li>
<li><a href="lib/Gui.htm#New">Gui, New</a> creates a new anonymous GUI.</li>
<li>Any number of named or anonymous GUIs can be created.</li>
<li>New GUI options: <a href="lib/Gui.htm#GuiHwndOutputVar">+Hwnd<em>OutputVar</em></a>, <a href="lib/Gui.htm#Parent">+Parent<em>GUI</em></a></li>
<li>A GUI's owner can be any arbitrary window: <a href="lib/Gui.htm#Owner">+Owner<em>%HWND%</em></a>.</li>
<li><a href="lib/Gui.htm#fontq">Gui, Font</a> can control anti-aliasing of text.</li>
<li><a href="lib/GuiControls.htm#ActiveX">ActiveX controls</a> such as the Internet Explorer WebBrowser control are supported.</li>
<li><a href="lib/GuiControlGet.htm#Name">GuiControlGet, <em>OutputVar</em>, Name</a> gets the name of the variable associated with a GUI control.</li>
<li>Keyboard accelerators such as <kbd>Ctrl</kbd>+<kbd>O</kbd> are supported automatically when used in <a href="lib/Gui.htm#Menu">Gui menus</a>.</li>
<li><a href="lib/Gui.htm#fontq">Font quality</a> can be controlled by the Font sub-command.</li>
</ul>
<h2 id="Static">Static Variables</h2>
<p>Static variables can now be initialized using any expression. For example:</p>
<pre>Sleep 500
MsgBox % Time() "ms since the script started."
Time() {
static Tick := A_TickCount
return A_TickCount - Tick
}</pre>
<h2 id="enc">Text Encodings</h2>
<p><a href="lib/FileRead.htm">FileRead</a>, <a href="lib/FileReadLine.htm">FileReadLine</a>, <a href="lib/LoopReadFile.htm">Loop Read</a> and <a href="lib/FileAppend.htm">FileAppend</a> support the majority of Windows-supported text encodings, not just the system default ANSI code page. <a href="lib/FileEncoding.htm">FileEncoding</a> can be used to set the default encoding, which can be overridden for FileRead and FileAppend as follows:</p>
<pre class="Syntax">
<span class="func">FileRead</span>, OutputVar, *P<i>nnn</i> Filename
<span class="func">FileAppend</span> <span class="optional">, Text, Filename, Encoding</span>
</pre>
<p>While <i>nnn</i> must be a numeric <a href="https://learn.microsoft.com/windows/win32/intl/code-page-identifiers">code page identifier</a>, <i>Encoding</i> follows the same format as <a href="lib/FileEncoding.htm">FileEncoding</a>.</p>
<p><b>See also:</b> <a href="Compat.htm#FileRead">Script Compatibility</a></p>
<h2 id="Variadic">Variadic Functions and Function-Calls</h2>
<p><a href="Functions.htm#Variadic">Variadic functions</a> can receive a variable number of parameters via an array, while <a href="Functions.htm#VariadicCall">variadic function-calls</a> can be used to pass a variable number of parameters to a function.</p>
<h2 id="icons">Improvements to Icon Support</h2>
<h3 id="Unusual_Sizes">Unusual Sizes</h3>
<p>Icon resources of any size supported by the operating system may be extracted from executable files. When multiple sized icon resources exist within an icon group, the most appropriate size is used. Prior to revision 17, an arbitrary icon resource was selected by the system, scaled to the system large icon size, then scaled back to the requested size.</p>
<h3 id="Resource_Identifiers">Resource Identifiers</h3>
<p>Negative icon numbers may be used to identify a group icon resource within an executable file. For example, the following sets the tray icon to the default icon used by ahk files:</p>
<pre>Menu, Tray, Icon, %A_AhkPath%, -160</pre>
</body></html>