🚨 Upgrade to UIA v2: Uncover Secret 💡 for a Smoother Transition 🔜
Channel: AUTOHOTKEY Gurus
Date: 2023-02-14

In this video we take a cool UIA form-completion script written in v1 to using AutoHotkey version 2 which also means we had to switch to the UIA2 library which is packed with some great new methods!  Isaias chatted with Descolada and UIA V2 should be considered in "beta" now which means it will mainly be updates / patches and changes won't "break" things
Learn more about UIA here:  https://the-Automator.com/UIA
And get this script here:  http://the-Automator.com/UIAForm

Summary: Save time and optimize your automation process by using UIA elements, caching, and interrogating variables in local memory with the help of our discounted course.

1. 00:00 🤖 Ryan Wells wrote an AutoHotkey script to simplify web login/registration and we're offering a discount on our course to help you convert it to V2 with easy fixes for any issues.
 1.1 Ryan Wells, a auto hockey hero member, wrote a script with UIA and we are making a video to demonstrate how to convert it to V2 with a discount to our course.
 1.2 AutoHotkey script allows for quick and easy login/registration on webpages with generic details.
 1.3 You can quickly fix problems in V2 code by clicking on the red lines and getting a description of the issue.

2. 03:28 💡 Using functions with brackets and storing them in variables makes it easier to read and understand.
 2.1 Hotkeys now need brackets to indicate where they start and end, and everything is an expression so no need to force Expressions.
 2.2 Using a function without a specific parameter and storing it in a variable is clearer than the original Excel function Library.

3. 06:19 🔎 Use "Find Elements" with key-value pairs to target edit elements and create a simpler regular expression for a username with an optional space for easier automation.
 3.1 To use the UIA Library, the function "Find Elements" should be used instead of "Find First by Name".
 3.2 Pass an object with control type "edit" and name as the text, and match mode as "regex" to complete the condition.
 3.3 It's easier to read and more intuitive to use key-value pairs to set localized control type, match mode, and value, and automation can be used to target edit ones.
 3.4 Using a tool, it is easier to create a simpler regular expression that is case insensitive and matches a username with an optional space.

4. 10:43 🔎 Get our course on transitioning to V2 for half off  https://the-Automator.com/V1toV2Course
 4.1 Objects don't require a specific order when accessing values, making them a great choice for variables.
 4.2 Using AHK V2, you can easily structure your regex with parentheses and brackets on separate lines, making it easier to find patterns.
 4.3 When converting a script from one version to another, hotkeys and syntax must be changed, and the library being used may not exist.
 4.4 Once you get used to it, you can quickly find and replace words in a script, but testing it afterwards is the only problem.
 4.5 Get our course on transitioning to V2 for half off with the URL below.

5. 15:30 🐛 Isaiah has fixed bugs and condensed regular expressions to make UIA more reliable and flexible, using Find Element 99% of the time and element exist for if statements.
 5.1 Isaiah is close to finishing the Alpha version of UIA and has fixed bugs and condensed regular expressions to match his full name.
 5.2 You can easily add new rules to strings and apply the value of ridges to allow for multiple variants without having to touch the code.
 5.3 Matching everything with a question mark allows for more flexibility.
 5.4 Use Find Element 99% of the time, as it is more reliable and supports features like regular expression matching.
 5.5 If you want to use an if statement, use the element exist method which returns true or false.
 5.6 Use element exist to conditionally treat objects and try statements to avoid errors if elements don't exist.

6. 21:30 💡 Optimize your automation process by using UIA elements, caching, and interrogating variables in local memory to ensure you are seeing the most up-to-date version.
 6.1 You can use any window title as a UIA element, eliminating the need to use win exist or find element.
 6.2 Using a cache to store name and type of elements instead of using find element can significantly speed up the process.
 6.3 Create a variable in local memory, interrogate it, and act on it instead of querying.
 6.4 To ensure you are seeing the most up-to-date version of an element, you must clear your cache and rebuild it.

7. 26:06 💰 Save money by having two properties instead of all of them, but be aware that changes may not be reflected in the cached version.
 7.1 Build cash by having two properties instead of all of them.
 7.2 A cache is a snapshot of the elements on a page, which can be used to speed up searches.
 7.3 Changes made to a cached version of data may not be reflected in the snapshot.

8. 30:04 ✅ UIA Library syntax has changed, so check out the UIA page for videos on the updates.