AutoHotkey 发送 {Del} 在 Win10 上的资源管理器中不起作用

问题描述 投票:0回答:2

我想使用Alt+d来触发删除

!d::Send, {delete}

除了资源管理器之外,这几乎适用于所有地方。选择文件并按 Alt+d 时没有任何反应。这是为什么?

环境:最新AutoHotKey,Windows 10-64bit

autohotkey
2个回答
4
投票

尝试

!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

https://autohotkey.com/docs/commands/ControlGetFocus.htm


0
投票

对于 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
}
© www.soinside.com 2019 - 2024. All rights reserved.