I think the UI function could be improved to also include the WinExist call, add an optional timeOut argument, and make the name more descriptive.
Something like this:
Optionally it could be modified to throw an error if the window isn't found or the element is empty. This function can also be reused: if the script detects that function in the macro text, then it doesn't have to include it any more.
Also it doesn't have to depend on a global UIA variable, since it's used only once inside the function, but I guess it's a matter of choice/style whether to let this method be used in any script or not (e.g. the UI function would work in a script that uses cUIA instead of UIA).
I think the UI function could be improved to also include the WinExist call, add an optional timeOut argument, and make the name more descriptive. Something like this:
Optionally it could be modified to throw an error if the window isn't found or the element is empty. This function can also be reused: if the script detects that function in the macro text, then it doesn't have to include it any more. Also it doesn't have to depend on a global UIA variable, since it's used only once inside the function, but I guess it's a matter of choice/style whether to let this method be used in any script or not (e.g. the UI function would work in a script that uses
cUIA
instead ofUIA
).