cajhin / capsicain

Powerful low-level keyboard remapping tool for Windows
349 stars 18 forks source link

Enable AutoHotkey local configuration #37

Closed bitoj closed 3 years ago

bitoj commented 3 years ago

According to its documentation, AutoHotkey takes a startup script from either

When AutoHotkey in the Capsicain directory is started by Capsicain, only the latter location works.

It appears that AutoHotkey takes the location where it is installed from the command that is used to invoke it. That is not how Capsicain currently starts AutoHotkey.exe.

This PR involves a small fix to use the full pathname to start a program from Capsicain.

cajhin commented 3 years ago

Did you mean " [....] only the former location works." ?

I always have the .ahk in the same folder as autohotkey.exe, and that works. Never tried it with /Documents.

bitoj commented 3 years ago

No, for me it really only worked when I placed an AutoHotkey.ahk in my Documents folder.

This was actually one of the first things I noticed after installing Capsicain v79. Starting AutoHotkey resulted in seeing the AHK help file, with the following text at the bottom of the main page.

Why am I seeing this?

You ran AutoHotkey without telling it which script file to run, and it couldn't find a script in either of the usual places.

After following the documentation about the "usual places", I concluded that the folder with AutoHotkey.exe did not work for some reason, but the Documents folder did. So I had a work-around and decided to investigate later, mainly for the benefit of new users.

Thus my PR.

After your comment I tried to reproduce your findings, and I did. After uninstalling my main AHK from Program Files, the AutoHotkey.exe from the Capsicain folder found the local AutoHotkey.ahk.

So the problem is still related to using an unqualified path name, but relying on the PATH to have Windows start its known AutoHotkey.exe, after Capsicain verified that there is at least one such program in its own folder. But that is no guarantee that the local version will actually be started.

So I still think the PR has value, but it is not as important as I thought earlier. New users that have no prior AutoHotkey installation will not be affected.

cajhin commented 3 years ago

Ah, I get it now. Thank you for figuring this out!

I never noticed that an 'installed' AHK has priority over a local ahk.exe in the capsicain folder, since I 'copy&paste deploy' all my tools. I never install a software when a portable version exists.

This is going to impact users that rely on capsicain starting their 'installed' AKH. It is now required to have a local copy in the capsicain home dir. I think it's better that way, since an "AHK for capsicain" will likely have a different role than a global stand-alone AHK.