john c. j.
john c. j.

Reputation: 1175

Backspace to go one level up

This is my slightly modified version of kidmar's script from AHK forums.

The script should change Backspace key behaviour, i.e. when we press Backspace in Windows Explorer, it works like Alt-Up (we go up one level in files hierarchy).

For some reason it doesn't work. How it should be fixed?

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

(There are another working solutions for this task, but I'm interseted in this one).

Upvotes: 2

Views: 341

Answers (1)

Relax
Relax

Reputation: 10568

Your version works on my system, if I use:

#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 inserts a delay between a down event and up event for a send, or a delay after sending keys. It does not work with SendInput.

Upvotes: 1

Related Questions