default editor for ahk v2

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
hpta
Posts: 24
Joined: 27 Sep 2019, 01:43

default editor for ahk v2

12 Feb 2022, 21:23

Please, how can I set the default editor for ahk scripts?
I tried this:
image.png
image.png (13.73 KiB) Viewed 2004 times
(with restart)
After right click on a running script icon->Edit script - the script is still opened in Notepad.

Btw the example code doesn't work for ahk v2 - different syntax...
https://lexikos.github.io/v2/docs/commands/Edit.htm#ExDefaultEditor
User avatar
boiler
Posts: 17387
Joined: 21 Dec 2014, 02:44

Re: default editor for ahk v2

12 Feb 2022, 21:57

I don't know if this should make a difference, but see the difference between yours and mine. Mine has a "Command" folder within the "Edit" folder with the default key's value modified while yours has a key named "Command" in the "Edit" folder for which the value was assigned.
ahk editor regedit.png
ahk editor regedit.png (16.73 KiB) Viewed 1967 times
hpta
Posts: 24
Joined: 27 Sep 2019, 01:43

Re: default editor for ahk v2

13 Feb 2022, 05:23

@boiler
I tried to set it up like you, but it still doesn't make a difference
image.png
image.png (14.87 KiB) Viewed 1847 times
Another thing to consider is that I don't have Autohotkey installed. I use just v2 beta which is located somewhere on my PC (not in Program Files)
I created the structure of AutoHotkeyScript keys in regedit manually. There was nothing before it. (so for example I don't have "Compile", "Compile-Gui" keys in the registry)
User avatar
boiler
Posts: 17387
Joined: 21 Dec 2014, 02:44

Re: default editor for ahk v2

13 Feb 2022, 07:54

That is apparently the key difference. Unless you have a reason not to, after restoring the registry its prior state without your additions, I would install AutoHotkey so all the file associations are put in place. Then just replace the v1 binary files with the v2 binaries.
vmech
Posts: 375
Joined: 25 Aug 2019, 13:03

Re: default editor for ahk v2

16 Feb 2022, 20:59

@hpta
Also you need .ahk key in registry

Image
Dump of AutoHotkey registry keys
Please post your script code inside [code] ... [/code] block. Thank you.
hpta
Posts: 24
Joined: 27 Sep 2019, 01:43

Re: default editor for ahk v2

22 Feb 2022, 11:53

I finally tried to do it by installing v1 to program files, then replacing binaries there with ahk v2 beta files.
This is what I have in the Program Files folder
image.png
image.png (44.67 KiB) Viewed 1635 times
(v2 beta files are highlighted in yellow)

But the "Edit Script" settings simply doesn't work with v2 beta.

If I run a script with AutoHotkey64.exe (i. e. v2 beta executable) and select "Edit Script" in the tray menu then it's opened in Notepad.
However, If I run a simple skript with a AutoHotkeyU64.exe (one of v1 executables) and select "Edit Script: in the tray menu, it is opened in VS Code (!)

It might be that it's not possible to set default editor for ahk V2 yet.

edit: I also tried deleting AutoHotkeyU64.exe and then renaming AutoHotkey64.exe to AutoHotkeyU64.exe. It doesn't work either.
User avatar
boiler
Posts: 17387
Joined: 21 Dec 2014, 02:44

Re: default editor for ahk v2

22 Feb 2022, 13:27

It shouldn’t matter if it’s v2 or not. To confirm, you should try to get it totally working for v1 first, then just swap out the executable binary file. The fact that you started without having it installed and edited the registry then tried to install it is probably causing issues. You could probably verify this if you have access to another machine where you install v1 first then do nothing else than to swap the binary file with a v2 version.
vmech
Posts: 375
Joined: 25 Aug 2019, 13:03

Re: default editor for ahk v2

22 Feb 2022, 15:05

@hpta
As @boiler noted above, launching Edit script command doesn't depend on .exe files in %ProgramFiles%\Autohotkey folder at all.
It depends on the registry key HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command. Its default value should contain path to your VSCode editor, e.g. @="\"C:\\Program Files\\Microsoft VS Code\\VSCode.exe\" \"%1\"".
My working (!!!) registry key
Please post your script code inside [code] ... [/code] block. Thank you.
hpta
Posts: 24
Joined: 27 Sep 2019, 01:43

Re: default editor for ahk v2

22 Feb 2022, 16:08

@boiler, @vmech
Thank you for your patience and help. There had to be something wrong in the registry.... I searched through it, deleted everything constaining "ahk" or "autohotkey" (except for a couple of random cryptic strings probably not related to autohotkey), then installed v1,

edited HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command
... Edit Script was opening the script in VS Code. Yes!

Copied v2 beta AutoHotkey64.exe into AutoHotkey.exe in the Program Files.
... Still opening in VS Code.

So problem solved but I feel like I've spent too much time with issue :-). I wish a proper official V2 installer already existed...
IMO it's easy to mess things up If you try to run ahk1 and ahk2 on the same PC. And if try to change the "Open with" path for .ahk files.
vmech
Posts: 375
Joined: 25 Aug 2019, 13:03

Re: default editor for ahk v2

22 Feb 2022, 16:53

hpta wrote:
22 Feb 2022, 16:08
I searched through it, deleted everything constaining "ahk" or "autohotkey" (except for a couple of random cryptic strings probably not related to autohotkey), then installed v1
First, you might have tried removing Autohotkey through Apps and Features ;)
Second, you might have tried to find in registry ghost keys contained 'ahk' and 'autohotkey', and then deleting them 8-)
But anyway, all's well that ends well :thumbup:
Please post your script code inside [code] ... [/code] block. Thank you.
User avatar
boiler
Posts: 17387
Joined: 21 Dec 2014, 02:44

Re: default editor for ahk v2

22 Feb 2022, 17:44

hpta wrote:
22 Feb 2022, 16:08
IMO it's easy to mess things up If you try to run ahk1 and ahk2 on the same PC.
There are various methods for easily accomplishing this. This one is my favorite. ;)

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: No registered users and 49 guests