ibn_maksimys Posted September 14 Share Posted September 14 Hi, all! At my Qt project I have QComboBox with fixed values. For switch values at AutoIt I try to use CUIAutomation2.au3, but value not changes. Anybody can to show me right way for such task? I solved task for editable ComboBox, but for fixed values I tried different combinations, but without success. Spoiler expandcollapse popup#include "CUIAutomation2.au3" Example_QCombobox() Func Example_QCombobox() FileChangeDir("C:\Users\user\Desktop\TestApp") Run("C:\Users\user\Desktop\TestApp\Test.exe") Sleep( 1000 ) ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "QComboBox", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pComboBox1, $oComboBox1 $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition0, $pComboBox1 ) $oComboBox1 = ObjCreateInterface( $pComboBox1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oComboBox1 ) Then Return ConsoleWrite( "$oComboBox1 ERR" & @CRLF ) ConsoleWrite( "$oComboBox1 OK" & @CRLF ) ; --- Value Pattern (action) Object --- ConsoleWrite( "--- Value Pattern (action) Object ---" & @CRLF ) Local $pValuePattern1, $oValuePattern1 $oComboBox1.GetCurrentPattern( $UIA_ValuePatternId, $pValuePattern1 ) $oValuePattern1 = ObjCreateInterface( $pValuePattern1, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValuePattern1 ) Then Return ConsoleWrite( "$oValuePattern1 ERR" & @CRLF ) ConsoleWrite( "$oValuePattern1 OK" & @CRLF ) ; --- Value Pattern (action) Methods --- ConsoleWrite( "--- Value Pattern (action) Methods ---" & @CRLF ) $sValue = "B" $oValuePattern1.SetValue($sValue) ConsoleWrite( "$oValuePattern1.SetValue()" & @CRLF ) ; --- Copy element info --- EndFunc Link to comment Share on other sites More sharing options...
junkew Posted Sunday at 03:44 PM Share Posted Sunday at 03:44 PM Probably hard as long as the application is not sharable. Maybe you could maken an example of the problem https://doc.qt.io/qtcreator/ FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
ibn_maksimys Posted Monday at 06:19 AM Author Share Posted Monday at 06:19 AM junkew, hello! Thank you for reply! The test application can be downloaded from the link https://dropmefiles.com/dt2AR Link to comment Share on other sites More sharing options...
junkew Posted Monday at 06:28 PM Share Posted Monday at 06:28 PM I made a small window myself with 2 QtComboboxes one enabled and one not. Its not a straightforward setvalue and as an alternative then just setfocus and a sendkeys can do the trick either send the value or send a key down/up You have to play with different combinations like expand that seems to work/show the list of available choices (both comboboxes will react to expand even if disabled 😉 and show the list with choices and based on that you could send one or more keydown with sendkeys) As it recognizes the controls itself you can reach it with setfocus and then using regular sendkeys to get to right selection. Apparently its not reacting to setvalue or iaccessible.setvalue (I mainly tried with inspect.exe and assume the spytool as made by @LarsJ will not give different results) FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
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