Allotarallo Posted January 2, 2021 Share Posted January 2, 2021 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 More sharing options...
Developers Jos Posted January 2, 2021 Developers Share Posted January 2, 2021 Moved to the appropriate forum. Moderation Team 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 More sharing options...
Developers Jos Posted January 2, 2021 Developers Share Posted January 2, 2021 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 More sharing options...
Allotarallo Posted January 2, 2021 Author Share Posted January 2, 2021 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 More sharing options...
Nine Posted January 2, 2021 Share Posted January 2, 2021 Tested on Win7 : expandcollapse popup#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 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Allotarallo Posted January 4, 2021 Author Share Posted January 4, 2021 Hi Nine, thank you for the code. Unfortunately no luck on Win 10 x64 19042. No visible effect whatsoever as far as I can tell... 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