Leo1906 Posted June 2, 2016 Posted June 2, 2016 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
Leo1906 Posted June 2, 2016 Author Posted June 2, 2016 (edited) Ok .. well .. I figured it out myself Here's the solution: Quellcode Quellcode bearbeiten _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 June 2, 2016 by Leo1906
junkew Posted June 3, 2016 Posted June 3, 2016 Its a setting in the cfg file. Check for highlight phrase in the sources of uiautomation. I FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now