Jump to content

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()
    WinKill("Python")
    $XTPToolBar="Afx:00310000:b:00010003:00000006:010F01BB"
    $PyButton="Python"
    $oPyButton=_UIA_getFirstObjectOfElement($UIA_oDesktop,"class:=" & $XTPToolBar, $treescope_children)

    if isobj($oPyButton) Then
        _UIA_DumpThemAll($oPyButton,$treescope_subtree)
        $oButton=_UIA_getFirstObjectOfElement($oPyButton,"name:=" & $PyButton, $treescope_subtree)
        $oInvokeP=_UIA_getpattern($oButton,$UIA_InvokePatternID)
        $oInvokeP.Invoke
        WinWaitActive("Python")
        $pyHandle = WinGetHandle("Python")
        WinSetState("Python", "", @SW_HIDE)
        sleep(1000)
        Return $pyHandle
    EndIf
EndFunc

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,
Leo

Link to comment
Share on other sites

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

 

Here's the solution:

Quellcode

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...