AutoHotkey v2.0-beta.1

Community news and information about new or upcoming versions of AutoHotkey
User avatar
JoeSchmoe
Posts: 129
Joined: 08 Dec 2014, 08:58

Re: AutoHotkey v2.0-beta.1

30 Jul 2021, 20:28

I couldn't be more excited to see this. Many congrats, Lexikos!

To anyone else reading, I've been using v2 for about a year and love it. I converted a 1000 line script and while there was a learning curve, it didn't take long to actually do it. You just dive right in and fix the errors that pop up when you try to run the script with the new version. Piece of cake.
User avatar
hyaray
Posts: 85
Joined: 20 Jun 2015, 01:37
Contact:

Re: AutoHotkey v2.0-beta.1

01 Aug 2021, 10:54

First of all, I want to confirm whether v2 is the main version of ahk.
If it is, then users of v1 should be gradually switched to v2.
AutoHotkey is a niche language. If it is divided in this way, it is indeed not conducive to the development of the language.
I have been in contact with the v1 version of ahk for 6 years, and it has been two years since I switched to v2-a102(mainly because of the conversion of syntax , which is not difficult.)
A103 has started drastic reforms, many of which are bottom-level changes, without concise sample code, many errors will make people unable to start.

Now the v2_beta version is out, the syntax should be relatively stable, I also want to follow the steps.
As mentioned above, the workload and difficulty of converting the code are too great, and I think the structure of the help document is a bit confusing.
For example, I found map related changes at https://lexikos.github.io/v2/docs/v2-changes.htm#map
Then I entered https://wyagd001.github.io/v2/docs/objects/Map.htm to see the detailed introduction,
But there is no sample code, and then I have to know, and finally found the sample code with difficulty in Usage and Syntax→Objects→Basic Usage.
https://lexikos.github.io/v2/docs/Objects.htm#Usage_Associative_Arrays

Just such a single knowledge point requires so many search steps, how can users have the motivation to upgrade to v2.
So I have always advocated a dedicated post or a forum area to guide users to upgrade their existing code as painlessly as possible.
It is best to gradually upgrade the commonly used libraries of v1 to v2. This kind of code comparison is also a more intuitive way for users to learn grammatical differences.
Upgrading to v2 is a big project, I hope it can be taken seriously, this is what I want to say, thank you! ! !
Finally, I hope that the functions of array map can be enhanced, such as ToString, array join and other common functions are built into the script.
If there is an official library, I hope it can be written in the help file.
User avatar
boiler
Posts: 16709
Joined: 21 Dec 2014, 02:44

Re: AutoHotkey v2.0-beta.1

01 Aug 2021, 11:20

hyaray wrote: First of all, I want to confirm whether v2 is the main version of ahk.
If it is, then users of v1 should be gradually switched to v2.
No. By definition, the beta release is still not the official or main version. Going to beta means that updates are expected to just fix bugs, not to implement changes that would break existing code.
MrDoge
Posts: 151
Joined: 27 Apr 2020, 21:29

Re: AutoHotkey v2.0-beta.1

01 Aug 2021, 21:02

AHK_user wrote:
30 Jul 2021, 05:29
Is there by any chance a syntax file of all the commands and functions available?
@AHK_user do you mean v2? (there are no commands in v2, I think AHK Studio ahk.xml is v1)

what do you mean by "syntax file" ? is it simply the list of functions? what other information is there? oh, 1st argument, 2nd argument

for v2, I found this list in ahk source code. I searched for StatusBarGetText, which should be a rare function (so I have more chance of landing on a list, instead of some implementation)
https://github.com/Lexikos/AutoHotkey_L/blob/3808407a7c8871c0e87288a739f7ff317caaab7b/source/script.cpp#L310

for v1
here's my list, I actually used AHK Studio ahk.xml to make this list :
https://github.com/FuPeiJiang/ahk_parser.js/blob/06a808f4871ab50a59d2ac6dd6a04969a4e2ea57/src/parser/tokens.ts#L22
:4 are commands
:1 are directives
'class':5'
'if':2
'global':3,'local':3,'static':3
if you want CamelCase, you'll have to get corresponding in this: https://github.com/FuPeiJiang/ahk_parser.js/blob/06a808f4871ab50a59d2ac6dd6a04969a4e2ea57/ahk_language/command/merged.ahk

can you tell me your use case ? :)
I might find it useful
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: AutoHotkey v2.0-beta.1

01 Aug 2021, 23:43

MrDoge wrote:
01 Aug 2021, 21:02
AHK_user wrote:
30 Jul 2021, 05:29
Is there by any chance a syntax file of all the commands and functions available?
@AHK_user do you mean v2? (there are no commands in v2, I think AHK Studio ahk.xml is v1)

what do you mean by "syntax file" ? is it simply the list of functions? what other information is there? oh, 1st argument, 2nd argument

for v2, I found this list in ahk source code. I searched for StatusBarGetText, which should be a rare function (so I have more chance of landing on a list, instead of some implementation)
https://github.com/Lexikos/AutoHotkey_L/blob/3808407a7c8871c0e87288a739f7ff317caaab7b/source/script.cpp#L310

for v1
here's my list, I actually used AHK Studio ahk.xml to make this list :
https://github.com/FuPeiJiang/ahk_parser.js/blob/06a808f4871ab50a59d2ac6dd6a04969a4e2ea57/src/parser/tokens.ts#L22
:4 are commands
:1 are directives
'class':5'
'if':2
'global':3,'local':3,'static':3
if you want CamelCase, you'll have to get corresponding in this: https://github.com/FuPeiJiang/ahk_parser.js/blob/06a808f4871ab50a59d2ac6dd6a04969a4e2ea57/ahk_language/command/merged.ahk

can you tell me your use case ? :)
I might find it useful
I`ll check your links if I find the time :D .

To make ahk V2 beta user friendly, we need to update the editors.

1. Syntax File
The syntax file is used to autofill the correct functions/Commands in the editor. And to highlight them, gives you info about the function.
This file is to used in AHK Studio, but for the moment I have issues that AHK Studio overrides my version, I hope that meastrith explains me how to implement this for v2 files.

I have already created a scraper to collect some of the info from the help files :).
https://www.autohotkey.com/boards/viewtopic.php?f=62&t=93136#p413009

Here is my preliminary version for V2 beta syntax file:
https://github.com/dmtr99/AHK-Studio/blob/Beta/lib/Languages/ahkv2.xml

2. Launcher
I have made a Launcher that automatically runs the correct AHK version based on extension, content or folder.

https://www.autohotkey.com/boards/viewtopic.php?f=82&t=75824#p412188

3. Convertor V1 to V2
I tried to fix the already done work. But did not manage to update the Convert function to V2 (This code was made to convert V1 to V2 alpha) :facepalm: :facepalm: :facepalm: .
It would be helpfull if somebody could fix it so we can improve it further.

In the end, I created my own Convert2 fuction with the focus on Gui and Menu commands. It already begins working quite well for not to complex code lines with Gui and Menu commands.
You can test it out on V1 Gui`s :D It is fun to see how well it works.

https://www.autohotkey.com/boards/viewtopic.php?f=6&t=25100&p=413240#p413240
User avatar
JoeSchmoe
Posts: 129
Joined: 08 Dec 2014, 08:58

Re: AutoHotkey v2.0-beta.1

02 Aug 2021, 19:37

Having an automatic converter is key, I think. Then people can see their own code, both before and after a conversion. After that, they can get to tinkering with it and then they're on their way to mastering it.

@MrDoge has an automatic script converter on a web page:
https://fupeijiang.github.io/ahk_parser.js/

I used it to convert a 3000 line script I've been using for years. At first, there were two portions of code that made it crash. For each portion of code, I isolated the section of code and posted a Github issue (posting a Github issue is just like using a forum). For both issues, MrDoge responded and fixed the issue. Now my entire code will convert without crashing.

(For the record, I don't write super crazy code, pushing the limits of AHK1 syntax.)

The code uses several external AHK libraries, including a JSON library. My work schedule is crushing me, so it may be a while before the code is actually running. However, I do have 3000 lines of converted code.

Especially for a smaller project, MrDoge's converter is a valuable resource that I am grateful for. I think he may have also used it to convert the WinClip library, so I assume it can do some heavy lifting. With that said, if you use it, you should definitely be prepared to see some syntax errors the first time you run the code. That's fine - when I converted another script by hand, I found the error messages from ahkv2beta were very clear. It was a great way to start learning about the changes and really didn't take long. With a conversion script like this one, it's just nice that most of the changes have already been made for you.

For the record, here is a portion of the converted script. I compared the code, Before and After, using Microsoft Word's compare function because it's what I had handy:
Image
Obviously it's not a huge number of changes, but I'm super glad to have a script do the first draft:
https://i.imgur.com/VodcMbX.png

Also, guest3456 and AHK_user are writing another conversion script. It looks great, too.
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=25100
At this point, though, I have more experience with MrDoge's, which, because it's web-based, is a bit easier to start with.
User avatar
thqby
Posts: 391
Joined: 16 Apr 2021, 11:18
Contact:

Re: AutoHotkey v2.0-beta.1

03 Aug 2021, 08:36

For AHK V2, I have developed a vscode extension. Most of the functions are implemented by vscode language service protocol(vscode-lsp) and lexical analysis. This extension can also be used in other editors supporting vscode-lsp, such as neovim.
More information: https://github.com/thqby/vscode-autohotkey2-lsp
guest3456
Posts: 3453
Joined: 09 Oct 2013, 10:31

Re: AutoHotkey v2.0-beta.1

03 Aug 2021, 12:21

thqby wrote:
03 Aug 2021, 08:36
neovim
:clap:

MrDoge
Posts: 151
Joined: 27 Apr 2020, 21:29

Re: AutoHotkey v2.0-beta.1

03 Aug 2021, 14:01

edited reply I was writing yesterday:
AHK_user wrote:
01 Aug 2021, 23:43
The syntax file is used to autofill the correct functions/Commands in the editor.
omg, I could really use this in vscode for v2, I just don't want to implement it
name:type of parameters
but I haven't been writing much ahk for a few months, tiny scripts, yes
---
and I've just installed extension by @thqby and now I have that in vscode, lol
thanks
description of functions are in chinese, but parameters are in english and that's all I needed
it tells me which argument I'm currently writing

but now it's not showing vscode-icons for ahk anymore

2. Launcher
I name my v2 files .ah2, and I use f5 to run my current file in vscode.
to grab file path in WinTitle, put this line in vscode settings.json
"window.title": "${activeEditorLong} - Visual Studio Code",

3. Convertor V1 to V2
I'm also making a converter: https://github.com/FuPeiJiang/ahk_parser.js, convert online here
it parses ahk v1 first, I thought it would be cleaner, but I saw this : https://github.com/mmikeww/AHK-v2-script-converter/blob/0711af91d0775b6ad234f06b3d21098457938367/ConvertFuncs.ahk#L28
and this was wayyyyy cleaner

I hope that with a parser, mine can do stuff this can't do
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: AutoHotkey v2.0-beta.1

24 Aug 2021, 07:57

Well done! :salute: :happybday:

Cheers.
User avatar
hyaray
Posts: 85
Joined: 20 Jun 2015, 01:37
Contact:

Re: AutoHotkey v2.0-beta.1

25 Aug 2021, 07:51

thqby wrote:
03 Aug 2021, 08:36
For AHK V2, I have developed a vscode extension. Most of the functions are implemented by vscode language service protocol(vscode-lsp) and lexical analysis. This extension can also be used in other editors supporting vscode-lsp, such as neovim.
More information: https://github.com/thqby/vscode-autohotkey2-lsp
Great, I'm using vim8, with coc.nvim pulging, But I don't know how to use this extension, is there some simple tutorial for me to learn. :xmas:
User avatar
thqby
Posts: 391
Joined: 16 Apr 2021, 11:18
Contact:

Re: AutoHotkey v2.0-beta.1

25 Aug 2021, 19:28

@hyaray
I didn't try it. I saw it in issues.
https://github.com/neoclide/coc.nvim/issues/3023
User avatar
hyaray
Posts: 85
Joined: 20 Jun 2015, 01:37
Contact:

Re: AutoHotkey v2.0-beta.1

25 Aug 2021, 20:04

thqby wrote:
25 Aug 2021, 19:28
@hyaray
I didn't try it. I saw it in issues.
https://github.com/neoclide/coc.nvim/issues/3023
Thank you very much. I will try it. The concept of lsp is very vague.
By the way, If I want to improve lsp, what should I do? :bravo:
User avatar
thqby
Posts: 391
Joined: 16 Apr 2021, 11:18
Contact:

Re: AutoHotkey v2.0-beta.1

25 Aug 2021, 20:30

@hyaray
This is the introduction of LSP.
https://code.visualstudio.com/api/language-extensions/language-server-extension-guide

You can commit issues on GitHub or Gitee.
Or clone the code, install dependencies, modify the source code, and repackage.
hpta
Posts: 24
Joined: 27 Sep 2019, 01:43

Re: AutoHotkey v2.0-beta.1

26 Aug 2021, 09:13

thqby wrote:
03 Aug 2021, 08:36
For AHK V2, I have developed a vscode extension... https://github.com/thqby/vscode-autohotkey2-lsp
This looks like something i've been looking for :-)
quick questions: Is it possible to set the help text to English?
like in this case
image.png
image.png (10.16 KiB) Viewed 5704 times
And after opening this in VS code this message is shown:
The AutoHotkey interpreter does not exist, re-specify in'Settings-AutoHotkey2.InterpreterPath'
Source: Autohotkey2 Language Support (Extension)
image.png
image.png (7.72 KiB) Viewed 5704 times
- Please can you tell me how to define settings for this?
User avatar
thqby
Posts: 391
Joined: 16 Apr 2021, 11:18
Contact:

Re: AutoHotkey v2.0-beta.1

26 Aug 2021, 21:41

@hpta
There are no tips to organize the English version. These files are in the plugins folder/syntaxes/ahk2.(d.ahk|json).
The Setting options are here.
image.png
image.png (28.33 KiB) Viewed 5646 times
sssheridan
Posts: 9
Joined: 18 Dec 2019, 05:31

Re: AutoHotkey v2.0-beta.1

10 Sep 2021, 02:25

lexikos wrote:
24 Jul 2021, 19:28
Any further changes prior to the final v2.0.0 release should be of a minor nature (such as improvements to the error and warning dialogs), and should not affect the functionality of scripts. In other words, future releases are expected to be backward-compatible.
Does this mean backward-compatible with v2.x, or with v1.x as well?
lexikos wrote:
24 Jul 2021, 19:28
AutoHotkey v2 (about and downloads)
This is currently just a broken version of the regular homepage.
User avatar
boiler
Posts: 16709
Joined: 21 Dec 2014, 02:44

Re: AutoHotkey v2.0-beta.1

10 Sep 2021, 04:50

sssheridan wrote: Does this mean backward-compatible with v2.x, or with v1.x as well?
Only with versions of v2 since the beta release. It already isn’t and was never meant to be backward compatible with v1.
User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: AutoHotkey v2.0-beta.1

10 Sep 2021, 08:24

@sssheridan I have fixed the V2 download page. :+1:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: AutoHotkey v2.0-beta.1

11 Sep 2021, 14:38

Code: Select all

DllCall('somefunc', 'Ptr', BigStruct, 'UInt', BigStruct.Size, 'Float', 123.456, 'Ptr*', &pAnotherThing := 0, 'Double')
[/code]
Did "String" get replaced with 'String' in v2?

Return to “Announcements”

Who is online

Users browsing this forum: No registered users and 15 guests