Oh Boy, the internet is smarter than I thought. You guys are probably going to hate me. But I'm already using this script. One thing I've noticed however, is this script does not work when MinMax = 0 and the mouse cursor is between y <= 4 && y >=0 (when the cursor changes to the resizing icon). And so, I'm trying to add a "patch script" to fill in that gap. It's nothing major, but I have a perfectionist nature... (which also plagues my life
)
My whole script is this:
Code: Select all
#If MouseIsOverTitlebar()
RButton::
{
MouseGetPos,, MouseYMin, WinID
WinMinimize, ahk_id %WinID%
Return
}
MButton::
{
MouseGetPos,, MouseYCLS, WinID
WinGet, PNameWinCLS, ProcessName, ahk_id %WinID%
If (PNameWinCLS == "EXCEL.EXE" OR PNameWinCLS == "Winword.EXE" OR PNameWinCLS == "WINWORD.EXE")
{
Send !{F4}
Return
}
Else If (PNameWinCLS == "NordVPN.exe")
{
SendMessage, 0x02 ; WM_DESTROY
Return
}
Else
{
WinClose, ahk_id %WinID%
Return
}
}
#If
MouseIsOverTitlebar()
{
; CoordMode Mouse, Relative
CoordMode Mouse, Screen
MouseGetPos,, MouseY, WinID
WinGet, PNameWinMin, ProcessName, ahk_id %WinID%
WinGet, WinMMax, MinMax, ahk_id %WinID%
Static WM_NCHITTEST := 0x84
HTCAPTION := 2
CaptionBarSize:=30
If ((PNameWinMin == "lync.exe" OR PNameWinMin == "acadlt.exe" OR PNameWinMin == "acad.exe") AND (MouseY < CaptionBarSize && MouseY >= 0))
{
Return True
}
Else If (WinMMax == 0 AND MouseY == 0)
; Else If (WinMMax == 0 AND (MouseY <= 4 && MouseY >= 0))
; Else If (WinMMax == 0 AND MouseY == 0) ; (MouseY <= 4 && MouseY >= 0))
{
; msgbox, 1
Return True
}
Else
{
; msgbox, 12
CoordMode Mouse, Screen
MouseGetPos x, y, w
If WinExist("ahk_class Shell_TrayWnd ahk_id " w) ; Exclude taskbar.
{
Return False
}
SendMessage WM_NCHITTEST,, (x & 0xFFFF) | ((y & 0xFFFF) << 16),, ahk_id %w%
WinExist("ahk_id " w) ; Set Last Found Window for convenience.
Return ErrorLevel = HTCAPTION
}
}
Some credit goes to seabreeze
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=63022&p=269207&hilit=titlebar+middle+click#p269207