WinActivate (statement)

Syntax

WinActivate [window_name$ | window_object] [,timeout]

Description

Activates the window with the given name or object value.

Comments

The WinActivate statement requires the following parameters:

 

Parameter

Description

 

window_name$

String containing the name that appears on the desired application's title bar. Optionally, a partial name can be used, such as "Word" for "Microsoft Word."

A hierarchy of windows can be specified by separating each window name with a vertical bar (|), as in the following example:

  WinActivate "Notepad|Find"

In this example, the top-level windows are searched for a window whose title contains the word "Notepad." If found, the windows owned by the top level window are searched for one whose title contains the string "Find."

 

window_object

HWND object specifying the exact window to activate. This can be used in place of the window_name$ parameter to indicate a specific window to activate.

 

timeout

Integer specifying the number of milliseconds for which to attempt activation of the specified window. If not specified (or 0), then only one attempt will be made to activate the window. This value is handy when you are not certain that the window you are attempting to activate has been created.

 

If window_name$ and window_object are omitted, then no action is performed.

Example

This example runs the clock.exe program by activating the Run File dialog box from within Program Manager.

Sub Main()

  WinActivate "Program Manager"

  Menu "File.Run"

  WinActivate "Program Manager|Run"

  SendKeys "clock.exe{ENTER}"

End Sub

See Also

AppActivate (statement).

More information

W