Jump to content

Active Window's Title bar Customization - (Moved)


Recommended Posts

Hi Everybody,

total noob here trying out Autoit for the first time.

What I'm trying to accomplish is writing a script that REMOVES the minimize/maximize/close buttons of the currently active window.

By looking through different threads, I managed to write this little script that actually does the job on the currently active window:

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

$hActive = WinGetHandle("[active]")

$iOldStyle = _WinAPI_GetWindowLong($hActive, $GWL_STYLE)
ConsoleWrite("+ old style: " & $iOldStyle & @CR)
$iNewStyle = BitXOr($iOldStyle, $WS_SYSMENU)
_WinAPI_SetWindowLong($hActive, $GWL_STYLE, $iNewStyle)
; _WinAPI_ShowWindow($h, @SW_SHOW)
_WinAPI_SetWindowPos($hActive, 0, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))

The issue is that this only works once, when running the script itself.

I'm wondering if anybody has any idea on how to go about having the script keep running in the background constantly, monitoring any active window, and applying the change to the window (if it hasn't been applied to it before).

Thanks, any help appreciated.

Link to comment
Share on other sites

  • Developers
6 minutes ago, Allotarallo said:

What I'm trying to accomplish is writing a script that REMOVES the minimize/maximize/close buttons of the currently active window.

... and why exactly do you need/want to do this?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Hi Jos,

thank you for taking care of the post and apologies for the wrong entry.

The goal of the script is to fix a pet peeve of mine with the Windows UI.

Here is a screenshot of my desktop setup:

https://imgur.com/zCKQeCx

Taskbar at the top, my applications basically act as "tabs", like any modern software should be designed to work. In this layout, I find the minimize/maximize/close buttons on the top right to be a complete and utter eyesore, especially considering that I NEVER use them for any reason whatsoever.

  • "Minimize" is a useless button the function of which completely escapes me; never ever use it. When I click on a new application, the one that used to be on top goes automatically in the background. If I need to see the desktop for some reason, the "show desktop" button at the top right de facto minimizes all the opened windows. 
  • "Close" is available on the taskbar itself, making it totally redundant at the top right of the title bar. Moreover, by closing apps from the taskbar I feel the usage pattern more closely resembles the use of "tabs" (on Chrome, just to make an example), which is what I'm shooting for.
  • "Maximise/restore" is the most baffling of all, being that you can accomplish the needed actions by simply double clicking the title bar when necessary.
  • Not to mention that all these actions are, again, available on the taskbar itself by simply shift-clicking on the application if necessary.

There are a bunch of other considerations regarding the usage of keyboard shortcuts, the amount of movement required for the mouse pointer from the middle of the screen to the desired target, and the fact that by freeing up that part of the title bar it's actually easier to grab and move around windows as there is more "free" real estate to click on. But I'm keeping the topic strictly UI related, rather than UX. So, end of rant!

Thanks again to anybody who has some ideas on how to accomplish this.

 

 

Link to comment
Share on other sites

Tested on Win7

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

Opt("MustDeclareVars", 1)

Local $hActive, $iNewStyle, $iOldStyle, $hPrec, $iState

HotKeySet("^!{ESC}", _Exit)

While True
  Sleep(100)
  $hActive = WinGetHandle("[ACTIVE]")
  If $hPrec = $hActive Then ContinueLoop
  $hPrec = $hActive
  ConsoleWrite ("==============================================" & @CRLF)
  ConsoleWrite ("Class Name = " & _WinAPI_GetClassName($hActive) & @CRLF)
  $iOldStyle = _WinAPI_GetWindowLong($hActive, $GWL_STYLE)
  ConsoleWrite ("Old style = " & Hex($iOldStyle) & @CRLF)
  If Not BitAND($iOldStyle, $WS_VISIBLE) Then
    ConsoleWrite ("not visible" & @CRLF)
    ContinueLoop
  EndIf
  If Not BitAND($iOldStyle, $WS_SYSMENU) Then
    ConsoleWrite ("not menu" & @CRLF)
    ContinueLoop
  EndIf
  $iState = WinGetState($hActive)
  If BitAND($iState, $WIN_STATE_MAXIMIZED) Then
    ConsoleWrite ("maximize" & @CRLF)
    ContinueLoop
  EndIf
  $iNewStyle = BitXOr($iOldStyle, $WS_SYSMENU)
  _WinAPI_SetWindowLong($hActive, $GWL_STYLE, $iNewStyle)
  _WinAPI_SetWindowPos($hActive, 0, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))
WEnd

Func _Exit()
  Exit
EndFunc

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...