1

In this howtogeek post, there is a snippet like this, use Backspace to go up one folder level in Windows Explorer:

#IfWinActive, ahk_class CabinetWClass

; Please run on Windows 7+ 
Backspace::
    ControlGet renamestatus,Visible,,Edit1,A
    ControlGetFocus focussed, A
    if(renamestatus!=1 && (focussed=="DirectUIHWND3"||focussed==SysTreeView321))
    {
        MsgBox, Don't check this ; debug
        SendInput !{Up}
    }else{
        tooltip, Back-delete a char
        Send {Backspace} ; Why does it not trigger another Backspace hotkey?
    }
return
#IfWinActive

But I'm very baffled why he can write

Backspace::

instead of

$Backspace::

According to doc, when you are renaming a file in Windows 7 Explorer, the no-$ case will cause a press of Backspace to trigger more Backspaces infinitely, BUT in fact it does not happen. Can someone help explain this?

Try with Autohotkey 1.1.13.01, on Windows 7.

1

From the #UseHook help topic:

Hotkeys will be implemented using the default method (RegisterHotkey() if possible; otherwise, the keyboard hook).

Normally, the windows API function RegisterHotkey() is used to implement a keyboard hotkey whenever possible. However, the responsiveness of hotkeys might be better under some conditions if the keyboard hook is used instead.

Turning this directive ON is equivalent to using the $ prefix in the definition of each affected hotkey.

So the hotkey has one of two registration methods and multiple ways to be set to one of these two registration methods. You can look at which method is being used to register the hotkey by running the script as #persistent or as part of another script that's persistent, and then opening the script window from the tray icon and selecting View > Hotkeys and their methods (Ctrl+H). The hotkey will be listed there with either k-hook or reg--the two options described above in the #UseHook help topic.

The following will result in k-hook:

#UseHook
Backspace::

This will also result in a keyboard hook:

$Backspace::

This will also result in a keyboard hook:

#IfWinActive, ahk_class CabinetWClass
Backspace::

This will result in a regular registration and reg will be displayed under the hotkey list:

Backspace::

Or more generally:

#IfWinActive
Backspace::

The important distinction is the end result, and whether it is registered as a keyboard hook or not. If you'd like to try the infinitely repeating Backspace then remove or replace the #IfWinActive, ahk_class CabinetWClass and hit backspace in Explorer window. Things should go crazy for a second and then you should get a message that too many hotkeys have been received and are you sure you want to continue. Have fun with that.

Another tool you may be interested in is just adding the 'Up' button icon back to your Windows 7 folders... this free utility does a great job and you can just select the 1 of the 4 options available in the installer once you download and run it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.