Sign in to follow this  
Followers 0
Harribo

Check window maximizebox

10 posts in this topic

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

Share this post


Link to post
Share on other sites



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
WEnd

Please 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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by Harribo

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Harribo,

You have not liked any of my other suggestions, so let us see if this one fares better: :idiot:

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

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