Function Reference


WinSetState

Shows, hides, minimizes, maximizes, or restores a window.

WinSetState ( "title", "text", flag )

Parameters

title The title/hWnd/class of the window to change the state. See Title special definition.
text The text of the window to change the state. See Text special definition.
flag The "show" flag of the executed program:
    @SW_HIDE = Hide window
    @SW_SHOW = Shows a previously hidden window
    @SW_MINIMIZE = Minimize window
    @SW_MAXIMIZE = Maximize window
    @SW_RESTORE = Undoes a window minimization or maximization
    @SW_DISABLE = Disables the window
    @SW_ENABLE = Enables the window

Return Value

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

Remarks

If multiple windows match the criteria, the most recently active window is used.
@SW_MINIMIZE and @SW_MAXIMIZE even work on modal dialog windows.

Related

ControlHide, WinActivate, WinClose, WinFlash, WinGetState, WinKill, WinMinimizeAll, WinMinimizeAllUndo, WinMove, WinSetOnTop

Example

Example()

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

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

        ; Set the state of the Notepad window to "hide".
        WinSetState($hWnd, "", @SW_HIDE)

        ; Wait for 2 seconds.
        Sleep(2000)

        ; Set the state of the Notepad window to "show".
        WinSetState($hWnd, "", @SW_SHOW)

        ; Wait for 2 seconds.
        Sleep(2000)

        ; Close the Notepad window using the handle returned by WinWait.
        WinClose($hWnd)
EndFunc   ;==>Example