Page 1 of 1
Use OutputVar instead of Built-in Variables \ Script Settings
Posted: 30 May 2021, 20:40
by RobertL
Current:
Code: Select all
dhw := A_DetectHiddenWindows
DetectHiddenWindows On
..
DetectHiddenWindows %dhw%
Suggested:
Code: Select all
DetectHiddenWindows OutputVar
..
DetectHiddenWindows %OutputVar%
reserve switch keyword for command (here is
on/off), otherwise, treated as Output variable name.
Re: Use OutputVar instead of Built-in Variables \ Script Settings
Posted: 01 Jun 2021, 09:03
by Delta Pythagorean
This can be done using a function:
Code: Select all
DetectHiddenWindows("On")
MsgBox, % DetectHiddenWindows()
DetectHiddenWindows("Off")
MsgBox, % DetectHiddenWindows()
DetectHiddenWindows(state = "")
{
old_state := A_DetectHiddenWindows
if (state != "")
{
DetectHiddenWindows, % state
}
return old_state
}
Re: Use OutputVar instead of Built-in Variables \ Script Settings
Posted: 01 Jun 2021, 09:33
by RobertL
@Delta Pythagorean
Thanks.
My original point is to simplify creating build-in variables.
Although not efficient..
Re: Use OutputVar instead of Built-in Variables \ Script Settings
Posted: 01 Jun 2021, 18:19
by Delta Pythagorean
@RobertL
I'm sorry to say but the reason this won't be done is because of two reasons:
- Commands use one of 3 (debatable if the third type is really a type) types of inputs:
- Literals. These are just strings, If you want to do an expression, you can specify a percent sign (%) at the beginning of the parameter followed by a space and the expression.
- Expressions. These are few and far between; they're expressions, you do your math, get and set variables, etc.
- (Debatable) ByRefs. These are parameters where the command looks for a "clean" variable (alphanumeric, underscores, no objects or arrays). They're pretty annoying to work with but one way to work around its stubborness is:
Code: Select all
MyFunc := Func("SearchForMouseInstruction")
SetTimer, % MyFunc, 1000
- This feature isn't very useful to add when it can be circumvented like the example I had given above.