退格键向上一级

Backspace to go one level up

这是我对 kidmar's script from AHK forums 稍作修改的版本。

脚本应该改变 Backspace 键行为,即当我们在 Windows 资源管理器中按 Backspace 时,它的工作方式类似于 Alt-Up(我们在文件中上一级层次结构)。

由于某种原因,它不起作用。应该如何修复?

FunBackspaceExplorer()
{
    IfWinActive, ahk_class CabinetWClass
    {
        ControlGetFocus, focused, A
        IfNotInString, focused, "Edit" ; Return true only if current control isn't an edit control
            return 1
    }

    return 0
}

#If, FunBackspaceExplorer() ; Backspace hotkey exists only if all conditions are met
Backspace:: SendInput, !{Up}
#If

(这个任务还有另一个可行的解决方案,但我对这个感兴趣)。

如果我使用:

,你的版本可以在我的系统上运行
#If, FunBackspaceExplorer() ; Backspace hotkey exists only if all conditions are met

    Backspace:: 
    SetKeyDelay 10,1000
    SendEvent {Alt down}{Up down}{Alt Up}{Up Up}
    return

#If

SetKeyDelay 在发送的向下事件和向上事件之间插入延迟,或者在发送密钥后插入延迟。 它不适用于 SendInput。