Is there a simple way to get the name of the window for a particular window ID? I tried using WinItemizeEx, until I noticed that it is one of the few functions which won't accept a window ID for the partial-window-name parameter. Thanks.
#DEFINEFUNCTION WinID2WinName(id)
; returns the name of the window with a particular id
list = WinItemNameID()
loc = ItemLocate(id,list,"|")
name = ItemExtract(loc-1,list,"|")
Return name
#ENDFUNCTION
Could be combined into a single statement.
fhammer: Nice. Quite natty, in fact.
For the OP: This works by finding the WindowID in the list returned by WinItemNameID(), then returning the item in that list that precedes the found WindowID. Note that this could fail in a perverse case where some window had the same name as the WindowID.
Here's another way that uses functions in the Control Manager extender:
name = cWndInfo(cWinIdConvert(WinId),0)
FWIW, I use cWndInfo() a lot in my code.
Or
hWnd = DllHwnd(WinId)
if hWnd then strTitle = cWndInfo(hWnd, 0)
else strTitle = ''