Jump to content

How to lock window state


xtrim
 Share

Recommended Posts

@SW_LOCK is a macro that allow you to lock a window (lock = prevent window paint in this case). To make a window unresizable depends by window style. For example a window with style $WS_SIZEBOX is unresizable. Try this little example after you open Notepad.

#include <WinAPI.au3>
Const $GWL_STYLE = -16
Const $WS_SIZEBOX = 262144

$HWND = WinGetHandle("Untitled - Notepad")
$STYLE = _WinAPI_GetWindowLong($HWND,$GWL_STYLE)
If BitAND($STYLE,$WS_SIZEBOX) = $WS_SIZEBOX Then
    _WinAPI_SetWindowLong($HWND,$GWL_STYLE,BitXOR($STYLE,$WS_SIZEBOX))
EndIf

Before run this script Notepad window should be resizable. After you run the script Notepad window will not have anymore $WS_SIZEBOX style.

When the words fail... music speaks.

Link to comment
Share on other sites

Is it possible also to monitor the window state?

From the help window:

; Check if a new notepad window is minimized
$state = WinGetState("[CLASS:Notepad]", "")

; Is the "minimized" value set?
If BitAnd($state, 16) Then
    MsgBox(0, "Example", "Window is minimized")
EndIf

or

$sAutoItPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir")
Run(@WindowsDir & "\HH.exe " & $sAutoItPath & "\AutoIt3.chm::/html/functions/WinGetState.htm", "", @SW_MAXIMIZE)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...