Windows minimize disable

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
giapage
Posts: 4
Joined: 12 Dec 2018, 09:36

Windows minimize disable

12 Dec 2018, 10:15

Hello,
I need to disable or hide the button "Minimize" for all windows on my PC with Windows7 pro 64bit and Windows10 pro 64bit

I've found the code to use on other posts this code:

Code: Select all

Loop
{
	WinSet, Style, -0x20000, A ; WS_MINIMIZEBOX 0x20000
}

But it create a AHK process which uses 99% of CPU and generate visible slow down of the overall system. How can I achieve the same result but avoiding to use the loop which takes so much CPU percentage?

Regards
GP
giapage
Posts: 4
Joined: 12 Dec 2018, 09:36

Re: Windows minimize disable

18 Dec 2018, 04:17

Hello,
is it possible to do what I would like to do?
Best regards
GP
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: Windows minimize disable

18 Dec 2018, 09:31

Code: Select all

WinGet, id, list
Loop, %id%
{
	this_ID := id%A_Index%
	WinSet, Style, -0x20000, ahk_id %this_ID% ; WS_MINIMIZEBOX 0x20000
}

; https://autohotkey.com/board/topic/80644-how-to-hook-on-to-shell-to-receive-its-messages/
Gui +LastFound
DllCall("RegisterShellHookWindow", UInt,WinExist())
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage")
return

ShellMessage( wParam,lParam )
{
	If ( wParam = 1 ) ;  1 means HSHELL_WINDOWCREATED
		WinSet, Style, -0x20000, ahk_id %lParam% ; WS_MINIMIZEBOX 0x20000
}
giapage
Posts: 4
Joined: 12 Dec 2018, 09:36

Re: Windows minimize disable

18 Dec 2018, 10:16

Thanks GEV.
I tried to use your AHK script but I have noticed that it does not work for all applications. For example, if I run On Screen Keyboard on Win7 pro 64bit, this script does not disable the minimize button.
I have seen also that another windows application does not hide the minimize button. What is the reason why this script does not work on all windows applications?

Regards
GP

GEV wrote:
18 Dec 2018, 09:31

Code: Select all

WinGet, id, list
Loop, %id%
{
	this_ID := id%A_Index%
	WinSet, Style, -0x20000, ahk_id %this_ID% ; WS_MINIMIZEBOX 0x20000
}

; https://autohotkey.com/board/topic/80644-how-to-hook-on-to-shell-to-receive-its-messages/
Gui +LastFound
DllCall("RegisterShellHookWindow", UInt,WinExist())
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage")
return

ShellMessage( wParam,lParam )
{
	If ( wParam = 1 ) ;  1 means HSHELL_WINDOWCREATED
		WinSet, Style, -0x20000, ahk_id %lParam% ; WS_MINIMIZEBOX 0x20000
}
giapage
Posts: 4
Joined: 12 Dec 2018, 09:36

Re: Windows minimize disable

07 Jan 2019, 09:07

Dear GEV,
I was wondering if you had the chance to see my last question about why some application does not hide the minimize button by using your script.

Thanks in advance for your reply.

Best regards
Giacomo P
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: Windows minimize disable

07 Jan 2019, 09:55

Try to start or reload the script while the windows in question already exist. If it works, we can find another way to hide the minimize button on them, otherwise they can't be put in this style.
vsub
Posts: 541
Joined: 29 Sep 2015, 03:39

Re: Windows minimize disable

07 Jan 2019, 11:20

You will hide the button but what about
1.Show Desktop button at the bottom right
2.Win+D
3.Win+M
4.Clicking on the taskbar button of the window

This script doesn't fix those problems but it is another alternative

Code: Select all

Loop
{
WinGet,ID,ID,A
WinGet,Style,Style,ahk_id %ID%
If (Style & 0x20000 )
WinSet, Style, -0x20000,ahk_id %ID%
WinWaitNotActive,ahk_id %ID%
}
You can also add a list of windows on which the script to not work
Add GroupAdd(check how that function work) to the top of the script and use the function commands to add a on window which you want to keep the minimize button and add
WinWaitNotActive,ahk_group the group name
at the beginning of the loop

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5, mikeyww, RussF and 378 guests