WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: cssyphus on August 22, 2022, 05:26:31 AM

Title: Tracking a changing window title
Post by: cssyphus on August 22, 2022, 05:26:31 AM
I need to keep track of a changing window title.

First, I get a handle to the window using hMyWin = winIdGet("the window I want")

After that, I check using if isDefined(hMyWin) . . .

But how can I query the window title for that handle, other than switching to that window and using something like currWinTitle = winGetActive()?

Is there a way to query that window title in the background - i.e. without switching the focus to that window?

I am hoping there might be a command like

currWinTitle = winTitle(hMyWIn)

I should know the answer, but am having a memory brown out on this matter.

Age.. belier of the adage "that wot don't kill us makes us stronger."

Title: Re: Tracking a changing window title
Post by: td on August 22, 2022, 07:12:42 AM
There are several ways to obtain the title of a window in WinBatch. One approach is to use the Control Manager's cWindInfo function. Of course, you also need to use the WIL WinIdConvert function to change the Window ID to a raw handle first.
Title: Re: Tracking a changing window title
Post by: cssyphus on August 22, 2022, 09:54:31 AM
That did the trick, thanks Tony


_win = `Window I wana get`
AddExtender(`C:\Program Files (x86)\WinBatch\System\wwctl44i.dll`)
if winExist(_win)
_hWin = winIdGet(_win)
_hhWin = cWinIDConvert(_hWin)
_winTitle = cWndInfo(_hhWin, 0)
message(``, _winTitle)
endif
Title: Re: Tracking a changing window title
Post by: td on August 22, 2022, 02:41:43 PM
Note that WIL has its own function called WinIdConvert. You do not need to use the control manager version anymore.