Tej Posted June 9, 2014 Posted June 9, 2014 Hi All, I have a UI which has window text using that i am able to control it. But there are few numeric updown with a default value and i want to change them to a different value. Using autoit info tool it doesnt have property called "Value" which is the property holding item. Please help me how to control that. Here the instance is always changing when i close and reopen the UI. Class name is same for all numeric updown files. >>>> Control <<<< Class: WindowsForms10.Window.8.app.0.33c0d9d Instance: 32 ClassnameNN: WindowsForms10.Window.8.app.0.33c0d9d32 Name: nupPllActive Advanced (Class): [NAME:nupPllActive] ID: 461968 Text: Position: 419, 93 Size: 51, 20 ControlClick Coords: 28, 18 Style: 0x56010000 ExStyle: 0x00010000 Handle: 0x0000000000070C90 Waiting for help thanks tej
wakillon Posted June 9, 2014 Posted June 9, 2014 You will have more chances to get an answer by using the Help forum ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
Moderators Melba23 Posted June 9, 2014 Moderators Posted June 9, 2014 Tej,Welcome to the AutoIt forum. But please pay attention to where you post - the "Examples" section where you started this thread is clearly marked: "This is NOT a general support forum!". I have moved it for you, but would ask you to be more careful in future. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
jguinch Posted June 9, 2014 Posted June 9, 2014 Did you try ControlSend / ControlSetText ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Tej Posted June 12, 2014 Author Posted June 12, 2014 Can anybody help on the numeric up and down please?
Tej Posted June 12, 2014 Author Posted June 12, 2014 Hi jguinch, I have tried but of no use. I believe control send is not having access to change "value" of numeric up and down as "Text" property is null for numUPDown control Appreciate your help. Please let me know if you can give an example i will let you know the feedback. ControlSetText($hWnd, "", "[NAME:nupPllActive]", "") Local $sText = ControlGetText($hWnd, "", "[CLASS:WindowsForms10.EDIT.app.0.33c0d9d; INSTANCE:8]") Local $sText = ControlGetText($hWnd, "", "WindowsForms10.EDIT.app.0.33c0d9d8") ControlSend("My parameters", "", "[NAME:nupPllActive]", "{DEL 3}6") ControlSetText("My parameters", "", "nupPllActive", "77") None of the above worked Let me know if something is wrong above.
LarsJ Posted June 12, 2014 Posted June 12, 2014 This can be done with the UI Automation framework. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
Tej Posted June 13, 2014 Author Posted June 13, 2014 Hi Larsj, Thanks a lot! That looks like a champion code.. i tried the script but of no help may be as i am new to it. There are 2 sections if i choose combox box i can grep with property name no value is shown and if i choose edit box its vice versa. How to fix this? For combo box.docx
LarsJ Posted June 15, 2014 Posted June 15, 2014 Here is a small example (included in the zip below, exe + dll) with a WindowsForms10 numeric up-down control.This code walks through all UI elements in the window:expandcollapse popup#include "CUIAutomation2.au3" Opt( "MustDeclareVars", 1 ) Global $oUIAutomation MainFunc() Func MainFunc() Local $hWindow = WinGetHandle( "NumericUpDown Cell/Col. Sample" ) If Not $hWindow Then Return $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return Local $pWindow ;$oUIAutomation.GetRootElement( $pWindow ) ; Desktop $oUIAutomation.ElementFromHandle( $hWindow, $pWindow ) ; Window If Not $pWindow Then Return Local $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow ) Then Return ;ListDescendants( $oWindow, 0, 1 ) ; Desktop ListDescendants( $oWindow, 0, 0 ) ; Window EndFunc Func ListDescendants( $oParent, $iLevel, $iLevels = 0 ) If Not IsObj( $oParent ) Then Return If $iLevels And $iLevel = $iLevels Then Return Local $pRawWalker, $oRawWalker $oUIAutomation.RawViewWalker( $pRawWalker ) $oRawWalker = ObjCreateInterface( $pRawWalker, $sIID_IUIAutomationTreeWalker, $dtagIUIAutomationTreeWalker ) Local $pUIElement, $oUIElement $oRawWalker.GetFirstChildElement( $oParent, $pUIElement ) $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) Local $sIndent = "" For $i = 0 To $iLevel - 1 $sIndent &= " " Next While IsObj( $oUIElement ) ConsoleWrite( $sIndent & "Title = " & _UIA_getPropertyValue( $oUIElement, $UIA_NamePropertyId ) & @CRLF & _ $sIndent & "Class = " & _UIA_getPropertyValue( $oUIElement, $UIA_ClassNamePropertyId ) & @CRLF & _ $sIndent & "Ctrl type = " & _UIA_getPropertyValue( $oUIElement, $UIA_ControlTypePropertyId ) & @CRLF & _ $sIndent & "Ctrl name = " & _UIA_getPropertyValue( $oUIElement, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _ $sIndent & "Value = " & _UIA_getPropertyValue( $oUIElement, $UIA_LegacyIAccessibleValuePropertyId ) & @CRLF & _ $sIndent & "Handle = " & Hex( _UIA_getPropertyValue( $oUIElement, $UIA_NativeWindowHandlePropertyId ) ) & @CRLF & @CRLF ) ListDescendants( $oUIElement, $iLevel + 1, $iLevels ) $oRawWalker.GetNextSiblingElement( $oUIElement, $pUIElement ) $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) WEnd EndFunc Func _UIA_getPropertyValue( $obj, $id ) Local $tVal $obj.GetCurrentPropertyValue( $id, $tVal ) If Not IsArray( $tVal ) Then Return $tVal Local $tStr = $tVal[0] For $i = 1 To UBound( $tVal ) - 1 $tStr &= "; " & $tVal[$i] Next Return $tStr EndFuncAnd this is output in Scite console:expandcollapse popupTitle = ThousandsSeparator? Class = WindowsForms10.BUTTON.app.0.378734a Ctrl type = 50002 Ctrl name = check box Value = Handle = 00060274 Title = Set Class = WindowsForms10.BUTTON.app.0.378734a Ctrl type = 50000 Ctrl name = button Value = Handle = 00060270 Title = Get Class = WindowsForms10.BUTTON.app.0.378734a Ctrl type = 50000 Ctrl name = button Value = Handle = 00070248 Title = Minimum: Class = WindowsForms10.STATIC.app.0.378734a Ctrl type = 50020 Ctrl name = text Value = Handle = 00070282 Title = Minimum: Class = WindowsForms10.EDIT.app.0.378734a Ctrl type = 50004 Ctrl name = edit Value = 0 Handle = 0003030E Title = Set Class = WindowsForms10.BUTTON.app.0.378734a Ctrl type = 50000 Ctrl name = button Value = Handle = 000302F6 Title = Get Class = WindowsForms10.BUTTON.app.0.378734a Ctrl type = 50000 Ctrl name = button Value = Handle = 000302F8 Title = Maximum: Class = WindowsForms10.EDIT.app.0.378734a Ctrl type = 50004 Ctrl name = edit Value = 100 Handle = 000302FA Title = Set Class = WindowsForms10.BUTTON.app.0.378734a Ctrl type = 50000 Ctrl name = button Value = Handle = 00070224 Title = Get Class = WindowsForms10.BUTTON.app.0.378734a Ctrl type = 50000 Ctrl name = button Value = Handle = 0007026A Title = DecimalPlaces: Class = WindowsForms10.EDIT.app.0.378734a Ctrl type = 50004 Ctrl name = edit Value = 0 Handle = 0006025A Title = Set Class = WindowsForms10.BUTTON.app.0.378734a Ctrl type = 50000 Ctrl name = button Value = Handle = 0008026C Title = Get Class = WindowsForms10.BUTTON.app.0.378734a Ctrl type = 50000 Ctrl name = button Value = Handle = 00080226 Title = Maximum: Class = WindowsForms10.STATIC.app.0.378734a Ctrl type = 50020 Ctrl name = text Value = Handle = 0009026E Title = Increment: Class = WindowsForms10.EDIT.app.0.378734a Ctrl type = 50004 Ctrl name = edit Value = 1 Handle = 000302C2 Title = Increment: Class = WindowsForms10.STATIC.app.0.378734a Ctrl type = 50020 Ctrl name = text Value = Handle = 00070268 Title = DecimalPlaces: Class = WindowsForms10.STATIC.app.0.378734a Ctrl type = 50020 Ctrl name = text Value = Handle = 000202DE Title = DataGridView Class = WindowsForms10.Window.8.app.0.378734a Ctrl type = 50036 Ctrl name = table Value = Handle = 000202E0 Title = Class = WindowsForms10.Window.8.app.0.378734a Ctrl type = 50003 Ctrl name = combo box Value = Handle = 000202F2 Title = Spinner Class = WindowsForms10.Window.8.app.0.378734a Ctrl type = 50016 Ctrl name = spinner Value = Handle = 000202E8 Title = Up Class = Ctrl type = 50000 Ctrl name = button Value = Handle = 00000000 Title = Down Class = Ctrl type = 50000 Ctrl name = button Value = Handle = 00000000 Title = Class = WindowsForms10.EDIT.app.0.378734a Ctrl type = 50004 Ctrl name = edit Value = 7 Handle = 000202EA Title = Top Row Class = Ctrl type = 50025 Ctrl name = Value = Top Row Handle = 00000000 Title = Top Left Header Cell Class = Ctrl type = 50034 Ctrl name = header Value = Handle = 00000000 Title = NumericUpDown Column Class = Ctrl type = 50034 Ctrl name = header Value = NumericUpDown Column Handle = 00000000 Title = Row 0 Class = Ctrl type = 50025 Ctrl name = Value = 7 Handle = 00000000 Title = Row 0 Class = Ctrl type = 50034 Ctrl name = header Value = Handle = 00000000 Title = NumericUpDown Column Row 0 Class = Ctrl type = 50025 Ctrl name = Value = 7 Handle = 00000000 Title = Row 1 Class = Ctrl type = 50025 Ctrl name = Value = (Create New) Handle = 00000000 Title = Row 1 Class = Ctrl type = 50034 Ctrl name = header Value = Handle = 00000000 Title = NumericUpDown Column Row 1 Class = Ctrl type = 50025 Ctrl name = Value = (null) Handle = 00000000 Title = Class = Ctrl type = 50037 Ctrl name = title bar Value = NumericUpDown Cell/Col. Sample Handle = 00000000 Title = System Class = Ctrl type = 50010 Ctrl name = menu bar Value = Handle = 00000000 Title = System Class = Ctrl type = 50011 Ctrl name = menu item Value = Handle = 00000000 Title = Minimize Class = Ctrl type = 50000 Ctrl name = button Value = Handle = 00000000 Title = Maximize Class = Ctrl type = 50000 Ctrl name = button Value = Handle = 00000000 Title = Close Class = Ctrl type = 50000 Ctrl name = button Value = Handle = 00000000In the top of the picture you see a datagrid with a combo box and three rows. The combo box contains an edit control and a spinner. The spinner contains an up button and a down button. The top row is a header. The next row contains the value 7.This code shows how to find all edit elements:expandcollapse popup#include "CUIAutomation2.au3" Opt( "MustDeclareVars", 1 ) MainFunc() Func MainFunc() Local $hWindow = WinGetHandle( "NumericUpDown Cell/Col. Sample" ) If Not $hWindow Then Return ConsoleWrite( "Window handle ERR" & @CRLF ) ConsoleWrite( "Window handle OK" & @CRLF ) ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "UI Automation object ERR" & @CRLF ) ConsoleWrite( "UI Automation object OK" & @CRLF ) ; Get UI Automation element from window handle Local $pWindow, $oWindow $oUIAutomation.ElementFromHandle( $hWindow, $pWindow ) $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow ) Then Return ConsoleWrite( "Automation element from window ERR" & @CRLF ) ConsoleWrite( "Automation element from window OK" & @CRLF ) ; Condition to find Edit elements Local $pCondition $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_EditControlTypeId, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "Property condition ERR" & @CRLF ) ConsoleWrite( "Property condition OK" & @CRLF ) ; Find all Edit elements Local $pUIElementArray, $oUIElementArray, $iElements $oWindow.FindAll( $TreeScope_Descendants, $pCondition, $pUIElementArray ) ; <<<< Use your own $oWindow element <<<<<<<<<<< $oUIElementArray = ObjCreateInterface( $pUIElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray ) $oUIElementArray.Length( $iElements ) If Not $iElements Then Return ConsoleWrite( "Find Edit elements ERR" & @CRLF ) ConsoleWrite( "Find all Edit elements OK. Elements: " & $iElements & @CRLF ) ; Print values of the Edit elements Local $pEdit, $oEdit, $nValue For $i = 0 To $iElements - 1 $oUIElementArray.GetElement( $i, $pEdit ) $oEdit = ObjCreateInterface( $pEdit, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) $oEdit.GetCurrentPropertyValue( $UIA_ValueValuePropertyId, $nValue ) ConsoleWrite( "Value of Edit element " & $i & ": " & $nValue & @CRLF ) Next EndFuncNow you can try to adapt the code to your own window.NumericUpDown.7z Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
Tej Posted June 17, 2014 Author Posted June 17, 2014 Hi LarsJ, Thanks a lot for your valuable time and effort. I will work on it and revert to you. thanks
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