Function Reference


WinClose

Closes a window.

WinClose ( "title" [, "text"] )

Parameters

title The title/hWnd/class of the window to close. See Title special definition.
text [optional] The text of the window to close. Default is an empty string. See Text special definition.

Return Value

Success: 1.
Failure: 0 if window is not found.

Remarks

This function sends a close message to a window, the result depends on the window (it may ask to save data, etc.). To force a window to close, use the WinKill() function. If multiple windows match the criteria, the window that was most recently active is closed.

Related

WinActivate, WinExists, WinKill, WinSetState, WinTitleMatchMode (Option), ProcessClose, WinMove

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    WinWait("[CLASS:Notepad]", "", 10)

    ; Wait for 2 seconds to display the Notepad window.
    Sleep(2000)

    ; Close the Notepad window using the classname of Notepad.
    WinClose("[CLASS:Notepad]")
EndFunc   ;==>Example