Running different AHK releases in parallel

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Running different AHK releases in parallel

02 Jun 2017, 14:54

jeeswg wrote:[EDIT:] It would be interesting to see the RegFromApp .reg file from an installation on a 32-bit machine, there would be no mention of 'Wow6432Node'.
This is my result for a virtual XP 32bit:

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\AutoHotkey]
"InstallDir"="C:\\Program Files\\AutoHotkey"
"Version"="1.1.25.02"
"StartMenuFolder"="AutoHotkey"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.ahk]
@="AutoHotkeyScript"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.ahk\ShellNew]
"FileName"="Template.ahk"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript]
@="AutoHotkey Script"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\DefaultIcon]
@="C:\\Program Files\\AutoHotkey\\AutoHotkey.exe,1"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Open]
@="Run Script"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Edit]
@="Edit Script"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Compile]
@="Compile Script"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell]
@="Open"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Edit\Command]
@="notepad.exe %1"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Compile\Command]
@="\"C:\\Program Files\\AutoHotkey\\Compiler\\Ahk2Exe.exe\" /in \"%l\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Open\Command]
@="\"C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\" \"%1\" %*"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\ShellEx\DropHandler]
@="{86C86720-42A0-1069-A2E8-08002B30309D}"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AutoHotkey.exe]
@="C:\\Program Files\\AutoHotkey\\AutoHotkey.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Ahk2Exe.exe]
@="C:\\Program Files\\AutoHotkey\\Compiler\\Ahk2Exe.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\AutoHotkey]
"DisplayName"="AutoHotkey 1.1.25.02"
"UninstallString"="\"C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\" \"C:\\Program Files\\AutoHotkey\\Installer.ahk\""
"DisplayIcon"="C:\\Program Files\\AutoHotkey\\AutoHotkey.exe"
"DisplayVersion"="1.1.25.02"
"URLInfoAbout"="https://autohotkey.com/"
"Publisher"="Lexikos"
"NoModify"="1"
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Running different AHK releases in parallel

02 Jun 2017, 17:27

I've written some code to
- remove context menu items e.g. 'Compile Script' / 'Run with UI Access' (using LegacyDisable values that can easily be removed again to restore the menu items)
- add context menu items e.g. 'Run Script (U32)'

I'd be interested if there is a similar way to temporarily disable the drop handler.

Note the code would have to be run in Admin mode.

I like to be able to toggle context menu items on/off when I need them.

I would like to have possibly 7 context menu items for AHK files:
- Run Script with: Basic, v1.1 A32/U32/U64, v2 A32/U32/U64

However this would clog up the menu, so it would be better to have these items accessible via a 'Run Script' context menu item with an arrow that points to a 'Run Script' submenu. But would this require a shell menu extension?

Cheers.

Code: Select all

;remove 'Compile Script' context menu item
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Compile, LegacyDisable

;remove 'Run with UI Access' context menu item
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\uiAccess, LegacyDisable

;does not work (disable drop handler)
;RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\ShellEx\DropHandler, LegacyDisable

;add 'Run Script (Version)' context menu item
;e.g. Basic, A32/U32/U64, v2 A32/v2 U32/v2 U64
vVersionName = U32
vVersionExe = AutoHotkeyU32.exe
;RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Open%vVersionName%,, Run Script (%vVersionName%)
;RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Open%vVersionName%\Command,, "C:\Program Files\AutoHotkey\%vVersionExe%" "`%1" `%*
return
Btw: Wow, onto page 2 of the thread already.

Btw when this key is created:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\ROOT\Certificates\########################################]
Is that key unique to the PC, or common to all PCs?

Also:
Is this always safe? notepad.exe %1
Would this be better? notepad.exe "%1"
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
lexikos
Posts: 9560
Joined: 30 Sep 2013, 04:07
Contact:

Re: Running different AHK releases in parallel

02 Jun 2017, 19:30

Why use a registry monitor? You can just search for RegWrite in Installer.ahk.

The NSIS script for the original installer should also be available somewhere.
Drugwash wrote:Theoretically the uninstall feature of the (recent, as in 1.1+) AHK installer should remove any and all traces of the registry entries it created.
It does. You can see for yourself in Installer.ahk.
However if an older version was installed through an installer there may be leftovers, such as the ahk_auto_file class in HKCR and HKLM\Software\Classes as being created by the AHK 1.0 installer.
That isn't created by the AHK 1.0 installer. It is created by the user, i.e. Open With.

On newer versions of Windows, Open With (and checking the "always" box) creates a key like

Code: Select all

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ahk\CurrentChoice
which Microsoft have made difficult for programs to tamper with directly. It overrides the keys created by the installer.

Windows also creates other keys under each user profile which the installer does not touch.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Running different AHK releases in parallel

02 Jun 2017, 19:49

@Lexikos, I used RegFromApp because I didn't know that Installer.ahk would have all the information that 'AutoHotkey_1.1.25.02_setup.exe' has.

The RegWrite lines are useful, however you have to trace back through all the variables to get all the information, also, for example, they don't mention the SystemCertificates key.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
lexikos
Posts: 9560
Joined: 30 Sep 2013, 04:07
Contact:

Re: Running different AHK releases in parallel

02 Jun 2017, 19:59

you have to trace back through all the variables to get all the information
So what? Is Ctrl+F harder than using a registry monitor? If you use the monitoring approach, you will miss things, like the "Run as administrator" entries if UAC is disabled, or various other entries if you don't enable the corresponding options. Some values aren't written if they already exist. Without knowing the logic of the installer, you can't know that the results you got are complete.

There are only three of those variables, and they are all defined in the same place.
... they don't mention the SystemCertificates key.
That's because the installer doesn't touch that key. You probably shouldn't either. If you want to reverse it correctly, I suppose you would need to use the appropriate API to delete the certificate.

That's another thing about registry monitoring installations (in general); the monitoring software will not tell you who created the key or why. Sometimes the system creates keys which you really should stay away from.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Running different AHK releases in parallel

02 Jun 2017, 20:25

There are variables/objects used in other parameters also, not just the key names.

For the registry additions I personally wanted to make, RegFromApp was the best way. As a minor point, it was interesting to compare the .reg file with PhiLho's in an earlier link.

I did look through the script, I intend to look at it more, and to try RegFromApp with different install options.

It's nice sometimes to be given the benefit of the doubt.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
ahk7
Posts: 574
Joined: 06 Nov 2013, 16:35

Re: Running different AHK releases in parallel

03 Jun 2017, 03:31

Just in case - AutoHashBang: HashBangs for AutoHotkey "Specify which AHK to use with your script with an interpreter directive." https://autohotkey.com/boards/viewtopic.php?t=6414
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: Running different AHK releases in parallel

03 Jun 2017, 03:55

Thank you for your input, Lexikos. Things are getting more complicated I see.

If ahk_auto_file is created by the system in response to user action then it should be removed from the system and more appropriate replacements used. The script I started to build as per OP's request would deal with separate file extensions for AHK scripts, each extension being assigned to a different executable. As such some common keys dealing with paths or commands should also be removed from the registry.

You mentioned HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ahk\CurrentChoice as being hard to tamper with by the user; would you please share your knowledge on how to remove that key, considering the script would have to either modify or remove the association for that extension?

Also I just looked into my registry on XP and there's other subkeys for .ahk there: OpenWithList and OpenWithProgids. The former contains only executable names with no paths - how would the system know which executable to feed the script to if there's more than one Autohotkey.exe of different versions on the system?

In hindsight I have a feeling of walking down the wrong path. Isn't there an assortment of API that deals with file association in a more elegant (and most importantly safe) way? Because with all these protected/hidden registry keys and other barriers M$ raises agains the user it's way too hard to make something legit work correctly and there's always the possibility of something slipping aside and coming back later to bite on the rear end.

Additionally I'd like to know your opinion on color-coding the official icon of various versions of AHK. In order for this multi-installation to work more smoothly it would be very useful if each of the current AHK versions (1.0, 1.1, 2.0, H1 and H2 that I know of) got a different color for the main icon and assorted shades (with or without other distinctive signs) for each of its file icons (ANSI, Unicode, Unicode64) - see sample screenshot. That would avoid having to deploy additional icon libraries from this script and would ensure uniform setups among the user base. Heck, if all versions used their own file classes (such as AutoHotkeyScript, AutoHotkey1Script, AutoHotkey2Script, AutoHotkeyH1Script, AutoHotkeyH2Script, ) and unique file extensions (such as ahk, ak1, ak2, ah1, ah2 or whatever) this script wouldn't even have a reason to exist. ;) Well, I'm asking too much - this world is about competition not collaboration, is it… But I'd sure like a change for the better, one day.
AHK color coded icons OK.png
AHK color coded icons OK.png (238.56 KiB) Viewed 3604 times
Part of my AHK work can be found here.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Running different AHK releases in parallel

03 Jun 2017, 09:47

Another thing to do is to use something like NirSoft SearchMyFiles to check for files created during the time period of the installation, these 2 files may or may not be relevant to the installation:
C:\Users\%username%\AppData\Roaming\Microsoft\Crypto\RSA\S-1-5-21-##########-##########-##########-####\#####################################################################
C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations\################.automaticDestinations-ms

Security Identifier - Wikipedia
https://en.wikipedia.org/wiki/Security_Identifier
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: Running different AHK releases in parallel

03 Jun 2017, 10:11

Those files most likely pertain to the UI Access option and are created when EnableUIAccess* functions are called in the installer.
Have you checked if the respective files get deleted upon uninstall?
Part of my AHK work can be found here.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Running different AHK releases in parallel

03 Jun 2017, 12:29

uninstall + reinstall (all 4 options unticked):
file existed but with old modified date:
C:\Users\%username%\AppData\Roaming\Microsoft\Crypto\RSA\S-1-5-21-##########-##########-##########-####\#####################################################################
file existed but with new modified date:
C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations\################.automaticDestinations-ms

Btw I added .reg file text for 4 options unticked:
list of every command/function/variable from across all versions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 65#p151665

[EDIT:] Re. 'Run as administrator', I believe that appears in the registry as RunAs, and appears whether you have none or all 4 options ticked.

[EDIT:] Btw did anyone write a .reg from/to 'RegWrite' parser? I did make an attempt, and might try and find it ..., but I had some issues with unknown registry types, and I did it all manually, I couldn't find any relevant dll calls. Also AHK RegRead seems to treat trailing 00s differently cf. Regedit generating a .reg file. Cheers.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: Running different AHK releases in parallel

03 Jun 2017, 13:01

I'd say those two files are of no importance in regard to our script here, unless someone says otherwise.
RunAs will be added to each file extension in the script.
UIAccess will be completely removed from registry.

Dunno about RegWrite parser.
Part of my AHK work can be found here.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: Running different AHK releases in parallel

12 Jun 2017, 14:59

20170612225510.png
20170612225510.png (34.68 KiB) Viewed 3530 times
I've put together an alpha version of the script. Has no real safety checks whatsoever (just a few nags), may be buggy and there's room for improvement (got a few things on the to-do list) so please please please only test it in a virtual machine, not on a working system. I have not tested it at all since I have no VM at hand. If anybody tests it please report back.

To actually write anything to the registry set the debug variable to zero.
The included icon library (in the res folder) contains only file type icons. A future version should create and patch icons on-the-fly in the original executable(s) but for current testing purposes the library provided should be enough. Main exe icon can not be changed (yet).

Script is at my repository (see signature below) under the AFA folder. Again: please do not test on a working system - virtual machine only!
Part of my AHK work can be found here.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: Running different AHK releases in parallel

13 Jun 2017, 12:26

Bugfix version 2.0.2.1 is up.
Part of my AHK work can be found here.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: Running different AHK releases in parallel

24 Jun 2017, 08:31

A couple bugfix versions have already been up for a while.
I take it nobody needs this or nobody tested it or nobody cares to offer feedback. Oh well.

Anyway, changing file icons on a per-extension basis should be easy and I'd recommend copying iconsAFA.dll to a common folder such as %WINDIR% before assigning icons to script extensions.

As for changing executable icons, that won't be feasible unless someone finds a reliable way to do it without hacking the exe resources, considering upgrades may be quite frequent. I've been searching the web up and down but couldn't find anything. I do recall Mozilla used to pick up a 'default.ico' residing in the same folder and this may have been the case with other (all?) executables long-long time ago (maybe in Win3.x versions or something). It would be nice if AHK would allow something like that (i.e AutoHotkeyA32.ico, AutoHotkeyU32.ico, AutoHotkeyU64.ico), so all uncompiled scripts would sport a custom icon to differentiate them at runtime.
("Keep dreaming" I tell to myself)
Part of my AHK work can be found here.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Running different AHK releases in parallel

24 Jun 2017, 15:30

@ Drugwash, for the reason that I have no virtual machine installed I didn't jump in. Nevertheless, I really appreciate/and noticed your effort (well, the whole thing is a mile above my skill level) - so, just to let you know, thx a mill :) :thumbup:
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: Running different AHK releases in parallel

24 Jun 2017, 15:38

Funny, I had just logged out while you were replying. :)
Well, I've tested the single registration feature on my 98SE and XP systems and they didn't burst into flames. I suppose multiple registration would work too since it shares the same code. Didn't test unregistration though.
Anyway, thanks for replying and hopefully someone will manage to confirm with other OS versions.
Part of my AHK work can be found here.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: Running different AHK releases in parallel

05 Jul 2017, 11:10

New version is up. Changelog included with the archive.
Source attached here for convenience.
AHKfileAssoc2033_src.7z
(70.97 KiB) Downloaded 83 times
Part of my AHK work can be found here.
Nixon

Re: Running different AHK releases in parallel

27 Jan 2018, 17:05

This looks fantastic. I'll try it soon in my VM first.
Thanks for the wonderful work !!!

:clap:
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: Running different AHK releases in parallel

27 Jan 2018, 17:56

Thank you.
Be careful though, I believe there still are some bugs when enabling multiple extensions at once (and maybe not only then), so do test thoroughly in VM. It's been quite a while since last working on this script.
Part of my AHK work can be found here.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Billykid and 213 guests