Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Disable window resize


  • Please log in to reply
5 replies to this topic

#1 sbonacina

sbonacina

    Seeker

  • Active Members
  • 17 posts

Posted 23 June 2009 - 02:56 PM

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, 23 June 2009 - 04:14 PM.








#2 picea892

picea892

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 696 posts

Posted 23 June 2009 - 05:02 PM

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


#3 spudw2k

spudw2k

    passionately misinformed

  • Active Members
  • PipPipPipPipPipPip
  • 1,278 posts

Posted 23 June 2009 - 09:48 PM

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, 23 June 2009 - 09:54 PM.


#4 sbonacina

sbonacina

    Seeker

  • Active Members
  • 17 posts

Posted 24 June 2009 - 05:05 AM

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, 24 June 2009 - 05:28 AM.


#5 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,313 posts

Posted 24 June 2009 - 05:13 AM

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.

#6 spudw2k

spudw2k

    passionately misinformed

  • Active Members
  • PipPipPipPipPipPip
  • 1,278 posts

Posted 24 June 2009 - 03:49 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users