AutoHotkey v2 Official Release Announcement - Q&A

Discussion about the AutoHotkey Foundation and this website
fraudeerbeer
Posts: 4
Joined: 22 Jan 2023, 15:45

AutoHotkey v2 Official Release Announcement - Q&A

Post by fraudeerbeer » 22 Jan 2023, 15:56

Hi everyone,

I wanted to know which IDE/Code Editor is best to use when scripting AHK v2. I currently use VS Code with the AutoHotkey Plus extension, which is my preferred IDE, but will this extension support AHK v2? I also saw the extension AutoHotkey Plus Plus, which is a fork of AutoHotkey Plus. Is this any good?
Please LMK,

-FraudeerBeer.

Dgls
Posts: 12
Joined: 11 Jan 2023, 21:53

Re: AutoHotkey v2 Official Release Announcement

Post by Dgls » 22 Jan 2023, 20:06

I'm relatively new to this as well, I've arrived at VS Code with the extensions:
AutoHotkey V2 Language Support,
vscode-autohotkey-debug
It seems to work very well and has boosted my productivity. The syntax highlighting, class awareness and debugging are all excellent.

Axlefublr
Posts: 2
Joined: 23 Jan 2023, 05:19
Contact:

Re: Looking for a good IDE that will work flawlessly on v2

Post by Axlefublr » 23 Jan 2023, 05:23

fraudeerbeer wrote:
22 Jan 2023, 15:56
Hi everyone,

I wanted to know which IDE/Code Editor is best to use when scripting AHK v2. I currently use VS Code with the AutoHotkey Plus extension, which is my preferred IDE, but will this extension support AHK v2? I also saw the extension AutoHotkey Plus Plus, which is a fork of AutoHotkey Plus. Is this any good?
Please LMK,

-FraudeerBeer.
The best extension for v1 *is* actually Autohotkey Plus Plus. The best one for v2 is Autohotkey Language Support, I've made a video about it if you're interested: https://youtu.be/u66dw-hIj3g

neogna2
Posts: 586
Joined: 15 Sep 2016, 15:44

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by neogna2 » 23 Jan 2023, 06:17

official release announcement wrote:
The syntax highlighting in AHK code boxes will be changed to use v2 syntax rules.
Looking forward to v2 syntax highlighting for code boxes in v2 posts! But is it possible, and in terms of work feasible, to keep v1 syntax highlighting in existing v1 forum posts? And for new v1 code in the v1 subforums?

robodesign
Posts: 932
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by robodesign » 23 Jan 2023, 09:03

Is there a tool to help migrate existing code to the new v2 code? I'm using the v1. 1 syntax.

I really want to migrate to v2, because it's great, but my apps are too big to easily make the switch. My image viewer/editor (QPV) has over 95k lines....

Thank you.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.

User avatar
technochitlin
Posts: 10
Joined: 22 Jul 2016, 14:35

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by technochitlin » 23 Jan 2023, 09:13

Malwarebytes 4.5.20 freaks and deletes file/forces a reboot when I try to install 2.02 on my Win10 machine; 1.1.36 installs just fine.

Axlefublr
Posts: 2
Joined: 23 Jan 2023, 05:19
Contact:

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by Axlefublr » 23 Jan 2023, 11:10

robodesign wrote:
23 Jan 2023, 09:03
Is there a tool to help migrate existing code to the new v2 code? I'm using the v1. 1 syntax.

I really want to migrate to v2, because it's great, but my apps are too big to easily make the switch. My image viewer/editor (QPV) has over 95k lines....

Thank you.
There are a few tools that convert v1 code into v2 code, but none of them are perfect, so you'll have to step in and edit some things that failed to automatically convert. I haven't used any of those tools myself, but I think Joe Glines has a video on at least one of them that you can check out.

neogna2
Posts: 586
Joined: 15 Sep 2016, 15:44

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by neogna2 » 23 Jan 2023, 11:42

robodesign wrote:
23 Jan 2023, 09:03
Is there a tool to help migrate existing code to the new v2 code? I'm using the v1. 1 syntax.
I really want to migrate to v2, because it's great, but my apps are too big to easily make the switch. My image viewer/editor (QPV) has over 95k lines....
https://github.com/mmikeww/AHK-v2-script-converter and related thread viewtopic.php?f=6&t=25100

Converting those 95K lines will be a lot of manual work I suspect! I have no script near that size and I've still been slowly, gradually migrating v1 scripts to v2 for the last year or so. Advice: start with converting the smallest v1 scripts you use, to ease into the v2 syntax changes and find effective ways to deal with v2 error message popups (v2 is much more "throwy", which can be overwhelming at first, but IsSet() and Try are your friends) and find code editor settings and tools for v2 that serves your needs.

neogna2
Posts: 586
Joined: 15 Sep 2016, 15:44

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by neogna2 » 23 Jan 2023, 12:30

If the forum is partly reworked to put v2 front and center consider also adding new guidelines for new forum posts. Here are three suggestions

Provide source code
Avoid posting compiled .exe scripts and never post .exe scripts without also providing the source. Same for compiled .dll files or binary mcode embedded in scripts. Good security habit and promotes open source.

Don't embed huge images from third party image hosts into posts
Crop and shrink images first and then attach to the post instead of a third party image host. Saves user bandwidth and avoids information loss when third party image hosts close down.

Give posts specific, informative titles
Not "v2 error" or other generic titles. Mods could append info to too generic titles. Improves forum search.

fraudeerbeer
Posts: 4
Joined: 22 Jan 2023, 15:45

Re: Looking for a good IDE that will work flawlessly on v2

Post by fraudeerbeer » 23 Jan 2023, 17:59

Axlefublr wrote:
23 Jan 2023, 05:23
fraudeerbeer wrote:
22 Jan 2023, 15:56
Hi everyone,

I wanted to know which IDE/Code Editor is best to use when scripting AHK v2. I currently use VS Code with the AutoHotkey Plus extension, which is my preferred IDE, but will this extension support AHK v2? I also saw the extension AutoHotkey Plus Plus, which is a fork of AutoHotkey Plus. Is this any good?
Please LMK,

-FraudeerBeer.
The best extension for v1 *is* actually Autohotkey Plus Plus. The best one for v2 is Autohotkey Language Support, I've made a video about it if you're interested: https://youtu.be/u66dw-hIj3g
Thank you, very useful video.

ahketype
Posts: 191
Joined: 27 Oct 2016, 15:06
Location: Yorkshire, UK

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by ahketype » 24 Jan 2023, 15:00

Trying to get my head round how it will work if the version selector considers my code to be v1 so runs v1 interpreter, but if I then adopt v2 syntax in further developing that script (rather than converting everything in the script to v2 first). Will this cause issues? I.e. will neither version be able to run this hybrid code? Presumably, that's the case, and v1 scripts have to be developed in v1 or fully converted to run in v2.
Many thanks, I'm looking forward to having just one syntax!

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by boiler » 24 Jan 2023, 16:48

ahketype wrote: Trying to get my head round how it will work if the version selector considers my code to be v1 so runs v1 interpreter, but if I then adopt v2 syntax in further developing that script (rather than converting everything in the script to v2 first).
The version selector is for determining which version is to be used for the entire script. It doesn’t run part of a script with one version and another part with another.

ahketype wrote: Will this cause issues? I.e. will neither version be able to run this hybrid code? Presumably, that's the case, and v1 scripts have to be developed in v1 or fully converted to run in v2.
Yes, that would cause problems as neither the v1 nor the v2 interpreter can run hybrid code. So you’re right that a script needs to be able to fully stand on its own as either v1 or v2 code.

ahketype
Posts: 191
Joined: 27 Oct 2016, 15:06
Location: Yorkshire, UK

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by ahketype » 24 Jan 2023, 19:04

boiler wrote:
24 Jan 2023, 16:48
ahketype wrote: Trying to get my head round how it will work if the version selector considers my code to be v1 so runs v1 interpreter, but if I then adopt v2 syntax in further developing that script (rather than converting everything in the script to v2 first).
The version selector is for determining which version is to be used for the entire script. It doesn’t run part of a script with one version and another part with another.

ahketype wrote: Will this cause issues? I.e. will neither version be able to run this hybrid code? Presumably, that's the case, and v1 scripts have to be developed in v1 or fully converted to run in v2.
Yes, that would cause problems as neither the v1 nor the v2 interpreter can run hybrid code. So you’re right that a script needs to be able to fully stand on its own as either v1 or v2 code.
Thanks, boiler, it's kind of obvious now. I read that the Launcher would automatically detect the version from the file contents and settings, but that still obviously leaves two incompatible interpreters, and it can only make a binary decision.

It was also confusing because (note to devs...) the v2 installer didn't say anything about installing alongside v1 (or I missed it - I don't know if it would, in fact). So when I installed v2, at the prompt for the path, I wasn't sure what to do to leave the option of going back to v1 or running both. So I renamed the Autohokey folder, "AutohotkeyV1", then continued with the default installation of v2. I began trying to run scripts from SciTE, which presumably doesn't check the Launcher auto-detect routines, it just tries to error-check according to the platform selected.

Anyway, fixed now. I tried launching a script from Explorer, and got the dialogue:
It looks like the script you are trying to run requires AutoHotkey v1, which is not installed.

Script: AutoHotkey - Copy.ahk
Rule: v1-cmd v1-ass v1-char v1-hk v1-send v1-dir

We can try to download and install AutoHotkey v1.1.36.02 for you, while retaining the ability to use the versions already installed.

Download and install AutoHotkey v1.1.36.02?
---------------------------
Yes No
---------------------------
So, I did that and reinstalled a new copy of v1 (best not muck things up even further with my meddling in Program files!). I then just had to copy back into that path the Lib folder for script dependencies like gdip.ahk.

Ooh, new question - what happens if you run a v1 script and it launches a v2 script or vice versa? Do you get the two Autohotkey interpreters running their respective scripts?

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by boiler » 24 Jan 2023, 20:14

ahketype wrote: what happens if you run a v1 script and it launches a v2 script or vice versa? Do you get the two Autohotkey interpreters running their respective scripts?
I would think it would run it the same way as if you ran it manually. It’s best to use #Requires/#Requires at the top of your scripts so it always chooses the right one.

iseahound
Posts: 1427
Joined: 13 Aug 2016, 21:04
Contact:

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by iseahound » 24 Jan 2023, 22:12

@boiler Add the v1/v2 side by side install instructions (or a link) somewhere on the official announcement to reduce confusion.

How to install v1/v2 side by side:
  1. Go to https://www.autohotkey.com/ and click Download.
  2. Download and install AutoHotkey v1.1 (Use Express Installation, then Exit)
  3. Download and install AutoHotkey v2.0.
Now when you double click a script file to run, you should see a context menu that allows you to select between 1.1.36.02 or 2.0.2.
Last edited by iseahound on 25 Jan 2023, 10:29, edited 2 times in total.

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by boiler » 24 Jan 2023, 23:46

Thanks for the suggestion, @iseahound. A link has been added to the announcement (end of the first paragraph).

User avatar
lmstearn
Posts: 681
Joined: 11 Aug 2016, 02:32
Contact:

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by lmstearn » 31 Jan 2023, 03:57

neogna2 wrote:
23 Jan 2023, 06:17
But is it possible, and in terms of work feasible, to keep v1 syntax highlighting in existing v1 forum posts? And for new v1 code in the v1 subforums?
Excellent suggestion, by the responses, it sounds as if the forum S/W caters for one style only, unconditional on topic. There may be an "easy" way around it by a separate (subdirectory) Board install for a v1 subforum, not sure. :think:
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by boiler » 31 Jan 2023, 05:08

lmstearn wrote:
31 Jan 2023, 03:57
neogna2 wrote:
23 Jan 2023, 06:17
But is it possible, and in terms of work feasible, to keep v1 syntax highlighting in existing v1 forum posts? And for new v1 code in the v1 subforums?
Excellent suggestion, by the responses, it sounds as if the forum S/W caters for one style only, unconditional on topic. There may be an "easy" way around it by a separate (subdirectory) Board install for a v1 subforum, not sure. :think:
I haven’t seen the responses that say that. Although it wouldn’t address the issue of existing posts, the forum software already allows for a myriad of styles for code boxes if the dropdown list is used. And in many cases, there are several versions of the same language available. Including both “AutoHotkey v1” and “AutoHotkey v2” in that list should be no problem, I would suspect. The general code tag button would be made to apply to v2 instead of v1 like it is now, though.

Regarding existing posts, they could be edited to change “code” tags (which currently default to AHK v1 but will soon be for AHK v2) to v1-specific “Codebox=autohotkeyv1” tags, but that is more work than can be expected to be done manually. Hopefully, there is a way to do a bulk find/replace for all posts in specific sub-forums.

badbob001
Posts: 4
Joined: 29 Jan 2020, 19:23

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by badbob001 » 31 Jan 2023, 08:52

A common use case is a single "hotkey" file full of different functions culled from forums, documentation, and oneself, which seems like a recipe for mixed v1 and v2 code. Can an editor with autohotkey syntax highlighting (like notepad++) point out the v1-specific code so we know to update it to v2 format? Or do we just have to wait for the v1 code to run, fail, and reveal the details in the error message?

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by boiler » 31 Jan 2023, 09:13

Other than some specific keywords, it’s often not clear what individual lines of code belong to one version vs. the other. It would take some real inattention to what one is doing to end up with a mix of both versions in the same script file.

Post Reply

Return to “About This Community”