Home > Language Reference > Windows Management Functions > UseWindow


The UseWindow function specifies the window to which subsequent keyboard, mouse and menu actions are directed.


Used to bring to foreground/front the specified window so that it may receive keystrokes, mouse clicks and other interactive actions. It includes an automatic synchronization : UseWindow waits until the specified window has been found and brought to foreground before executing next line.


ret=UseWindow(<window_name> [, Noactivate])


<window_name>, string, window name of the window to bring to foreground. Instance number of <window_name> is optional (see the examples below). You can truncate <window_name> to bring to foreground a window whose title starts with the specified characters.

Noactivate, optional keyword. If used, <window_name> does not take the focus. This keyword is generated automatically when Low level Recording mode is used. In this case, the statements following the UseWindow line will activate the window.

Return value

ret, optional numeric return value. If the window has been found within 30 seconds (this default value can be changed using #ActionTimeout), the function returns 0. If the function fails, the return value is a nonzero value (see Window Functions Error Codes).


Note that in Recording mode, a UseWindow statement is generated each time the target window changes.

During execution, if the target window is minimized, the UseWindow automatically restores it and activates it (unless NoActivate keyword is used).

If #ActionTimeout has been set to a value lower or equal than 10, only an exact window name match is used.

See also



UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad", 1)

Result = UseWindow(win$)

UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad", 1)
'Child window NOTEPAD , file "Untitled" opened, instance 1

UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad")
'Child window NOTEPAD , file "Untitled" opened, first instance found

'Child window NOTEPAD , any file opened, instance 1