codeninja Posted December 19, 2013 Share Posted December 19, 2013 Hi, How can i get the information about the selected control in windows form? Thanks, --SJ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2013 Moderators Share Posted December 19, 2013 codeninja,If the control accepts keyboard input then you could try _WinAPI_GetFocus. 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 Link to comment Share on other sites More sharing options...
codeninja Posted December 19, 2013 Author Share Posted December 19, 2013 (edited) Hi Melba, It returns 0x0...0 probably it means failure. FYI, My control is located inside the infragistics grid-view control.(By using window info i could not identify its name because it present inside the grid-view) I attached the sample grid view of mine. in this grid i can select total combo-box but i can't modify the selected item? How can i modify the selected item of combo-box? Thanks, --SJ codeninja, If the control accepts keyboard input then you could try _WinAPI_GetFocus. M23 Edited December 19, 2013 by codeninja Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2013 Moderators Share Posted December 19, 2013 codeninja,It sounds as if that control is user-drawn and so not accessible via the Windows API. Hence Autoit will not be able to automate it using the standard functions. M23 codeninja 1 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 Link to comment Share on other sites More sharing options...
codeninja Posted December 19, 2013 Author Share Posted December 19, 2013 (edited) Thanks for your support, and one more question is, I can read the text-box value by sending ctrl+c key stroke inside the grid and i would like to read combo-box selected item too. How can i read the selected item from the combo-box which is present inside the same grid-view? is their any key board short cut to do this? --SJ Edited December 19, 2013 by codeninja Link to comment Share on other sites More sharing options...
orbs Posted December 19, 2013 Share Posted December 19, 2013 are you able to focus on the combo box, as discussed in previous thread? '?do=embed' frameborder='0' data-embedContent>> if so, and if the combo box behaves as a combo box should behave, then by sending down arrow you would open the drop-down list, then by sending some more arrows and Enter will change the value. or better still, if you know what you want to put in, just send the string, it shoudl even auto-complete as you "type". codeninja 1 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
orbs Posted December 19, 2013 Share Posted December 19, 2013 Thanks for your support, and one more question is, I can read the text-box value by sending ctrl+c key stroke inside the grid and i would like to read combo-box selected item too. How can i read the selected item from the combo-box which is present inside the same grid-view? is their any key board short cut to do this? --SJ if the combo box is not read-only then Ctrl+C will do it. otherwise it requires some extra thinking... codeninja 1 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
codeninja Posted December 19, 2013 Author Share Posted December 19, 2013 Hi orbs, I can select combo-box control inside the grid-view by implementing mouse click based on grid-view co-ordinates. Now, i would like to read the selected text of combo-box? do you know any short cut keys to perform this action. Thanks --SJ Link to comment Share on other sites More sharing options...
orbs Posted December 19, 2013 Share Posted December 19, 2013 does your combo box look like the 1st or the 2nd in this screenshot? if it's like the 1st, then Ctrl+C should do it. otherwise it may be not possible, and i guess you'll have to ask yourself "do i really need to read the value? can i work without reading the value?" codeninja 1 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
codeninja Posted December 19, 2013 Author Share Posted December 19, 2013 does your combo box look like the 1st or the 2nd in this screenshot? combo.png if it's like the 1st, then Ctrl+C should do it. otherwise it may be not possible, and i guess you'll have to ask yourself "do i really need to read the value? can i work without reading the value?" Thank You. I Agree Link to comment Share on other sites More sharing options...
jdelaney Posted December 19, 2013 Share Posted December 19, 2013 (edited) Sometimes, you can luck out, and use the wrapping control as the parent (must be a handle) in the function: WinGetClassList example of use: expandcollapse popup#include <Array.au3> Func Var_GetAllWindowsControls($hCallersWindow) ; Get all list of controls $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) If IsArray($aPos) Then ConsoleWrite("Func=[Var_GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] Text=[" & $text & "]." & @CRLF) Else ConsoleWrite("Func=[Var_GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>Var_GetAllWindowsControls Edited December 19, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
LarsJ Posted December 19, 2013 Share Posted December 19, 2013 To automate these Infragistics controls you need the Microsoft UI Automation framework. You find an AutoIt implementation in this example.From the Infragistics website here (search for "ui automation"):"The Infragistics WPF suite of controls fully support Microsoft UI Automation. ...Another key use of UI Automation is automated testing; the framework allows test scripts to access and interact with the UI elements." codeninja 1 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 Link to comment Share on other sites More sharing options...
codeninja Posted December 20, 2013 Author Share Posted December 20, 2013 (edited) To automate these Infragistics controls you need the Microsoft UI Automation framework. You find an AutoIt implementation in this example. From the Infragistics website here (search for "ui automation"): "The Infragistics WPF suite of controls fully support Microsoft UI Automation. ... Another key use of UI Automation is automated testing; the framework allows test scripts to access and interact with the UI elements." Hi LarsJ, Thanks for your idea. Is this possible to integrate AutoIt script with MS UI Automation Framework? my question maybe weird but i don't know how to do this. --SJ Edited December 20, 2013 by codeninja Link to comment Share on other sites More sharing options...
codeninja Posted December 20, 2013 Author Share Posted December 20, 2013 Sometimes, you can luck out, and use the wrapping control as the parent (must be a handle) in the function: WinGetClassList example of use: expandcollapse popup#include <Array.au3> Func Var_GetAllWindowsControls($hCallersWindow) ; Get all list of controls $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) If IsArray($aPos) Then ConsoleWrite("Func=[Var_GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] Text=[" & $text & "]." & @CRLF) Else ConsoleWrite("Func=[Var_GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>Var_GetAllWindowsControls Hi jdelaney, I have tried this method but it does not return the controls which is present inside the infragistics grid-view. --SJ Link to comment Share on other sites More sharing options...
LarsJ Posted December 20, 2013 Share Posted December 20, 2013 (edited) codeninja, Download the UDFs here and download and run the code in the "Simple spy demo" code box in the middle of the first post. Then click the Grid control (to set focus) and press Ctrl+w. You'll see info in the edit box.To print all controls (including non-visible) in Scite console run the code in post 71.You can also run the UISpy.exe (old) or Inspect.exe (new) tools from Microsoft. If you can get information with these tools you know that the controls can be handled with the Microsoft UI Automation framework. Edited December 20, 2013 by LarsJ codeninja 1 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 Link to comment Share on other sites More sharing options...
codeninja Posted December 20, 2013 Author Share Posted December 20, 2013 Hi LarsJ I get following information about the text box control which is present inside the infragistics grid-view Mouse position is retrieved 478-419 At least we have an element [][WindowsForms10.EDIT.app.0.2780b98_r13_ad1] Having the following values for all properties: Title is: <> Class := <WindowsForms10.EDIT.app.0.2780b98_r13_ad1> controltype:= <UIA_EditControlTypeId> ,<50004> , (0000C354) *** Parent Information *** Title is: <> Class := <WindowsForms10.Window.8.app.0.2780b98_r13_ad1> controltype:= <UIA_TableControlTypeId> ,<50036> , (0000C374) The spy demo can identify the all the control types which could not possible by Windows info tool. But,it could not help to identify the unique name of the selected control as well as selected text of the control. but, many thanks for your "spy demo" reference its highly useful. How to run the code in post 71? what do you mean by post 71? ["To print all controls (including non-visible) in Scite console run the code in post 71."] Thanks --SJ Link to comment Share on other sites More sharing options...
LarsJ Posted December 20, 2013 Share Posted December 20, 2013 (edited) You should verify with UISpy.exe or Inspect.exe that you can get the information you need.In the gray bar just above this text you see the post or reply number (#17) to the right (my name is at the left side). In the UI Automation example by junkew then find post/reply #71. Probably at page 4. Edited December 20, 2013 by LarsJ codeninja 1 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 Link to comment Share on other sites More sharing options...
codeninja Posted December 20, 2013 Author Share Posted December 20, 2013 You should verify with UISpy.exe or Inspect.exe that you can get the information you need. In the gray bar just above this text you see the post or reply number (#17) to the right (my name is at the left side). In the UI Automation example by junkew then find post/reply #71. Probably at page 4. Hi LarsJ Thanks for your clarification and i got the response by using script mentioned on post #17 , ;Response snippet of my grid-view control Title = Column1 Class = Ctrl type = 50025 Ctrl name = Selected = False Handle = 00000000 I am excited after seeing this result . Now i get some more confident to solve this problem. How can they read the text inside the grid-view column? Is this possible to implement same thing to my controls(text-box|combo-box|button)? i also attached my grid-view for your reference --SJ Link to comment Share on other sites More sharing options...
junkew Posted December 20, 2013 Share Posted December 20, 2013 Infragistics seems to be having full support for ui automation and as such you should be able to get to the grid interfaces to get the details unfortunately I do not have a demo application available to check / enhance the AU3 ui automation UDF but see these links http://help.infragistics.com/Help/Doc/WPF/2012.1/CLR4.0/html/Developers_Guide_UI_Automation_Support.html http://www.infragistics.com/help/windows-forms/Coded_UI_Test_Extension_Overview.html http://www.infragistics.com/help/windows-forms/Using_the_Coded_UI_Test_Extension.html codeninja 1 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...
codeninja Posted December 20, 2013 Author Share Posted December 20, 2013 Infragistics seems to be having full support for ui automation and as such you should be able to get to the grid interfaces to get the details unfortunately I do not have a demo application available to check / enhance the AU3 ui automation UDF but see these links http://help.infragistics.com/Help/Doc/WPF/2012.1/CLR4.0/html/Developers_Guide_UI_Automation_Support.html http://www.infragistics.com/help/windows-forms/Coded_UI_Test_Extension_Overview.html http://www.infragistics.com/help/windows-forms/Using_the_Coded_UI_Test_Extension.html Hi, I would like to do UI automation test by using AutoIt+Cucumber, Its not my requirement to do it by infragistics coded UI test. Thanks for your help --SJ 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