Jump to content

Disable window resize


Recommended Posts

Dear all,

I went through the forum and didn't found yet any topic concerning my need.

My company users use a commercial application that I want to be run by an autoit script, because of some display setting that need to be done before running the app.

So I wrote a script that runs this application, this way:

Run ("cmd /C set USER_HOME="& $UserHome &"& .\prog.exe )
WInWaitClose ( "Program Name" )

I would like to lock the size of the application window, so I tried the following:

Opt("GUIResizeMode", 768); no resize
Opt("GUIEventOptions",0)

without any success.

And also this:

$spHandle=WinGetHandle ( "Program Name")
GUICtrlSetResizing($spHandle, $GUI_DOCKSIZE)

But, as far as I understood, all of theese apply to created GUI objects, not to external windows.

Any idea on how to do that?

Thanks a lot for your help

Best regards

STefano

Edited by sbonacina
Link to comment
Share on other sites

I know there must be a better way, but I will give you my 2 cents. Query if the mouse cursor is a size symbol and the wintitle is the application. If it is, block mouse input.

Block mouse input using this

http://www.autoitscript.com/forum/index.ph...showtopic=82650

Global $on=0
while 1
    for $i= 8 to 13
    if $i = MouseGetCursor() and WinGetTitle() = "applicationname" and $on=0 then
    ;call Block mouse input here
        $on=1
    Next
    for $i= 1 to 7
    if $i = MouseGetCursor() and $on=1 then
    ; Remove Block from mouse
        $on=0
    Next
    for $i= 14 to 15
        if $i = MouseGetCursor() and $on=1 then
        $on=0
    ; Remove Block from mouse
    Next
    sleep(50)
WEnd
Link to comment
Share on other sites

This code will remove the Sizebox style from a window.

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

$hWnd = WinGetHandle("Program Name")
$style = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
If BitXOR($style,$WS_SIZEBOX) <> BitOr($style,BitXOR($style,$WS_SIZEBOX)) Then _WinAPI_SetWindowLong($hWnd,$GWL_STYLE,BitXOR($style,$WS_SIZEBOX))
Edited by spudw2k
Link to comment
Share on other sites

Many thanks, spudw2k. That worked fine.

Your hint paved my way to better understand the Window handling.

I went a little bit further and I disabled also the Maximize Box.

To whom it might be of interest, here's the code:

#Include <WinAPI.au3>; to call Windows api specific functions
#include <WindowsConstants.au3>; to include Windows specific constants, such as the Windows Style Values

$newhWnd = WinGetHandle("Program Name")
$style = _WinAPI_GetWindowLong($newhWnd, $GWL_STYLE)

If BitXOR($style,$WS_SIZEBOX,$WS_MAXIMIZEBOX) <> BitOr($style,BitXOR($style,$WS_SIZEBOX,$WS_MAXIMIZEBOX)) Then _WinAPI_SetWindowLong($newhWnd,$GWL_STYLE,BitXOR($style,$WS_SIZEBOX,$WS_MAXIMIZEBOX))
Edited by sbonacina
Link to comment
Share on other sites

Many thanks, spudw2k. That worked fine.

Your hint paved my way to better understand the Window handling.

I went a little bit further and I disabled also the Maximize Box.

To whom it might be of interest, here's the code:

#Include <WinAPI.au3>; to call Windows api specific functions
 #include <WindowsConstants.au3>; to include Windows specific constants, such as the Windows Style Values
 
 $newhWnd = WinGetHandle("Sun xVM VirtualBox")
 $style = _WinAPI_GetWindowLong($newhWnd, $GWL_STYLE)
 
 If BitXOR($style,$WS_SIZEBOX,$WS_MAXIMIZEBOX) <> BitOr($style,BitXOR($style,$WS_SIZEBOX,$WS_MAXIMIZEBOX)) Then _WinAPI_SetWindowLong($newhWnd,$GWL_STYLE,BitXOR($style,$WS_SIZEBOX,$WS_MAXIMIZEBOX))
The BitXOR logic looks very complicated. I think this would do the same

If BitAnd($style,BitOr($WS_SIZEBOX,$WS_MAXIMIZEBOX)) Then
  _WinAPI_SetWindowLong(...
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

The BitXOR logic looks very complicated. I think this would do the same

If BitAnd($style,BitOr($WS_SIZEBOX,$WS_MAXIMIZEBOX)) Then
  _WinAPI_SetWindowLong(...
Agreed, your method is much more efficient.
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...