cWndByWndSpecName

Returns the window handle of a top-level window from the window specification generated using a window’s title.

Syntax:

cWndByWndSpecName( window-title, window-module, child-count [ , child-id...])

Parameters:

(s) window-title Window title name

(s) window-module Window module name.

(i) child-count Number of child windows (must be at least 0 and no greater than 13)

(i) child-id Child window id (minimum 0, maximum 13)

Returns:

(i) window-handle Window handle of specified window.

 

cWndByWndSpecName obtains the window handle of a top-level window from the window specification generated using a window’s title. This function works exactly like cWndByWndSpec except that the window specification contains a window’s title instead of its class name and it uses a window specification generated by cWndGetWndSpecName instead of one generated by cWndGetWndSpec.

To use cWndGetWndSpecName place the components of the window specification in the parameters to the function. The first parameter must contain the window’s title, the second contains the module name, and the third must contain the number of child window ids given in the remaining parameters. These three parameters are always required. The remaining parameters consist of child window ids: one child window id per parameter. The number of ids must correspond to the number given in the child-count or third parameter. If the number of child id parameters does not match the value in the child-count parameter your will get an "Invalid window specification" error. There is a limit of 13 child window parameters. You can use this function on windows with more than 13 child windows but only thirteen child ids can be used to identify the window.

The function returns zero (0), if the specified window is not found.

You can create your own window specification or have Control Manager create one for you by calling the cWndGetWndSpecName function, which is recommended. To obtain a window specification, write a WIL script that simply calls cWndGetWndSpecName with the target window’s handle and save the result. The specification can be saved to the clipboard, to a file or displayed in a message box and hand copied.

Although a window specification eliminates a lot of the uncertainty in obtaining a window’s handle, there is still some chance for error. For example, if you have two instances of the same application running, they will have the same windows specification in most cases. The function resolves ambiguities like this by selecting the specification-matching window that is closest to the top in Z order. The Z order of a window indicates the window's position in a stack of overlapping windows on the Windows desktop. The window at the top of the Z order overlaps all other windows. All other windows overlap the window at the bottom of the Z order.

UAC Notes: attempting to query information about an elevated process may cause the function to error when executed from a restricted user account.

 

Example:

AddExtender("wwctl44i.dll",0,"wwctl64i.dll")

; Find Notepad's Windows handle hwnd = DllHwnd("~Notepad") ; Get the window specification. Spec = cWndGetWndSpecName (hwnd) ; Get the handle by the window specification. hWndSpec = cWndByWndSpecName(%Spec%) ; Make sure the result matches the original handle If hwnd == hWndSpec Then Message("Window Spec is correct", Spec) Else Message("Window Spec is NOT correct", Spec) Exit

See Also:

cSetWndSpecRetry, cWndGetWndSpecName, cWndByWndSpec, cWndByClass, cWndByName, cFindbyClass, cFindByName