本文介绍了如何通过关闭窗口来最小化窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想在启动任何关闭窗口的操作时将其最小化(单击关闭按钮).对于AutoHotKey,我认为需要 WinMinimize
,但是我不知道如何检测关闭事件.如果您知道PowerShell的解决方案,请也分享.
I want to make a window only be minimized when any act of closing it is initiated (click the close button, ). For AutoHotKey I think WinMinimize
is needed, but I don't know how to detect a closing event. If you know a solution for PowerShell, please share too.
推荐答案
#NoEnv
#SingleInstance Force
; Add the ahk_class of the windows you want minimize by clicking on the close button in this array:
Classes := "Notepad,CabinetWClass,IEFrame" ; ...
Loop, parse, Classes, `,
GroupAdd, GroupName, ahk_class %A_LoopField%
SetTimer CheckMouse, -300
return
CheckMouse:
CoordMode, Mouse, Screen
MouseGetPos, mX, mY, WindowUnderMouse
WinGetPos, wX, wY, wW, wH, ahk_id %WindowUnderMouse%
CloseButton := (mY > wY and mY < wY+50 and (mX > wX + (wW-50) and mX < wX+wW))
SetTimer CheckMouse, -300
return
#If (CloseButton)
~LButton::
MouseGetPos,,, WindowUnderMouse
WinGetClass, Class, ahk_id %WindowUnderMouse%
If Class in %Classes%
{
WinGet, id, ID, ahk_id %WindowUnderMouse%
DISABLE_CloseButton(id)
WinMinimize, ahk_id %WindowUnderMouse%
}
return
#If WinActive("ahk_group GroupName")
!F4:: WinMinimize, A
#If ; turn off context sensitivity
DISABLE_CloseButton(id){ ;By RealityRipple at http://www.xtremevbtalk.com/archive/index.php/t-258725.html
menu:=DllCall("user32\GetSystemMenu","UInt",id,"UInt",0)
DllCall("user32\DeleteMenu","UInt",menu,"UInt",0xF060,"UInt",0x0)
WinGetPos,x,y,w,h,ahk_id %id%
WinMove,ahk_id %id%,,%x%,%y%,%w%,% h-1
WinMove,ahk_id %id%,,%x%,%y%,%w%,% h+1
}
ENABLE_CloseButton(id){ ;By Mosaic1 at http://www.xtremevbtalk.com/archive/index.php/t-258725.html
menu:=DllCall("user32\GetSystemMenu","UInt",id,"UInt",1)
DllCall("user32\DrawMenuBar","UInt",id)
}
https://autohotkey.com/docs/commands/_If.htm
这篇关于如何通过关闭窗口来最小化窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!