Jump to content
Sign in to follow this  
xtrim

How to lock window state

Recommended Posts

xtrim

Hi,

How do I lock an external(Other program) windows state?

I don't want the user to be able to resize the window. is it possible?

Is it possible also to monitor the window state?

tnx :)

Xtrim

Share this post


Link to post
Share on other sites
Andreik

@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

Share this post


Link to post
Share on other sites
JoHanatCent

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)

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.