cWndByWndSpec

Returns a window handle based on the window specifications.

Syntax:

cWndByWndSpec(window-class, window-module, child-count [ , child-id...])

Parameters:

(s) window-class Window class 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.

 

Place the components of the window specification in the parameters to the function. The first parameter must contain the window's class name.

The second contains the module name. The module name is the name of the executable or DLL file that is responsible for the window. It does not include the file name's path or extension.

The third parameter 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 cWndGetWndSpec function, which is recommended. To obtain a window specification, write a WIL script that simply calls cWndGetWndSpec 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")
; Look for Win2k's Notepad by its specification.
hWnd = cWndByWndSpec("Notepad", "notepad", 1, 15)
; Success?
If hWnd != 0 Then Message("Found NotePad","")
Else Message("Notepad not found","")
Exit

See Also:

cSetWndSpecRetry, cWndByWndSpecName, cWndGetWndSpec, cWndByClass, cWndByName, cFindbyClass, cFindByName