Home > Language Reference > Windows Management Functions > Focus$

Focus$

The Focus$ function returns the window name of the foreground window.

Usage

Used to acquire dynamically the focused window name. This window name can then be used in a UseWindow statement.  

Syntax

var$=Focus$()

Parameters

None.

Return value

var$, string, name of the foreground window.

See also

Top$

Examples

Shell("notepad")
a$=focus$()
msgbox(a$)


'Difference between Focus$ and Top$
'Launch notepad
Shell("notepad")
'Wait until notepad window is displayed
UseWindow("NOTEPAD.EXE|Notepad|")
'Display the name of the window which has the focus
windows_name$=Focus$()
Msgbox("The function Focus$ returns : "+windows_name$)

'Display the name of the window which is on top
windows_name$=Top$()
Msgbox("The function Top$ returns : "+windows_name$)

'Close the top window in order to exit notepad
CloseWindow(top$())