However, there is a it took me several hours to figure out how to do it on other windows in runtime, so I tought it might help others. So you want to remove buttons like this: #include <WinAPI.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
$h = WinGetHandle("Untitled - Note")
$iOldStyle = _WinAPI_GetWindowLong($h, $GWL_STYLE)
ConsoleWrite("+ old style: " &amp; $iOldStyle &amp; @CR)
$iNewStyle = BitXOr($iOldStyle, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX)
_WinAPI_SetWindowLong($h, $GWL_STYLE, $iNewStyle)
_WinAPI_ShowWindow($h, @SW_SHOW) or remove even the close button: instead of $iNewStyle = BitXOr($iOldStyle, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX)use $iNewStyle = BitXOr($iOldStyle, $WS_SYSMENU) The cool part about these is that you can still close the window with ALT+F4 or minimize it clicking the tray icon. The trickiest part caused me the biggest headache that if you just set the window style with a SetWindowLong() API call, but don't run _WinAPI_ShowWindow($h, @SW_SHOW) the following can happen. To show up properly after the style change, I tried redrawing the window, redrawing everything, sending WM_PAINT message to the Window, calling SetWindowLong() with different handles and options, nothing worked, until I found this comment. So it is very important to run it after setting the style. You can find more about Window styles on MSDN or Autoit help Now, what if you want only disable the buttons, but don't want to remove them ? Like this: (The close button is "greyed" out, the other two are still visible. but if you click them, nothing happens.) The following forum topic solution is very good: You can disable any of you want with these functions: ; Constants from http://msdn.microsoft.com/en-us/library/windows/desktop/ms646360(v=vs.85).aspx
Const $SC_CLOSE = 0xF060
Const $SC_MOVE = 0xF010
Const $SC_MAXIMIZE = 0xF030
Const $SC_MINIMIZE = 0xF020
Const $SC_SIZE = 0xF000
Const $SC_RESTORE = 0xF120
Func GetMenuHandle($hWindow, $bRevert = False)
If $bRevert = False Then
$iRevert = 0
Else
$iRevert = 1
EndIf
$aSysMenu = DllCall("User32.dll", "hwnd", "GetSystemMenu", "hwnd", $hWindow, "int", $iRevert)
ConsoleWrite("+ Menu Handle: " &amp; $aSysMenu[0] &amp; @CRLF)
Return $aSysMenu[0]
EndFunc
Func DisableButton($hWindow, $iButton)
$hSysMenu = GetMenuHandle($hWindow)
DllCall("User32.dll", "int", "RemoveMenu", "hwnd", $hSysMenu, "int", $iButton , "int", 0)
DllCall("User32.dll", "int", "DrawMenuBar", "hwnd", $hWindow)
EndFunc
Func EnableButton($hWindow, $iButton)
$hSysMenu = GetMenuHandle($hWindow, True)
DllCall("User32.dll", "int", "RemoveMenu", "hwnd", $hSysMenu, "int", $iButton , "int", 0)
DllCall("User32.dll", "int", "DrawMenuBar", "hwnd", $hWindow)
EndFunc by calling the functions like this: DisableButton($handle, $SC_CLOSE)
DisableButton($handle, $SC_MAXIMIZE)
DisableButton($handle, $SC_RESTORE)
DisableButton($handle, $SC_MINIMIZE)Same with EnableButton(). If you disable $SC_SIZE, the window will not be resizeable with the mouse. If you disable SC_MOVE, you also cannot move it. Note: everything was tested on Windows 7 with Aero theme. On other system you might not have the same problem (window becoming a ghost after style update). If you test it on other system, please make a feedback about it ! Hope this helps somebody !