lexikos wrote:WinSet doesn't update A_LastError. For the sub-commands which don't set ErrorLevel, I think it would be sufficient to consider it a success if the window exists. For efficiency, you could use WinExist() first and pass ahk_id to WinSet.
I see. Regarding WinExist()
, I guess I would need to store the current "LastFound window" first then restore it back before returning. Otherwise the function might interfere with the user's script functionality, in rare cases. Another thing, which is more efficient, passing ahk_id %Hwnd%
or omitting all the window parameters to take advantage of the "LastFound window" feature? The docs says that the script performs better with the latter..
lexikos wrote:Whether for v2 or for this script, Ahk2Exe will need to be extended to parse expressions like FileInstall("Some\Path.ext", ...) if that syntax will be supported. If that was done, this script could use the Win32 resource API to extract the file data.
An alternative would be to have a more general function for extracting resources, and require the script to use the "upcoming" resource directives, but I suppose then you'd need to repeat the resource name/path.
I see. For now I'll just retain the FileCopy
behavior and wait for Ahk2Exe's progress.
lexikos wrote:MinParams is 0 because WinTitle and WinText can be omitted, as in MenuSelect(,, "File", "Open"), which operates on the Last Found Window. That you can't omit the third parameter is only one of many requirements that are enforced at load time for specific commands, but not for the corresponding function (including MenuSelect()). Some checks are only done at load time, and only for args which are not variables/expressions.
Thanks for the confirmation. I'd have to review some of the functions. I think I might have overlooked some aside from MenuSelect()
InputBox in v2 validates its options. There's probably not much need to duplicate the behaviour to that extent, but in this case we can simplify (or at least shorten
) your code and gain validation at the same time. Instead of a parsing loop, we can use a single regex:
Code: Select all
Options := "x0 y0 w100 h100 T10.0 Password*"
Valid := RegExMatch(Options, "i)^\s*(?:(?:X(?<X>\S*)|Y(?<Y>\S*)|W(?<W>\S*)|H(?<H>\S*)|T(?<T>\S*)|(?<P>Password\S?))\s*)*$", _)
I think this is consistent with what v2-alpha accepts. Of course, InputBox in v1 still doesn't support Password*
and you would need to use % _P ? "HIDE" : ""
for the HIDE parameter.
Thanks, applied your suggestion in this commit
. I modified your pattern a little bit to clone v2's strict validation. Added error handling as well for invalid options.