Sign in to follow this  
Followers 0

Disable window resize

6 posts in this topic

Posted (edited)

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

Share this post


Link to post
Share on other sites



Posted

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

Share this post


Link to post
Share on other sites

Posted (edited)

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

Share this post


Link to post
Share on other sites

Posted (edited)

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

Share this post


Link to post
Share on other sites

Posted

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(...

Share this post


Link to post
Share on other sites

Posted

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.

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  
Followers 0




  • Recently Browsing   0 members

    No registered users viewing this page.