UIA Automation - Inspect.exe for AHK
Posted: 05 Mar 2017, 19:09
A bit of history
So I first came across UIA while looking for better ways to automate the user interfaces of other applications which were not based off Win32 forms. The thread I found was this one. The thread offers a method of finding text anywhere without the use of an OCR. Or rather, it can "see text" in many other places other than just Win32 forms like the AHK_Spy for example. After testing it on some non-win32 forms I found that it could extract information from these UIs that no other AHK function could. This peaked my interest as you can imagine.
In the thread Jethrow and nepter develop a IUIAutomation Interface. And I knew that when i was automating software of this kind I should refer to this library... A few months passed and here I am back looking at it. I've been extending an application that Nepter created - A GUI Cloner a lot like the Windows Inspect.exe which is provided in the Windows SDK. When I first adopted the application it was incredibly compact, but very messy and difficult to understand. It also lacked functionality I wanted. So I began to extend it.
Inspect.ahk
You can find the Inspect.ahk here:
https://github.com/sancarn/Inspect.exe_AHK
The original made by nepter can be found here.
Download both inspect.ahk and uia.ahk
To inspect a Window press {F8}.
Possible features for the future:
- Sample code generator for targeting specified element with the library.
- UIA TreeView to be generated on mouse move/hover (like AHK_Spy).
- More information to be extracted where useful.
- Draw a rectangle around selected tree element.
Even though this code is just reinventing the wheel, this is an extremely powerful learning tool and has the usual advantages of being written directly in AHK.
Happy scripting!
So I first came across UIA while looking for better ways to automate the user interfaces of other applications which were not based off Win32 forms. The thread I found was this one. The thread offers a method of finding text anywhere without the use of an OCR. Or rather, it can "see text" in many other places other than just Win32 forms like the AHK_Spy for example. After testing it on some non-win32 forms I found that it could extract information from these UIs that no other AHK function could. This peaked my interest as you can imagine.
In the thread Jethrow and nepter develop a IUIAutomation Interface. And I knew that when i was automating software of this kind I should refer to this library... A few months passed and here I am back looking at it. I've been extending an application that Nepter created - A GUI Cloner a lot like the Windows Inspect.exe which is provided in the Windows SDK. When I first adopted the application it was incredibly compact, but very messy and difficult to understand. It also lacked functionality I wanted. So I began to extend it.
Inspect.ahk
You can find the Inspect.ahk here:
https://github.com/sancarn/Inspect.exe_AHK
The original made by nepter can be found here.
Download both inspect.ahk and uia.ahk
To inspect a Window press {F8}.
Possible features for the future:
- Sample code generator for targeting specified element with the library.
- UIA TreeView to be generated on mouse move/hover (like AHK_Spy).
- More information to be extracted where useful.
- Draw a rectangle around selected tree element.
Even though this code is just reinventing the wheel, this is an extremely powerful learning tool and has the usual advantages of being written directly in AHK.
Happy scripting!