Jump to content
Sign in to follow this  

IUIAutomation Problem

Recommended Posts


Hey Guys,

I got stuck with a problem here. It's the first time I'm using the UIAutomation but I got it working for me.
I wrote myself a function which starts a Python Console in an external program. Here is the function:


Func _start_python()
    $oPyButton=_UIA_getFirstObjectOfElement($UIA_oDesktop,"class:=" & $XTPToolBar, $treescope_children)

    if isobj($oPyButton) Then
        $oButton=_UIA_getFirstObjectOfElement($oPyButton,"name:=" & $PyButton, $treescope_subtree)
        $pyHandle = WinGetHandle("Python")
        WinSetState("Python", "", @SW_HIDE)
        Return $pyHandle

So my problem is that it is only working as long as the $XTPToolBar="Afx:00310000:b:00010003:00000006:010F01BB" is valid.
With every restart of the program this handle changes. The question now is, how can I retrieve it automatically.

Since now I used the Simple Spy tool to get it, but I want to make it work on it's own. But I can't understand the Simple Spy program in detail and can't figure out, how to extract just this part out of the program .. :/

Maybe you can help me with this :)


And something different on the side. The UIIAutomation draws red borders around the object it is currently inspecting. Not just when using Simple Spy. I want to get rid of them, because I can't iamgine that those are really needed for functionallity. And I don't want the user to see those things .. Do you know which part of the UDF I have to remove? I allready got rid of the logging function, but I still can't find this part in the scripts ..


Thanks in advance :)

Kind regards,

Share this post

Link to post
Share on other sites

Ok .. well .. I figured it out myself :D


Here's the solution:


Quellcode bearbeiten
  1. _WinAPI_GetClassName($hwnd)


 $hwnd is the handle of the program, retrieved through WinGetHandle()

Relatively easy and I don't have to use the UDF


But the thing with removing the red bars is still a thing though :)

Edited by Leo1906

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.