alex1990 Posted January 2, 2020 Share Posted January 2, 2020 I'm trying to write an automation script which clicks an item in a WinForms ComboBox. I am able to click the field and get the list to appear, but I cannot click the item in the list. I tried using the following code first ControlClick("MyProgram", "", "[ID:462328]") Sleep(1000) ControlClick("MyProgram", "", "[TEXT:API_PERFORMANCE]") This correctly opens the drop-down, but it does not click the desired value (list item "API_PERFORMANCE"). Using the Window Info tool on the item yields me a control with CLASS:Progman and TEXT:Program Manager. I did some poking around the internet, and found that, in older versions of WinForms, ComboBox lists and their items are created outside of the original program, on the desktop, so I tried the following code. ControlClick("MyProgram", "", "[ID:462328]") Sleep(1000) ControlClick("[CLASS:Progman]", "", "[TEXT:API_PERFORMANCE]") This still does not click anything. I am unsure how to proceed at this point. I used the Microsoft-provided inspect.exe tool to get the following information about the control. expandcollapse popupHow found: Mouse move (-1596,436) hwnd=0x0000000000070C34 64bit class="ComboLBox" style=0x54A08041 ex=0x88 Name: "API_PERFORMANCE" ControlType: UIA_ListItemControlTypeId (0xC357) LocalizedControlType: "list item" BoundingRectangle: {l:-1642 t:431 r:-1531 b:444} IsEnabled: true IsOffscreen: false IsKeyboardFocusable: true HasKeyboardFocus: false AccessKey: "" ProcessId: 6304 RuntimeId: [2A.70C34.4.80000001.70C34.FFFFFFFC.3] ProviderDescription: "[pid:6304,providerId:0x0 Annotation:Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]" IsPassword: false HelpText: "" IsDialog: [Not supported] LegacyIAccessible.ChildId: 3 LegacyIAccessible.DefaultAction: "Double Click" LegacyIAccessible.Description: "" LegacyIAccessible.Help: "" LegacyIAccessible.KeyboardShortcut: "" LegacyIAccessible.Name: "API_PERFORMANCE" LegacyIAccessible.Role: list item (0x22) LegacyIAccessible.State: selected,focusable,selectable (0x300002) LegacyIAccessible.Value: "" SelectionItem.IsSelected: true SelectionItem.SelectionContainer: "" list IsAnnotationPatternAvailable: false IsDragPatternAvailable: false IsDockPatternAvailable: false IsDropTargetPatternAvailable: false IsExpandCollapsePatternAvailable: false IsGridItemPatternAvailable: false IsGridPatternAvailable: false IsInvokePatternAvailable: true IsItemContainerPatternAvailable: false IsLegacyIAccessiblePatternAvailable: true IsMultipleViewPatternAvailable: false IsObjectModelPatternAvailable: false IsRangeValuePatternAvailable: false IsScrollItemPatternAvailable: true IsScrollPatternAvailable: false IsSelectionItemPatternAvailable: true IsSelectionPatternAvailable: false IsSpreadsheetItemPatternAvailable: false IsSpreadsheetPatternAvailable: false IsStylesPatternAvailable: false IsSynchronizedInputPatternAvailable: false IsTableItemPatternAvailable: false IsTablePatternAvailable: false IsTextChildPatternAvailable: false IsTextEditPatternAvailable: false IsTextPatternAvailable: false IsTextPattern2Available: false IsTogglePatternAvailable: false IsTransformPatternAvailable: false IsTransform2PatternAvailable: false IsValuePatternAvailable: false IsVirtualizedItemPatternAvailable: false IsWindowPatternAvailable: false IsCustomNavigationPatternAvailable: false IsSelectionPattern2Available: false FirstChild: [null] LastChild: [null] Next: "CSharp" list item Previous: "API" list item Other Props: Object has no additional properties Children: Container has no children Ancestors: "" list "Desktop 1" pane [ No Parent ] Is there anything in there that I could use to locate this element and click it? Or is there something I'm missing here? Link to comment Share on other sites More sharing options...
Nine Posted January 2, 2020 Share Posted January 2, 2020 Look at ControlCommand () function (especially the part about ComboBox) . The way you are trying to do it will never work. Also there is a GUI Combo Box UDF that have additional functionalities that you could use. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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