Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve version specific executable searching. #352

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

EtorixDev
Copy link
Contributor

I was having some issues testing v1 behavior while working on another pull request because the library couldn't find my v1 installation. I completely uninstalled AutoHotkey twice and tested two install configurations to see how it behaved and rewrote the executable searching code to accommodate it.

The first time I installed v1 then v2. In this case, v1 installed into C:\Program Files\AutoHotkey and v2 installed into C:\Program Files\AutoHotkey\v2.

The second time I installed v2 then v1 (how I originally had it installed). In this case, v2 installed into C:\Program Files\AutoHotkey\v2 and v1 installed into C:\Program Files\AutoHotkey\v1.1.37.02.

So the rewritten code will search the top level install directory if v1 is selected, otherwise it will search for v1... or v2... directories and then search there.

I put all of the executables in a single list to save a line and an if statement but can split it if necessary.

EXECUTABLES = ['AutoHotkey.exe', 'AutoHotkey64.exe', 'AutoHotkey32.exe', 'AutoHotkeyU64.exe', 'AutoHotkeyU32.exe', 'AutoHotkeyA32.exe']
# vs
V2_EXECUTABLES = ['AutoHotkey.exe', 'AutoHotkey64.exe', 'AutoHotkey32.exe']
V1_EXECUTABLES = ['AutoHotkey.exe', 'AutoHotkeyU64.exe', 'AutoHotkeyU32.exe', 'AutoHotkeyA32.exe']

@spyoungtech
Copy link
Owner

spyoungtech commented Dec 20, 2024

Thanks for suggesting. Are those install locations default behaviors for the AutoHotkey installer and is that documented somewhere?

I think I also vaguely recall that the installer inserts a registry value for the location of the executable. If that registry key is known and stable, maybe that can be used. It may also be possible to infer the binary location if the program associated with .ahk file extension is one of the known executable names, maybe as a last resort.

@EtorixDev
Copy link
Contributor Author

EtorixDev commented Dec 20, 2024

The DOCS mention the default install location second hand a few times. From the V1 Docs it mentions this:

A directory other than the default may be specified via the /D parameter (in the absence of /S, this changes the default directory displayed by the installer). For example:

AutoHotkey_1.1.34.03_setup.exe /S /D=C:\Program Files\AutoHotkey

And

Uninstall: To silently uninstall AutoHotkey, pass the /Uninstall parameter to Installer.ahk. For example:

"C:\Program Files\AutoHotkey\AutoHotkey.exe" "C:\Program Files\AutoHotkey\Installer.ahk" /Uninstall

And related from the V2 Docs

For users of v1: AutoHotkey v2 includes a launcher which allows multiple versions of AutoHotkey to co-exist while sharing one file extension (.ahk). Installing AutoHotkey v1 and v2 into different directories is not necessary and is currently not supported.

So I believe my testing which showed that installing v1 then v2 causes v1 to install in the main folder and v2 in a subfolder, and installing v2 then v1 causes them each to have their own sub-folders is correct and default behavior, however I likely didn't handle the order of the executable as robustly as possible.

As for the registry, I just opened up regedit and ctrl+f searched for "AutoHotkey" and found 3 entries for "ExecutablePath" that I think are used for the default "open with" settings?

I also found in the AutoHotkey folder in the registry which has 2 subfolders "v1" and "v2" which have "Build" keys equaling either Unicode 64-bit (v1) or 64-Bit (v2) so this could be a potential way to detect it however I'm not sure if these registry entries are added when just v1 is installed or when v1 is installed first. Would need some testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants