_( opt = "" )
StdLib loader.
opt | Space separated list of script options. |
s | Speed, defaults to -1 |
m | Affects how m function works: mm makes it use MsgBox (default), mo OutputDebug, m alone disables it. Anything else will use FileAppend; for instance mout.txt! writes to out.txt file. ! at the end is optional and if present, it will mark the file for deletition on scripts startup. !can be also used with o mode to clear the DebugView log. DebugView will be started if it doesn’t run, make sure its on the system PATH (there will be no error message if Run fails). |
d | Detect hidden windows. |
e | Escape exits the script. Use ea to exit the script only if its window is active. |
w | SetWorkingDir %A_ScriptDir% |
t | Title match mode: t1 (ts), t2 (tc), t3 (te), tr. |
_("s100 d e m") ;set speed to 100ms, detect hiden windows and disable m, exit on ESC. _("mo w tc) ;set m to use OutputDebug, set working directory to A_ScriptDir, set title match mode to c (contain, 2). _("mout.txt!") ;set m to use File out.txt and to clear it each time script is started.
Includes #NoEnv and #SingleInstance force always. Registers global variable _ to contain A_Space.
m( o1 = "~`a", o2 = "~`a", o3 = "~`a", o4 = "~`a", o5 = "~`a", o6 = "~`a", o7 = "~`a", o8 = "~`a" )
Debug function.
o1..o8 | Arguments to display. |
m can use MsgBox (m mode), OutputDebug (o mode) or FileAppend to write messages. See _ function for details. In o mode, all arguments will be joined in single line.
o1.
if (x - m(y) = z) ; Use m inside expressions for debugging.
S( ByRef S, pQ, ByRef o1 = "~`a ", ByRef o2 = "", ByRef o3 = "", ByRef o4 = "", ByRef o5 = "", ByRef o6 = "", ByRef o7 = "", ByRef o8 = "" )
Struct function. With S, you define structure, then you can put or get values from it. It also allows you to create your own library of structures that can be included at the start of the program.
S | Struct definition. First word is struct name followed by : and a space, followed by space separated list of field definitions. Field definition consists of field name, optionally followed by = sign and decimal number representation of offset and type. For instance, “left=4.1” means that field name is “left”, field offset is 4 bytes and field type is 1 (UChar). You can omit field decimal in which case “Uint” is used as default type and offset is calculated from previous one (or it defaults to 0 if it is first field in the list). Precede type number with 0 to make it signed type or with 00 to make it Float or Double. For instance, .01 is “Char” and .004 is Float. S will calculate the size of the struct for you based on the input fields. If you don’t define entire struct (its perfectly valid to declare only parts of the struct you are interested in) you can still define struct size by including = and size after structs name. This allows you to use ! mode later. |
pQ :: StructName[=[Size]]: FieldDef1 FieldDef2 ... FieldDefN FieldDef :: FieldName[=[Def] Def :: offset.[0][0]Type Type :: [0]1 | [0]2 | [0]4 | [0]8 | 004 | 008
S | Pointer to struct data. |
pQ | Query parameter. First word is struct name followed by the mode char and a space, followed by the space separated list of field names. If the first char after struct name is “<” or “)” function will work in Put mode, if char is “>” or “)” it works in “Get” mode. If char is “!” function works in IPut mode (Initialize & Put). For ! to work, you must define entire struct, not just part of it. The difference between < and ( is that < works on binary data contained in S, while ( works on binary data pointed to by S. The same difference applies to > and ) modes. |
o1..o8 | Reference to output variables (Get) or input variables (Put) |
pQ :: StructName[>)<(!]: FieldName1 FieldName2 ... FieldNameN
Otherwise the result contains description of the error.
Define Examples: S("RECT=16: left=0.4 top=4.4 right=8.4 bottom=12.4") ;Define RECT explicitly. S("RECT: left top right bottom") ; Define RECT struct with auto struct size and auto offset increment. Returns 16. The same as above. S("RECT: right=8 bottom") ; Define only 2 fields of RECT struct. Since the fields are last one, ! can be used afterwards. Returns 16. S("RECT: top=4) ; Defines only 1 field of the RECT. Returns 8, so ! can't be used. S("RECT=16: top=4) ; Defines only 1 field of the RECT and overrides size. Returns 16, so ! can be used. S("R: x=.1 y=.02 k z=28.004") ; Define R, size don't care. R.x is UChar at 0, R.y is Short at 1, R.k is Uint at 3 and R.z is Float at 28. S("R=48: x=.1 y=.02 k z=28.004") ; Override struct size. Returns user size (48 in this case). ; This is not the same as above as it states that z is not the last field of the R struct and that actual size is 48. Get & Put Examples: S(b, "RECT< left right", x,y) ; b.left := x, b.right := y (b must be initialized) S(b, "RECT> left right", x,y) ; x := b.left, y := b.right S(b, "RECT! left right", x,y) ; VarSetCapacity(b, SizeOf(RECT)), b.left = x, b.right=y S(b:=&buf,"RECT) left right", x,y) ; *b.left = x, *b.right=y S(b:=&buf,"RECT( left right", x,y) ; x := *b.left , y := *b.right
v( var = "", value = "~`a ", ByRef o1 = "", ByRef o2 = "", ByRef o3 = "", ByRef o4 = "", ByRef o5 = "", ByRef o6 = "" )
Storage function, designed to use as stdlib or copy and enhance.
var | Variable name to retrieve. To get up several variables at once (up to 6), omit this parameter. |
value | Optional variable value to set. If var is empty value contains list of vars to retrieve with optional prefix |
o1 .. o6 | If present, reference to variables to receive values. |
To use multiple storages, copy v function and change its name.
You can choose to initialize storage from additional ahk script containing only list of assignments to storage variables, to do it internally by adding the values to the end of the your own copy of the function, or to do both, by accepting user values on startup, and checking them afterwards. If you use stdlib module without including it directly, just make v.ahk script and put variable definitions there.
Don’t use storage variables that consist only of _ character as those are used to regulate inner working of function.
v(x) ; returns value of x or value of x from v.ahk inside scripts dir. v(x, v) ; set value of x to v and return previous value v("", "x y z", x, y, z) ; get values of x, y and z into x, y and z v("", "prefix_)x y z", x, y, z) ; get values of prefix_x, prefix_y and prefix_z into x, y and z
d( fun, delay = "", a1 = "", a2 = "" )
Delay/Thread function. Thread is not OS thread, but AHK thread.
fun | Function to be executed. |
delay | Delay in ms. |
a1, a2 | Parameters. |
d("fun1", "", 1) ;execute asap in new thread with param 1 d("fun2", 500, "abc") ;execute after 500ms in new thread with param "abc"
StdLib loader.
_( opt = "" )
Debug function.
m( o1 = "~`a", o2 = "~`a", o3 = "~`a", o4 = "~`a", o5 = "~`a", o6 = "~`a", o7 = "~`a", o8 = "~`a" )
Struct function.
S( ByRef S, pQ, ByRef o1 = "~`a ", ByRef o2 = "", ByRef o3 = "", ByRef o4 = "", ByRef o5 = "", ByRef o6 = "", ByRef o7 = "", ByRef o8 = "" )
Storage function, designed to use as stdlib or copy and enhance.
v( var = "", value = "~`a ", ByRef o1 = "", ByRef o2 = "", ByRef o3 = "", ByRef o4 = "", ByRef o5 = "", ByRef o6 = "" )
Timer
t( ByRef v = "~`a " )
Delay/Thread function.
d( fun, delay = "", a1 = "", a2 = "" )
Exits the script with the message.
Fatal( Message, E = 1, ExitCode = "" )