I'm writing a script which Runs programs, based on program names (with paths, as needed) in a data file.
The script doesn't know the names or types of the programs prior to execution.
However, when I Run a program (using information from the data file), I'm looking for a way to wait until the program starts, then determine the name or class of the resulting main window.
You can use RunShell with the @GETPROCID flag and the WinItemProcId function to obtain a list of Window IDs or titles associated with the process (application.) Once you have the name you can use it to do things like call the WinShow function to restore a window to its "normal" state. Keep in mind the WinShow can't force a window to restore. It all depends on how the program displaying the window is written.
The Consolidated WIL Help file is your friend and you can find more about the function mentioned above there.
Thanks td,
My first try didn't work. The RunShell returned a ProcID, but the WinItemProcID (executed immediately after the RunShell) did not return anything. I found that by adding a TimeDelay(3) in between the RunShell and WinItemProcID, I got the desired result.
Given that I have the ProcID, is there a way to replace the TimeDelay with something more determinate. I suppose I could put the WinItemProcID in a loop, until something appears?
Thanks again.
It kinda depends on the process but to start, check out AppExist in the Consolidated WIL Help file.
Almost forgot to mention the WinWaitExist function as another alternative.