Use OutputVar instead of Built-in Variables \ Script Settings

Propose new features and changes
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Use OutputVar instead of Built-in Variables \ Script Settings

Post by RobertL » 30 May 2021, 20:40

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.
我为人人,人人为己?

User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: Use OutputVar instead of Built-in Variables \ Script Settings

Post by Delta Pythagorean » 01 Jun 2021, 09:03

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
}

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat


User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: Use OutputVar instead of Built-in Variables \ Script Settings

Post by RobertL » 01 Jun 2021, 09:33

@Delta Pythagorean
Thanks.
My original point is to simplify creating build-in variables.
Although not efficient..
我为人人,人人为己?

User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: Use OutputVar instead of Built-in Variables \ Script Settings

Post by Delta Pythagorean » 01 Jun 2021, 18:19

@RobertL
I'm sorry to say but the reason this won't be done is because of two reasons:
  1. 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
      
  2. This feature isn't very useful to add when it can be circumvented like the example I had given above.

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat


Post Reply

Return to “Wish List”