我想使用Alt+d来触发删除。
!d::Send, {delete}
除了资源管理器之外,这几乎适用于所有地方。选择文件并按 Alt+d 时没有任何反应。这是为什么?
环境:最新AutoHotKey,Windows 10-64bit
尝试
!d::
IfWinActive ahk_class CabinetWClass ; explorer
{
; The control retrieved by this command is the one that has keyboard focus
ControlGetFocus, FocusedControl, A ; A means the active window
; MsgBox %FocusedControl%
If FocusedControl contains DirectUIHWND,SysListView
SendInput, {AppsKey}d
else
Send, {delete}
}
else
Send, {delete}
return
对于 AHK V2 和 Win 11:
!d::
{
if WinActive("ahk_class CabinetWClass") ; explorer
{
FocusedControl := ControlGetClassNN(ControlGetFocus("A"))
if (FocusedControl ~= "i)(DirectUIHWND|DirectUIHWND2|SysListView)")
SendInput("{AppsKey}d")
else
Send("{delete}")
}
else
Send("{delete}")
return
}