Sign in to follow this  
Followers 0
Knight

Modify Window Style of Foreign Window - add minimize button

6 posts in this topic

I have a third party application that launches a window with a title bar but no exit or minimize buttons on it. Is it possible to add these buttons, specifically minimize, to that window with an AutoIt script?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You can't add buttons to an external program GUI, however you could possibly make a separate tool window with buttons to minimize and maximize the GUI. It may even be possible to somehow float an image over the top right hand corner of the original window and click on that. That's a bit too complicated for me though.

Edited by czardas

Share this post


Link to post
Share on other sites

This.

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Constants.au3>

Global $Check = False

$hGui = GuiCreate("Change/UnChange WS_MAXIMIZEBOX",250,30)
$iAction = GuiCtrlCreateButton("Remove WS_MAXIMIZEBOX to Calc",0,0,250,30)
GuiSetState()

Run("Calc.exe")
WinWait("[CLASS:CalcFrame]")
$hWinHandle = WingetHandle("[CLASS:CalcFrame]")
$dwStyle = _WinApi_getwindowlong($hWinHandle, $GWL_STYLE)

While True
    $iMsg = GuiGetMsg()
    Switch $iMsg
        case - 3
            WinClose($hWinHandle)
            Exit
        case $iAction
            If $check = false Then
            _WinAPI_SetWindowLong($hWinHandle, $GWL_STYLE, BitAND($dwStyle, $WS_MAXIMIZEBOX))
            $check = Not $check
        Else
            _WinAPI_SetWindowLong($hWinHandle, $GWL_STYLE, $dwStyle)
            $check = Not $check
        EndIf
    EndSwitch
WEnd

The Bug is because the style changing is a little more complicated, but not too much.

Share this post


Link to post
Share on other sites

It just locks up the window.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Try using the window information tool to get window info, and check out WinSetState in the help file.

Edit

Some custom GUIs are not so easy to automate, and there is no guarantee that it will work.

Edited by czardas

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I found a solution that works using ANYGUI.au3. It is available on this forum.

#include <AnyGUI.au3>
#include <WindowsConstants.au3>

$win = "Calculator"
$hwnd = _GuiTarget($win)
_TargetStyle("set", 1, $GUI_SS_DEFAULT_GUI, -1, $hwnd)
_EndTarget()
Edited by Knight

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