WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: cssyphus on May 11, 2021, 07:16:37 AM

Title: Run program get winId for use in later win_ commands
Post by: cssyphus on May 11, 2021, 07:16:37 AM
Is there a quick way to run() an app, and return a window id that can be later used in other commands such as SendKeysTo() ?

For example, to run('notepad.exe', '') and get a window ID back?
Title: Re: Run program get winId for use in later win_ commands
Post by: td on May 11, 2021, 07:43:56 AM
A quick search of the "Win*" functions in the Consolidated WIL Help file reveals the following:

https://docs.winbatch.com/mergedProjects/WindowsInterfaceLanguage/html/WILLZ_W__035.htm (https://docs.winbatch.com/mergedProjects/WindowsInterfaceLanguage/html/WILLZ_W__035.htm)

There are other functions that can be used in combination to get the same result or you can try and use Roboscripter to write the solution for you. However, it is best to start with the simplest solution first (using WinIdGet.)
Title: Re: Run program get winId for use in later win_ commands
Post by: cssyphus on May 11, 2021, 11:23:33 AM
Ah, okay, so this is a two-part thing.  For some reason, I thought I remembered there was a command that did both - not that it matters, this will work just ducky. And I didn't previously notice that winIdGet() knows to choose the most recently active instance if more than one is running.

You saved me again, Tony, thank you.