🚀 Boost your AutoHotkey power - Share variables & methods with other languages!
Channel: AUTOHOTKEY Gurus
Date: 2022-09-15

In this video we show you the most robust, fast and flexible way to share: Variables, Methods, Data, etc. between AutoHotkey scripts.  This can allow other languages like Python, Visual Basic, C++ etc. to use your AutoHotkey methods!  Such an amazing and cool approach!

You can get the resources and scripts here: https://the-Automator.com/ObjConnect

TLDR: Lexico's Object Register Active function allows for the sharing of variables, methods, and data across scripts using objects, workers, and COM objects.

1. 00:00 🔑 Create an object, name it, and register it with an ID to use Lexico's Object Register Active function for sharing variables, methods, and data across scripts.
 1.1 Object Register Active is a function created by Lexico's in 2015 that allows for the sharing of variables, methods, and data across scripts.
 1.2 You need to call a function to get a global unique identifier for your COM object, but you only need to do it once.
 1.3 Create an object, name it, and register it with an ID.

2. 03:42 🤖 Use a worker class to run tasks in the background and register the object to share with Windows.
 2.1 A worker class or object can be used to run a task in the background, notifying the main script when a file changes or a variable is set.
 2.2 To share an object with Windows, your script must register the object and be running in order for the registration to work.

3. 06:25 🚀 F1 starts an autohotkey object, F2 stops it, and line 8 activates a comm object in Python to send a message to an object.
 3.1 F1 starts the autohotkey object, F2 stops it, and line 8 activates a comm object in Python.
 3.2 Python code sends a message to an object to do the actions, not Python itself.

4. 07:57 🔮 Reverse engineering COM objects can be done using classes and dot notation, but requires good documentation and the object must be running first.
 4.1 Using classes and dot notation, you can reverse engineer the voodoo of COM objects.
 4.2 Creating an object requires good documentation so users know what methods are available.
 4.3 To connect to an object, the object must be running first and then the main script can be run to access it.

5. 10:47 🤔 Set variables in an object to communicate between multiple scripts and check if it is running or not.
 5.1 Pressing F1, F2, and F3 will show the current position, start/stop the worker thread, and tell if the worker thread is running, respectively.
 5.2 I can set a variable in VS Code and get a message box when I press F1 to show the new variable is set.
 5.3 Two scripts can communicate with each other by setting variables in an object and reacting to them.
 5.4 You can use an object to communicate between multiple scripts, setting variables and checking if it is running or not.

6. 15:54 🔒 Creating a mutex object and releasing it when finished allows multiple scripts to access the same method without conflicting.
 6.1 A mutex object is used to prevent race conditions when multiple processes attempt to access the same resource.
 6.2 Create a mutex when starting, release it when finished, and use it to prevent race conditions in a loop.
 6.3 Creating a mutex object and releasing it when finished allows multiple scripts to access the same method without conflicting.

7. 19:11 🔒 Connecting to a COM object returns a worker object, creating two different objects from the same class.
 7.1 SQLite uses a mutex object to prevent multiple users from accessing the same resource.
 7.2 Connecting to a COM object returns an object called worker, creating two different objects from the same class blueprint.

8. 20:58 💡 Create objects based on variables to quickly communicate between scripts in different languages.
 8.1 The same blueprint is used for multiple objects, allowing communication between scripts.
 8.2 You can use a normal method to create an object depending on a variable, such as type, and return a sub object.
 8.3 We can quickly communicate between scripts in different languages using objects to set and check variables.


Summary for https://youtu.be/VqsKwH1arbo by www.eightify.app