What are the main challenges of switching to v2?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
User avatar
Cr8zy_Ivan
Posts: 131
Joined: 30 Mar 2019, 18:20

What are the main challenges of switching to v2?

11 May 2023, 11:43

I've been putting off switching to v2 for a while now. Just as a general overall question, what are the main differences or challenges you have faced when switching from v1 to v2?

Any insights would be greatly appreciated.

Cheers!
User avatar
mikeyww
Posts: 27214
Joined: 09 Sep 2014, 18:38

Re: What are the main challenges of switching to v2?

11 May 2023, 13:38

Hello,

This question has been asked and discussed many times here in the forum-- at great length-- so you might find it useful to read those posts. In terms of differences, there is also an extensive changelog already posted online.
RussF
Posts: 1298
Joined: 05 Aug 2021, 06:36

Re: What are the main challenges of switching to v2?

11 May 2023, 13:48

For me, and I'm still learning V2, the easiest thing is the universal use of expressions. This is something I struggled with when first learning V1 by having to determine when and where I needed the infamous % signs. Expression driven coding is something I am used to, coming from other languages.

The most difficult thing for me so far has been managing GUIs with the OOP style use of methods and properties. I'm getting there, though! I still feel it is far superior to V1.

I have to admit, though, while I understand the removal of GoSub since every subroutine is essentially a function, I question the continuance of GoTo. I haven't used GoTO since my early days with Applesoft BASIC and GWBASIC, where you had no choice. Once I learned Pascal and dBase, and BASIC finally evolved into a more structured language, I never used it again. Ever. I maintain that ANY program can be written without it as long as you can properly structure your code with versatile loops and user-defined functions. Don't use it, you don't need it and it will only get you in trouble.

My $0.02 worth.

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

Re: What are the main challenges of switching to v2?

11 May 2023, 13:53

Cr8zy_Ivan wrote:
11 May 2023, 11:43
I've been putting off switching to v2 for a while now. Just as a general overall question, what are the main differences or challenges you have faced when switching from v1 to v2?

Any insights would be greatly appreciated.

Two things seem quite a bit different. Objects and Gui.

v1 had one generic object that would be accessed with various different syntaxes. You could use object.element or object['element']. You could also use multi-dimensions easily; object['one', "two"].

v2 has three main types of objects for data:
  • Object (the base generic object which uses Properties, Methods, and Values)
  • Array (an extension of base object that uses a numbered Index and Values)
  • Map (an extension of base object that uses mapped pairs of string Keys and Values)
Each has its distinctive syntax.

It takes a little adjusting and modification of existing scripts, but it is not too bad to switch, and the new 'objects' give more abilities.

v1 and v2 Gui are very different syntax and structure. Many of the principles are the same so it is not starting from scratch, but it is a little bit of a learning curve.
Basically, v1 Gui was confusing and somewhat difficult with having to know many 'tricks'. v2 Gui are also somewhat confusing but at least there is more of a logic to things once you do get the hang of it. Converting Gui and events is somewhat time consuming.

There is a lot of other syntax differences but in my opinion v2 syntax is more logically and easier to remember and get correct.

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
Cr8zy_Ivan
Posts: 131
Joined: 30 Mar 2019, 18:20

Re: What are the main challenges of switching to v2?

04 Aug 2023, 07:16

Thank you so much @FanaticGuru and @RussF !!
User avatar
Cr8zy_Ivan
Posts: 131
Joined: 30 Mar 2019, 18:20

Re: What are the main challenges of switching to v2?

04 Aug 2023, 21:43

One question though, for you both, @FanaticGuru and @RussF.

My knowledge about coding is not as extensive as you both. What I'm understanding from your comments however is, V2 seems to be better structured, in terms of syntax. Other than that, are there other advantages? Any improvement, performance wise perhaps? Faster execution maybe?

One thing I keep struggling with in V1 is Key Hooking (I'm not sure if this is the right terminology). Instances where I assign a specific Hotkey to execute a task, and the native functionality of the App I'm using gets triggered instead of the Hotkey I've programmed. One Key that is notorious in my case is the WinKey. It isn't uncommon for me to get the Start menu pop up while I launch various Hotkeys.

Is V2 better in "retaining" control of the Keyboard? Perhaps V2 is just simply more efficient in terms of resources used?

I'm just a very curious and enthusiastic AutoHotkeyer, and interested to know what you think. In any case, I'm already grateful for your responses.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: bob65536, kunkel321, shipaddicted, songdg and 35 guests