Function Reference


WinSetOnTop

Change a window's "Always On Top" attribute.

WinSetOnTop ( "title", "text", flag )

Parameters

title The title/hWnd/class of the window to change. See Title special definition.
text The text of the window to change. See Text special definition.
flag Determines whether the window should have the "TOPMOST" flag set.
    $WINDOWS_NOONTOP (0) = remove on top flag
    $WINDOWS_ONTOP (1) = set on top flag

Constants are defined in "AutoItConstants.au3".

Return Value

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

Remarks

Third-party programs which add an "Always On Top" context menu entry might not update their menu entry to reflect the AutoIt-induced change in TOPMOST status.

Related

WinSetState

Example

#include <AutoItConstants.au3>

Example()

Func Example()
        ; Retrieve the handle of the active window.
        Local $hWnd = WinGetHandle("[ACTIVE]")

        ; Set the active window as being ontop using the handle returned by WinGetHandle.
        WinSetOnTop($hWnd, "", $WINDOWS_ONTOP)

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

        ; Remove the "topmost" state from the active window.
        WinSetOnTop($hWnd, "", $WINDOWS_NOONTOP)
EndFunc   ;==>Example