The documentation for A_DetectHiddenWindows defers to DetectHiddenWindows for details.
When a parameter type is "Boolean", this is a contract stating that an empty string or zero value will be considered
false and any other value will be considered
true. In other words, no value is "non-boolean". We cannot simply break this contract without also bumping the major version; i.e. v3.0.
For v2.1, I have some ideas for allowing portions of a script (i.e. modules) to opt in to changes that would otherwise be backward-incompatible.
If you wish to improve error-detection in the current version, you can wrap the various functions with your own custom functions (or some other interface), or redefine the "built-in" functions and use those.
Code: Select all
BoolInteger(Value) {
if (Value != 0 && Value != 1)
throw (Value is Number ? ValueError : TypeError)("Value must be 0 or 1", -2, Value)
return Value
}
DetectHiddenWindows.DefineProp 'Call', {
Call: (Function, Value) =>
(Func.Prototype.Call)(Function, BoolInteger(Value))
}
MsgBox A_DetectHiddenWindows
DetectHiddenWindows 1
MsgBox A_DetectHiddenWindows
DetectHiddenWindows "off"
This can be optimized.
I would personally only choose to prohibit non-numeric values, due to the legacy of using "Off". However, neither
A_DetectHiddenWindows := "Off" nor
DetectHiddenWindows "Off" ever worked in v1, and
DetectHiddenWindows Off would produce an error in v2 unless you assign a value to
Off, in which case it could work.