Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

RegJump() - Jump to registry path in Regedit

  • Please log in to reply
2 replies to this topic
  • Members
  • 194 posts
  • Last active: Apr 18 2016 07:18 AM
  • Joined: 28 Nov 2010
RegJump() - Jump to registry path in Regedit

Hi all, today I've spent quite some time writing RegJump(), a function that takes a registry path and makes Regedit open to that path. It accepts root keys in boths standard HKEY_LOCAL_MACHINE and HKLM abbreviated form. RegJump() essentially does the same as Microsoft's RegJump, the only advantage being that my function does not rely on a third-party executable to work.

;Open Regedit and navigate to RegPath.
;RegPath accepts both HKEY_LOCAL_MACHINE and HKLM formats.
	;Must close Regedit so that next time it opens the target key is selected
	WinClose, Registry Editor ahk_class RegEdit_RegEdit

	If (SubStr(RegPath, 0) = "\") ;remove trailing "\" if present
		RegPath := SubStr(RegPath, 1, -1)

	;Extract RootKey part of supplied registry path
	Loop, Parse, RegPath, \
		RootKey := A_LoopField

	;Now convert RootKey to standard long format
	If !InStr(RootKey, "HKEY_") ;If short form, convert to long form
		If RootKey = HKCR
			StringReplace, RegPath, RegPath, %RootKey%, HKEY_CLASSES_ROOT
		Else If RootKey = HKCU
			StringReplace, RegPath, RegPath, %RootKey%, HKEY_CURRENT_USER
		Else If RootKey = HKLM
			StringReplace, RegPath, RegPath, %RootKey%, HKEY_LOCAL_MACHINE
		Else If RootKey = HKU
			StringReplace, RegPath, RegPath, %RootKey%, HKEY_USERS
		Else If RootKey = HKCC
			StringReplace, RegPath, RegPath, %RootKey%, HKEY_CURRENT_CONFIG

	;Make target key the last selected key, which is the selected key next time Regedit runs
	RegWrite, REG_SZ, HKCU, Software\Microsoft\Windows\CurrentVersion\Applets\Regedit, LastKey, %RegPath%
	Run, Regedit.exe

Practical example

The small example allows you to select any text containing a registry path and RegJump() will jump to the corresponding key or value in Regedit directly, all with a single click.

To trigger the hotkey, select text with the LButton and then press G on your keyboard whilst still holding down the LButton to commit. Incidentally, using LButton & for copying/pasting stuff etc is a a huge workflow booster an I highly recommend it.

Here are a couple of paths you can use for testing, directly from your web browser. Note that RegJump() will ignore (or rather remove) a trailing backslash:
HKEY_CURRENT_USER\Control Panel\Accessibility\AudioDescription\

#SingleInstance Force
~LButton & g::
	SendInput {LButton Up}^c
	Sleep 100 ;Wait for copied text to become available
	If InStr(Clipboard, "HKEY_")
		RegJump( Clipboard ) ;Go to Registry path

RegJump() - Jump to registry path in Regedit

HoverScroll() - HoverScroll() - Scroll controls without focus

  • Members
  • 194 posts
  • Last active: Apr 18 2016 07:18 AM
  • Joined: 28 Nov 2010
Another very convenient use of RegJump() is to create Explorer shortcuts to registry keys. For this you first need the following script, which takes one single argument containing the registry key path you want to navigate to in standard HKEY_LOCAL_MACHINE form, as stated in the original post.


#SingleInstance Force

MyRegPath = %1%
RegJump(MyRegPath) ;pass registry path to script

Then all you have to do is create a shortcut and in the target box enter the following:

"C:\Program Files\AutoHotkey\AutoHotkey.exe" "C:\Program Files\AutoHotkey\RegJumpLink.ahk" HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class
In other words:

<path to autohotkey.exe> <path to RegJumpLink.ahk> <registry key path>

This example assumes you put RegJumpLink.ahk in the same directory as AutoHotkey.exe
When you double-click the shortcut Regedit will open to the specified registry key path.

Using a little imagination, you can write a script to create a regsitry link from a path copied to the clipboard. On my system I use Classic Shell which allows me to create custom toolbars for Explorer. I have a button that runs an AHK script to create a link to any path (registry, file or URL) copied to the clipboard:

Posted Image

If anyone is interested in the code I'll be happy to share it.

RegJump() - Jump to registry path in Regedit

HoverScroll() - HoverScroll() - Scroll controls without focus

  • Members
  • 744 posts
  • Last active: Sep 01 2015 02:54 PM
  • Joined: 10 Jul 2013

That's pretty handy! wink.png