Harribo Posted January 20, 2011 Share Posted January 20, 2011 Hi I have a simple question but I keep searching and still I dont have the solution. The question: How can I check if a window has an maximizebox (the square upper right)? greetings Harribo ps. From now on I can be away for 5 days, so it is possible that I can not immediately give an reaction Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 21, 2011 Moderators Share Posted January 21, 2011 Harribo,Just check the overall GUI style and see if the $WS_MAXIMIZEBOX style is included: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <WinAPI.au3> Global $aGUI[3], $aStyle[3] $aGUI[1] = GUICreate("Static", 200, 200, 100, 100) GUISetState() $aGUI[2] = GUICreate("Maximizable", 200, 200, 300, 300, BitOr($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX)) GUISetState() For $i = 1 To 2 $iStyle = _WinAPI_GetWindowLong($aGUI[$i], $GWL_STYLE) ; Get GUI style value If BitAnd($iStyle, $WS_MAXIMIZEBOX) Then ; Check if MaximizeBox is included ConsoleWrite("GUI " & $i & " has a Maximize Box" & @CRLF) Else ConsoleWrite("GUI " & $i & " does NOT have a Maximize Box" & @CRLF) EndIf Next While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndPlease ask if anything is unclear. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Harribo Posted January 26, 2011 Author Share Posted January 26, 2011 .... Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd [/autoit] Please ask if anything is unclear. M23 Thanks! Works like a charm! Could not get that win api clear. Link to comment Share on other sites More sharing options...
Harribo Posted February 2, 2011 Author Share Posted February 2, 2011 (edited) Now that I have checked wheter a window has a maximizebox, how can I check ,if a maximizebox present, if this is disabled or enabled? (I am working on a script which maximizes windows. But certain windows I dont want to maximize. Like those windows without a maximizebox or with maximizebox disabled.) Edited February 2, 2011 by Harribo Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 2, 2011 Moderators Share Posted February 2, 2011 Harribo, You could take another way to solve this - just limit the size of the GUI: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $GUIMINWID = 300, $GUIMINHT = 100;set your restrictions here Global $GUIMAXWID = 800, $GUIMAXHT = 500 GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") $hGUI = GUICreate("Test", 500, 500, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetState() $aPos = WinGetPos($hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_MAXIMIZE WinMove($hGUI, "", $aPos[0], $aPos[1]) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam) $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tagMaxinfo, 7, $GUIMINWID) ; min X DllStructSetData($tagMaxinfo, 8, $GUIMINHT) ; min Y DllStructSetData($tagMaxinfo, 9, $GUIMAXWID ); max X DllStructSetData($tagMaxinfo, 10, $GUIMAXHT ) ; max Y Return 0 EndFunc ;==>WM_GETMINMAXINFO Is that a help? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Harribo Posted February 3, 2011 Author Share Posted February 3, 2011 Harribo, You could take another way to solve this - just limit the size of the GUI: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> [....] max Y Return 0 EndFunc ;==>WM_GETMINMAXINFO Is that a help? I appreciate your code but I really want to check wheter a window has a maximizebox and is dis/en-abled. Maybe you can help me by giving me the procedure or winapi to look for? Thanks for you reply. Link to comment Share on other sites More sharing options...
Harribo Posted February 3, 2011 Author Share Posted February 3, 2011 I figured out that when a window has a maximizebox disabled it is often the case that the window is not resizable. I think it is easier to look for that solution. Link to comment Share on other sites More sharing options...
Harribo Posted February 9, 2011 Author Share Posted February 9, 2011 Really no one?? Is there really no function to check this? Edit: I found this: http://stackoverflow.com/questions/311399/determining-if-the-maximize-button-is-available But I am not expert enough to integrate this into AutoIt3. I tried to edit and add commands to the file WinAPI.au3 in the Include map. Anyone handy with this? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 9, 2011 Moderators Share Posted February 9, 2011 Harribo, You have not liked any of my other suggestions, so let us see if this one fares better: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GUIMenu.au3> $hGUI = GUICreate("Maximize Enabled", 500, 500, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX)) GUISetState() Check_Max() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop WEnd $hGUI = GUICreate("Maximize Disabled") $hMenu = _GUICtrlMenu_GetSystemMenu($hGUI) _GUICtrlMenu_EnableMenuItem($hMenu, $SC_MAXIMIZE, $MF_GRAYED, False) GUISetState() Check_Max() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd Func Check_Max() $hMenu = _GUICtrlMenu_GetSystemMenu($hGUI) $iState = _GUICtrlMenu_GetItemState($hMenu, $SC_MAXIMIZE, False) ConsoleWrite($iState & @CRLF) If BitAnd($iState, 12) Then ConsoleWrite("Maximize Disabled" & @CRLF) Else ConsoleWrite("Maximize Enabled" & @CRLF) EndIf EndFunc Any good? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Harribo Posted February 12, 2011 Author Share Posted February 12, 2011 Harribo, You have not liked any of my other suggestions, so let us see if this one fares better: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GUIMenu.au3> [...] EndIf EndFunc Any good? M23 I really really really appreciate your posts !!! (Convinced now?) I do not work every day on this project so I try to forget sometimes to react in time. But, I tried your code and it unfortenately it does not 100% work. I tested this code with the Windows program mstsc.exe (connect to external desktop). It gives State=0 back when calling _GUICtrlMenu_GetItemState (instead of 12). I have some idea the wrong parameters are passed but did not have time yet to figure it completely out. Soon I will. Much thanks for the code. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now