Page 1 of 1

RegRead: what am I missing here?

Posted: 21 Aug 2017, 05:30
by J Scott Elblein
Hi all,

Brand new to AHK, but not new to coding. I installed AHK to play with and already have run into an issue.

I'm just trying to read the value of a reg key, and it's coming back empty (I've confirmed there's in fact, a value in the actual registry key itself). I copied & pasted the exact RegRead code straight from the help file, changing only the key.

Here's the entire code in my file so far:

Code: Select all

#NoEnv
#Warn
SendMode Input
SetWorkingDir %A_ScriptDir%

RegRead, OutputVar, HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\VirtualBox, InstallDir
MsgBox, Program files are in: %OutputVar%
then when I run it using SciTE4AutoHK (or even directly via a command prompt, the messagebox just shows no value returned? :crazy:

Running this on Windows 10 x64. Any ideas? Thought this lang was supposed to be almost n00b-proof? :P

Re: RegRead: what am I missing here?

Posted: 21 Aug 2017, 07:41
by Rindis
There is a small difference:

Code: Select all

RegRead, OutputVar, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion, ProgramFilesDir
RegRead, OutputVar, HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\VirtualBox, InstallDir
See the comma after HKEY_LOCAL_MACHINE?

Re: RegRead: what am I missing here?

Posted: 21 Aug 2017, 08:31
by just me
Hi Rindis,
RootKey\SubKey [v1.1.21+]
If RootKey is followed immediately by a slash (\), RootKey and SubKey are merged into a single parameter.

Re: RegRead: what am I missing here?

Posted: 21 Aug 2017, 09:10
by jeeswg
If the key and value exist I would have thought that your script would work.

Try this in SciTE4AutoHotkey and/or as a separate script:

Code: Select all

q:: ;test RegRead
RegRead, vFontName, HKEY_CURRENT_USER\Software\Microsoft\Notepad, lfFaceName
MsgBox, % vFontName
RegRead, vFontName, HKEY_CURRENT_USER, Software\Microsoft\Notepad, lfFaceName
MsgBox, % vFontName
return
Note also: what version of AutoHotkey are you using, in case it's a version before v.1.1.21.

[EDIT:] Cheers qwerty12, I had meant to mention about SetRegView. While trying to explain/present things carefully, things can slip your mind.

Re: RegRead: what am I missing here?  Topic is solved

Posted: 21 Aug 2017, 09:23
by qwerty12
Hi,

I don't have VirtualBox installed to test, but if your AutoHotkey is 32-bit and you're working with a 64-bit VirtualBox, you probably need to add SetRegView 64 before doing the RegRead.

EDIT:
(Or maybe SetRegView 32 if you're using a 64-bit AutoHotkey and VirtualBox is 32-bit) - err, not going to happen - VirtualBox relies on kernel drivers...

J Scott Elblein: You're welcome :-)

Re: RegRead: what am I missing here?

Posted: 21 Aug 2017, 11:43
by Rindis
Just_me:

good point :-)

Re: RegRead: what am I missing here?

Posted: 21 Aug 2017, 12:09
by J Scott Elblein
@qwerty12

That was it, TY. :D