• AutoHotkey – Open regedit at a specific location

    Home » Forums » Developers, developers, developers » DevOps Lounge » AutoHotkey – Open regedit at a specific location

    Author
    Topic
    #367980

    The Registry Editor in Windows 10 now has an editable address bar allowing you to paste a destination key.

    I was looking for an even easier way. A bit of research showed that Regedit keeps a record of the last key opened.

    Here’s some AutoHotkey code that I’ve now added to my always-running AHK script (which runs from startup). It lets me select a key from, say, a webpage then press WinKey+j (for ‘jump’) to open the Registry Editor at the same key, just by pre-populating Regedit’s LastKey entry:

    #j::
    {
    LK_loc = HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit ; Location of LastKey entry
    
    ClipSaved := ClipboardAll ; Save the current clipboard contents
    
    Clipboard = ; Empty the clipboard
    
    SendInput, ^c ; Copy selected registry key to the clipboard
    
    ClipWait  ; Wait for the clipboard to contain text
    
    ; Search and replace any abbreviations
    StringReplace, Clipboard, Clipboard, HKCR, HKEY_CLASSES_ROOT
    StringReplace, Clipboard, Clipboard, HKCC, HKEY_CURRENT_CONFIG
    StringReplace, Clipboard, Clipboard, HKCU, HKEY_CURRENT_USER
    StringReplace, Clipboard, Clipboard, HKLM, HKEY_LOCAL_MACHINE
    StringReplace, Clipboard, Clipboard, HKU, HKEY_USERS
    
    RegWrite, REG_SZ, %LK_loc%, LastKey, %Clipboard% ; Write LastKey data from clipboard to registry as a string
    
    Clipboard = ; Empty the clipboard
    
    Clipboard := ClipSaved ; Restore the original clipboard contents
    
    Run, %windir%\regedit.exe ; Open the Registry Editor
    
    Return
    }

    (If you would like the same functionality but can’t be fussed with AutoHotkey then have a look at this Winhelponline article describing how to do the same using Sysinternals/TechNet’s RegJump.)

    Hope this helps…

    Reply To: AutoHotkey – Open regedit at a specific location

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: