Why would I switch to version 2.0?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Albireo
Posts: 1749
Joined: 16 Oct 2013, 13:53

Why would I switch to version 2.0?

Post by Albireo » 27 Mar 2023, 15:08

So far I don't think I had any limitation in v1.0 (but maybe that's because I don't know what v2.0 adds)

User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: Why would I switch to version 2.0?

Post by mikeyww » 27 Mar 2023, 16:02

The choice is yours. Here is what it adds. https://www.autohotkey.com/docs/v2/v2-changes.htm

AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: Why would I switch to version 2.0?

Post by AHK_user » 27 Mar 2023, 16:18

Guis are easier to handle, and you do not have to remember anymore if the parameters of the command need to be written in literal text or expressions.
It is more logical.

Beware, once you taste it, you will probably never go back...

User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: Why would I switch to version 2.0?

Post by FanaticGuru » 27 Mar 2023, 16:26

Albireo wrote:
27 Mar 2023, 15:08
So far I don't think I had any limitation in v1.0 (but maybe that's because I don't know what v2.0 adds)

I like the more consistent syntax with pretty much everything being a function or object. After the learning curve, I believe I will be able to code faster in v2. Also, I believe I will be able to develop a stronger library of code that is more flexibly and modular to reuse in new scripts.

I have seen some pretty cool things with prototype that was not really doable in v1. I imagine over time there will be a lot of example code out there that expand or alter how AHK's builtin functions work. If you don't like the way objects work, then change them with prototype. If you want SplitPath to use properties instead of ByRef variables to get the results, change the prototype.

Switching from v1 to v2 is not all that hard if you just start making all your new stuff in v2 and not worry so much about converting all your v1 code. I just convert a little v1 to v2 here and there and it is not that overwhelming. Often the converted code ends up better just because I code better now than I did 5 or 10 years ago. I use a mix of v1 and v2 scripts running all the time now. If v1 is doing what you need and you are not really interested in learning v2, I don't think there is any reason to force yourself to switch to v2. v1 is probably going to stay popular with many people for years.

The two biggest differences at converting code for me is Gui has totally changed. Old way was a mess and new way is still pretty complicated. And scope of variables as now everything in hotkeys is local and there is no superglobal. But you can just put global everywhere when not sure and get a similar result and then over time start leaving most things local and only making global the few that actual need it.

Converting objects was a bit of a hump but I have gotten over that hump of where objects are now mostly three types of objects, arrays, and maps which each behaving a little differently.

I am very happy with the switch. My code is getting cleaner and more uniform. Being 'good' at coding in v1 seemed like knowing a bunch of tricks, while being 'good' at coding in v2 seems like knowing best practices of how to do things.

Another downside that will probably improve over time is v2 documentation has a technical feel to it. Kind like a MSDN technical reference for experienced programmers. Not that bad, but in that vein. It could really use more 'simple' examples. It really needs like beginner, intermediate, and advanced examples. I don't even know who all contributes to the documentation, overall, they have done an incredible job covering so much information. Maybe there just needs to be a supplemental examples document. Now I will often read something in the v2 docs then immediately google for some real-world example code. In a couple of years thought there will be lots of additional resources out there. It will get much easier to google examples and solutions.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks

User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: Why would I switch to version 2.0?

Post by mikeyww » 27 Mar 2023, 17:23

I agree overall, and I'd say that not having to deal with forced expressions and output variables as command parameters has been a bonus. Changing labeled subroutines into functions was also a fairly big change for me. Nonetheless, with a bit of practice, all of this has become easier and ultimately faster and simpler than coding in v1.

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Why would I switch to version 2.0?

Post by swagfag » 27 Mar 2023, 18:03

had u started out with v2 would have probably spared u having to make 500 threads where people explain to u when and when not to use %% inside expressions (as well as a multitude of other v1 quirks that u probably had no interest in knowing or learning about as u were coding up the solution to whatever problem u were trying to solve at the time. i know i didnt)

at most, it would have taken 2 threads

User avatar
NPerovic
Posts: 34
Joined: 31 Dec 2022, 01:25
Contact:

Re: Why would I switch to version 2.0?

Post by NPerovic » 02 Apr 2023, 04:24

Albireo wrote:
27 Mar 2023, 15:08
So far I don't think I had any limitation in v1.0 (but maybe that's because I don't know what v2.0 adds)
No limitation is just for now if you know what does deprecated means.

You don't know if what you can do now will not be possible after the next WINDOWS update.

As V2 is now the official version, that means v2 will keep-up-date in the future, and you can't expect anything from a deprecated version v1 anymore.

And the most important thing is that you don't need to convert everything you have to v2. Just try v2 from your next new script.

I really don't think anyone would insist on staying in V1 after trying V2. Unless you are not interested in anything new, and you don't care about the technology or anything that is rapidly changing. It is entirely your freedom to stay in V1.

Just like some people who are still using WIN 7. I don't know what they are thinking, but it is their freedom to choose to stay with the old stuff.
Collection of My AHK v2 Scripts
⭐ DarkThemeListView.ahk - Dark Theme ListView Control
⭐ KeyboardLayout.ahk - Switching between Keyboard Layouts
⭐ Dark_WindowSpy.ahk - Dark Theme Window Spy
⭐ SystemThemeAwareToolTip.ahk - Tooltip with System Theme Awareness
⭐ MouseHook.ahk - Tool for Intercepting Mouse Events
⭐ ToolTipEx.ahk - Extension for Custom Tooltips

Post Reply

Return to “Ask for Help (v2)”