Anyone got code to find the AHK install folder that does NOT use A_AhkPath?

Get help with using AutoHotkey and its commands and hotkeys
User avatar
evilC
Posts: 4819
Joined: 27 Feb 2014, 12:30

Anyone got code to find the AHK install folder that does NOT use A_AhkPath?

14 Apr 2017, 09:15

AHK-EXE-SWapper does not work if AHK is not in C:\Program Files, because it gets wrong AHK path.
It needs to run without using the AHK EXE, as it has to change the AHK exe.

So does anyone have any code to find AHK install folder?
eg find key in registry, or write temp AHK file to extract A_AhkPath from AHK exe?

Obviously I am capable of writing it myself, I just wondered if anyone already has a code snippet that works.
guest3456
Posts: 3349
Joined: 09 Oct 2013, 10:31

Re: Anyone got code to find the AHK install folder that does NOT use A_AhkPath?

14 Apr 2017, 09:23

looks like the guy showed the regkey in your mainthread:
Run regedit in my machine, `HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Open\Command` says "d:\TechnicalSupport\ProgramFiles\AutoHotkey\AutoHotkey.exe" "%1" %*

just me
Posts: 8600
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Anyone got code to find the AHK install folder that does NOT use A_AhkPath?

14 Apr 2017, 09:43

Code: Select all

HKEY_LOCAL_MACHINE\SOFTWARE\AutoHotkey\InstallDir
?
guest3456
Posts: 3349
Joined: 09 Oct 2013, 10:31

Re: Anyone got code to find the AHK install folder that does NOT use A_AhkPath?

14 Apr 2017, 10:54

evilC wrote:HKEY_LOCAL_MACHINE\SOFTWARE\AutoHotkey does not exist on my system
mine either (win10)

but i do have this:

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\AutoHotkey\InstallDir

just me
Posts: 8600
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Anyone got code to find the AHK install folder that does NOT use A_AhkPath?

14 Apr 2017, 11:25

Code: Select all

RegRead, OutputVar, HKEY_LOCAL_MACHINE\SOFTWARE\AutoHotkey, InstallDir
will be redirected to HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\AutoHotkey for 32-bit AHK on 64-bit Windows.
lexikos
Posts: 8598
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Anyone got code to find the AHK install folder that does NOT use A_AhkPath?

14 Apr 2017, 20:01

See Installer.ahk.

Code: Select all

AutoHotkeyKey := "SOFTWARE\AutoHotkey"
;...
    ; This first section has two purposes:
    ;  1) Determine the location of any current installation.
    ;  2) Determine which view of the registry it was installed into
    ;     (only applicable if the OS is 64-bit).
    CurrentRegView := ""
    Loop % (A_Is64bitOS ? 2 : 1) {
        SetRegView % 32*A_Index
        RegRead CurrentPath, HKLM, %AutoHotkeyKey%, InstallDir
        if !ErrorLevel {
            CurrentRegView := A_RegView
            break
        }
    }

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], mikeyww, Spawnova, Stinkfoot9, wetware05, Xtra and 44 guests