AutoHotkey v2 Official Release Announcement - Q&A

Discussion about the AutoHotkey Foundation and this website
badbob001
Posts: 6
Joined: 29 Jan 2020, 19:23

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by badbob001 » 31 Jan 2023, 09:39

boiler wrote:
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.
I think a lot of people just search and copy code samples written by others, so it seems very reasonable for a single collective hotkey file with many different functions to have code that span many years and AHK versions. It would be cool if this forum can detect code versioning in posts and add an obvious v1/v2 label around the code box.

I haven't really gone through the documentation properly but I find the AHK syntax confusing. I think my existing experience with many other scripting/programming languages may actually be making it harder.

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

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by boiler » 31 Jan 2023, 09:50

badbob001 wrote: It would be cool if this forum can detect code versioning in posts and add an obvious v1/v2 label around the code box.
Maybe so, but that won’t be possible. The sub-forum the post is found in will make it clear which version it’s for, which is why I said it would take some real inattention (and/or laziness) to mix code from different versions in the same file, at least often enough for this to become a real issue.

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

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by ahketype » 31 Jan 2023, 10:19

badbob001 wrote:
31 Jan 2023, 09:39
boiler wrote:
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.
I think a lot of people just search and copy code samples written by others, so it seems very reasonable for a single collective hotkey file with many different functions to have code that span many years and AHK versions. It would be cool if this forum can detect code versioning in posts and add an obvious v1/v2 label around the code box.
Yeah, people could end up with mixed files if they grab stuff from both versions in their script, but (a) they shouldn't do that (but beginners certainly will), (b) they should test the hotkeys they add to their file (ditto re beginners) and this would probably alert them to errors... in fact, (c) if they just run the file in order to use the hotkeys, they're likely to get error messages, whichever interpreter the Launcher do-dad decides it is. I had a (d) but it's gone. So hopefully that won't be too much of a problem, and if they post it it won't be long before someone spots the problem. Maybe that was (d). :think:

As boiler says, the forum software can't do that cool thing, and if it could it would just have to do something similar to the Launcher do-dad that makes a decision according to some algorithmic assessment of the code, so it will still have to make a v1/v2 binary choice, and the other bits of mixed code will have the wrong syntax highlighting anyway.
I haven't really gone through the documentation properly but I find the AHK syntax confusing. I think my existing experience with many other scripting/programming languages may actually be making it harder.
You and me both. If I was new to AHK, I'd try to do everything in v2. For one thing, v1 has two methods of coding stuff, which is confusing, and v2 dumps the legacy method (and extends and systematizes the "expression" syntax). Secondly, if one tries to accommodate v1 and v2 together, that's just adding another additional confusion - in fact, two, since it adds the v1 syntax confusion (and v2 isn't a simple copy of the expression syntax from v1).

Welcome and good luck!

User avatar
DataLife
Posts: 460
Joined: 29 Sep 2013, 19:52

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by DataLife » 31 Jan 2023, 13:56

I have version 1 installed. I have scripts that rely on Ansi and scripts that rely on Unicode autohotkey version. I routinely run the installer to install the ansi and the unicode versions.

If I install V2 and keep v1 and then later run the v1 installer to change from Ansi to Unicode or vice versa, will that corrupt the V2 installation?

I suspect V1 is not aware of V2 so V1 will overwrite some registry settings.

Maybe the solution is to always reinstall V2 after I run the installation for V1 to switch from V1 ansi to V1 Unicode and vice versa.
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.

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

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by iseahound » 31 Jan 2023, 17:45

You should be able to run multiple copies of v1 side by side.
https://www.autohotkey.com/docs/v1/lib/_Requires.htm wrote:[v1.1.36+]: One of the following words to restrict the type of executable (EXE) which can run the script: "Unicode", "ANSI", "32-bit", "64-bit".

User avatar
atnbueno
Posts: 89
Joined: 12 Oct 2013, 04:45
Contact:

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by atnbueno » 01 Feb 2023, 07:27

Congrats to the team on the v2 release! 👏🏼👏🏼

While I like the concept of the dashboard, and the efforts to make painless the co-existence of v1 and v2 scripts in a system, I'm considering (just for myself) renaming all my v1 *.ahk scripts to *.ahk1 and associating them to the v1 AutoHotkeyU64.exe, and leave the usual .ahk extension just for v2.

Can anyone think of a reason not to do this?

BTW, what are those *_UIA.exe? What's the difference with the unsuffixed .exe?
Edit: Nevermind. Found it.
Last edited by atnbueno on 01 Feb 2023, 10:15, edited 2 times in total.

gregster
Posts: 9089
Joined: 30 Sep 2013, 06:48

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by gregster » 01 Feb 2023, 07:51

atnbueno wrote:
01 Feb 2023, 07:27
While I like the concept of the Dashboard, and the efforts to make painless the co-existence of v1 and v2 scripts in a system, I'm considering (just for myself) renaming all my v1 *.ahk scripts to *.ahk1 and associating them to the v1 AutoHotkeyU64.exe, and leave the usual .ahk extension just for v2.

Can anyone think of a reason not to do this?
I never tried a 4-character file extension, but it seems it can lead to certain complications: viewtopic.php?f=76&t=53788
Perhaps .ah1 would be a better alternative, if you really want to do it.

atnbueno wrote:
01 Feb 2023, 07:27
BTW, what are those *_UIA.exe? What's the difference with the unsuffixed .exe?
Already in v1, you can create such AHK executables for UI access - for working around problems with the User Account Control (UAC) (which protects elevated programs aka programs which are running as admin). It seems those files are added now by default during installation:
https://www.autohotkey.com/docs/v2/Program.htm#Installer_uiAccess wrote:When installing under Program Files, the installer creates an additional set of AutoHotkey exe files that can be used to work around some common UAC-related issues. These files are given the "_UIA.exe" suffix. When one of these UIA.exe files is used by an administrator to run a script, the script is able to interact with windows of programs that run as admin, without the script itself running as admin.
Edit: Too late ;)

User avatar
atnbueno
Posts: 89
Joined: 12 Oct 2013, 04:45
Contact:

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by atnbueno » 01 Feb 2023, 09:37

gregster wrote:
01 Feb 2023, 07:51
Perhaps .ah1 would be a better alternative, if you really want to do it.
Good point. Thanks.

User avatar
Benny-D
Posts: 302
Joined: 12 Mar 2014, 10:09

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by Benny-D » 06 Mar 2023, 00:31

So, is it only the syntax that is now different in v2?
All my strings in my v1 codes were preceded by percent sign (like: MsgBox % "Hello World!" ). So I guess now I need to get rid of all percent signs in all such cases. Is that all I need to do to move on to v2 or there are some other things to be done?

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

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by boiler » 06 Mar 2023, 06:19

Benny-D wrote: So I guess now I need to get rid of all percent signs in all such cases. Is that all I need to do to move on to v2 or there are some other things to be done?
There are many more things that are different in v2, which are summarized here.

User avatar
Benny-D
Posts: 302
Joined: 12 Mar 2014, 10:09

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by Benny-D » 06 Mar 2023, 08:01

boiler wrote:
06 Mar 2023, 06:19
There are many more things that are different in v2, which are summarized here.
- Ah, I see. Thank you!
Oh my God! So many things! It'll be like re-writing all scripts from scratch!

guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by guest3456 » 10 Mar 2023, 01:38

Benny-D wrote:
06 Mar 2023, 08:01
boiler wrote:
06 Mar 2023, 06:19
There are many more things that are different in v2, which are summarized here.
- Ah, I see. Thank you!
Oh my God! So many things! It'll be like re-writing all scripts from scratch!
this will help:
viewtopic.php?f=6&t=25100


mitchneal
Posts: 10
Joined: 31 Dec 2020, 20:24

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by mitchneal » 12 Mar 2023, 19:54

I hope there's a script to convert v1 source code to v2
My code is so long that I don't wanna edit it.

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

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by boiler » 12 Mar 2023, 20:09

mitchneal wrote: I hope there's a script to convert v1 source code to v2
See the link in the post immediately above yours.

mitchneal wrote: My code is so long that I don't wanna edit it.
The current tools don’t perform a 100% conversion, so you would still would need to edit it some, possibly quite a bit.

mitchneal
Posts: 10
Joined: 31 Dec 2020, 20:24

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by mitchneal » 14 Mar 2023, 18:21

The current tools don’t perform a 100% conversion, so you would still would need to edit it some, possibly quite a bit.
I used it and thank you for the tool. (ps : why is there no "thanks" button to show that I read your reply instead of re-reply :crazy: )

User avatar
xMaxrayx
Posts: 203
Joined: 06 Dec 2022, 02:56
Contact:

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by xMaxrayx » 31 Mar 2023, 22:00

Noob user here, should I switch to v2 ?
seems will be hard time form when dealing with complicated stuff like this code

Code: Select all

;AHK 1v
;thanks Rohwedder from AHK fourms <3
;https://www.autohotkey.com/boards/viewtopic.php?p=514742#p514742


;#IfWinActive,ahk_exe blender.exe ;ahk will work only for blender

$e::
KeyWait, e, T.4 ; 0.4 second
IF ErrorLevel ;long press
	Send, {F2}                     ;change here the shortcut
Else Send, {e}
KeyWait, e
Return

User avatar
xMaxrayx
Posts: 203
Joined: 06 Dec 2022, 02:56
Contact:

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by xMaxrayx » 31 Mar 2023, 22:16

ahketype wrote:
31 Jan 2023, 10:19
badbob001 wrote:
31 Jan 2023, 09:39
boiler wrote:
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.
I think a lot of people just search and copy code samples written by others, so it seems very reasonable for a single collective hotkey file with many different functions to have code that span many years and AHK versions. It would be cool if this forum can detect code versioning in posts and add an obvious v1/v2 label around the code box.
Yeah, people could end up with mixed files if they grab stuff from both versions in their script, but (a) they shouldn't do that (but beginners certainly will), (b) they should test the hotkeys they add to their file (ditto re beginners) and this would probably alert them to errors... in fact, (c) if they just run the file in order to use the hotkeys, they're likely to get error messages, whichever interpreter the Launcher do-dad decides it is. I had a (d) but it's gone. So hopefully that won't be too much of a problem, and if they post it it won't be long before someone spots the problem. Maybe that was (d). :think:

As boiler says, the forum software can't do that cool thing, and if it could it would just have to do something similar to the Launcher do-dad that makes a decision according to some algorithmic assessment of the code, so it will still have to make a v1/v2 binary choice, and the other bits of mixed code will have the wrong syntax highlighting anyway.
I haven't really gone through the documentation properly but I find the AHK syntax confusing. I think my existing experience with many other scripting/programming languages may actually be making it harder.
You and me both. If I was new to AHK, I'd try to do everything in v2. For one thing, v1 has two methods of coding stuff, which is confusing, and v2 dumps the legacy method (and extends and systematizes the "expression" syntax). Secondly, if one tries to accommodate v1 and v2 together, that's just adding another additional confusion - in fact, two, since it adds the v1 syntax confusion (and v2 isn't a simple copy of the expression syntax from v1).

Welcome and good luck!

will we I suggest call the "AHK2" in different name, (maybe SAHK? =(auto script hot key) or PHK= programming hot key)

I know it looks stupid because AHK stand for Automation Hot key, but it will be nightmare to search on google on you will get mixed search results between v1 and v2 especially if you are not that profinational scripter.

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

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by boiler » 31 Mar 2023, 22:27

xMaxrayx wrote:
31 Mar 2023, 22:16
will we I suggest call the "AHK2" in different name, (maybe SAHK? =(auto script hot key) or PHK= programming hot key)

I know it looks stupid because AHK stand for Automation Hot key, but it will be nightmare to search on google on you will get mixed search results between v1 and v2 especially if you are not that profinational scripter.
A different extension for v2 has already been discussed at length multiple times and decided against by the primary AHK developer.

SMG
Posts: 1
Joined: 11 Nov 2016, 09:22

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by SMG » 09 Dec 2023, 04:52

I was going to make a longwinded post arguing for better compatibility with v1 scripts. And yeah, there is room for improvement there. But fundamentally, I can see it from the dev point of view and I'm on their side on this one. They have worked on V2 for 10 years, cleaning up all the mistakes of the past to make it consistent. They don't want to deal with the warts of V1 anymore and move on. V2 is a mature and consistent.

Anyone who legitimately needs to keep scripts at V1 because their project is just too big to change or they don't have time or whatever can simply download the AHK v1.1 portable version and force their scripts to use that version. There might be more v1.1 updates if they are lucky, but being slightly outdated should not be an issue since there isn't really any security on AHK anyway. If anything, it protects their script from any breaking changes, and if there is another update, they can update the portable version after testing.

As far as 'room for improvement' goes, I would:
  • echo calls for the AutoHotKey v1 forums to have a prominent banner displayed across the top to the effect of "This forum is for AutoHotkey 1.x, which could have a different Syntax to AutoHotkey 2.x. Please take care when using code samples as they may not work in 2.x"
  • make launcher.ahk should be self-contained .exe (i.e. launcher.exe) so easy to point an .ahk at it via command line and it will run the right version (v11/v2/x86/x64 etc.) rather than chaining AHK + launcher + the ahk in question
  • v1.1 & v2, ahk2exe, etc. bundled with the launcher already, rather than separate downloads (only adds a few MBs and less hassle/user prompts)
  • Launcher default to v1.1 if no #Requires v2 is present. #Requires is fairly new so good assumption it is a v1 script if it doesn't have it. Avoids prompting user
  • #Requires v2 should be a REQUIREMENT for all v2 scripts. Not optional. Makes it clear what kind of script is being viewed.

User avatar
joedf
Posts: 8986
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: AutoHotkey v2 Official Release Announcement - Q&A

Post by joedf » 11 Apr 2024, 09:41

Hi all, I will be removing the v2 banner on the homepage and the v1.1 download link soon. I am thinking to do this either on April 16th or end of the month, since it will be 1 month since the v1.1 End of life: viewtopic.php?f=24&t=127382
I will go ahead with this unless I hear any objections. Btw, I know I still have to tweak the syntax highlighting for v2 :mrgreen:
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]

Post Reply

Return to “About This Community”