dict_keys() is empty when trying to select a ListBox item
See original GitHub issueI try to select an item in a ListBox (pywinauto 0.6.5). UPD: I work with Qt5 software.
The initial script just finds the certain drop down menu inside a dialog.
from pywinauto.application import Application
app = Application(backend='uia').start(r"app.exe")
dlg = app.window(best_match='Select Rename Device')
dlg.window(best_match='DownComboBox3').print_control_identifiers()
The output seems to be good:
ComboBox - ' Down' (L795, T522, R1157, B542)
['ComboBox', ' DownComboBox', ' Down']
child_window(title=" Down", control_type="ComboBox")
|
| ListBox - '' (L0, T0, R0, B0)
| ['', 'ListBox']
| |
| | ListItem - '00/4i Simulation mode' (L1, T1, R752, B24)
| | ['00/4i Simulation mode', '00/4i Simulation modeListItem', 'ListItem', 'ListItem0', 'ListItem1']
| | child_window(title="00/4i Simulation mode", control_type="ListItem")
| |
| | ListItem - '00/2i Simulation mode' (L1, T24, R752, B47)
| | ['00/2i Simulation mode', '00/2i Simulation modeListItem', 'ListItem2']
| | child_window(title="00/2i Simulation mode", control_type="ListItem")
| |
| | ListItem - '00/6i Simulation mode' (L1, T47, R752, B70)
| | ['00/6i Simulation mode', '00/6i Simulation modeListItem', 'ListItem3']
| | child_window(title="00/6i Simulation mode", control_type="ListItem")
Process finished with exit code 0
Now I try to select ‘00/2i Simulation mode’ ListItem:
from pywinauto.application import Application
app = Application(backend='uia').start(r"app.exe")
dlg = app.window(best_match='Select Rename Device')
dlg.window(best_match='DownComboBox3').child_window(best_match='00/2i Simulation mode').select()
but got an error:
pywinauto.findbestmatch.MatchError: Could not find '00/2i Simulation mode' in 'dict_keys([])'
I tried to apply workaround suggested in the issue #365 but the error was the same:
from pywinauto.application import Application
app = Application(backend='uia').start(r"app.exe")
dlg = app.window(best_match='Select Rename Device')
dlg.window(best_match='DownComboBox3').ListBox.child_window(title="00/2i Simulation mode", control_type="ListItem").select()
Also, I tried to change backend to win32 (as #467 suggested).
But the dict_keys() was still empty.
I have no idea where I’m wrong. May anybody suggests a way to solve this issue with drop-down menu selection?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to display a Dictionary in a ListBox - Stack Overflow
Use the Format event on the list box: KeyValuePair<string, int> item = (KeyValuePair<string, int>)e.ListItem; e.Value = string.
Read more >How to get selected value from listbox in tkinter?
It is executed when we press the “Print Selected” button. In the case of no selected items, curselection method returns an empty tuple....
Read more >VBA Listbox - A Complete Guide - Excel Macro Mastery
The ListBox is used to display a list of items to the user so that the user can then select one or more....
Read more >Google Visualization API Reference | Charts
Each row is an object as described in addRow() . Use null or an empty array entry for an empty cell. Example: data....
Read more >Dropdown | Dash for Python Documentation | Plotly
loading_state (dict; optional): Object that holds the loading state object coming from dash-renderer. loading_state is a dict with keys: component_name (string; ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Use Case. Select an item from ComboBox control for an Qt5.6 application.
App example: https://fex.net/485689299381 (it is standard ‘blockingslave.exe’ Qt app compiled via QtCreator using MinGW) Note: Activate a COM port before using this app (I plugged an USB device, USB type B)
Actual Result: Such constructions do not work:
or
or
Expected Result: Ability to make selection by any way.
Full script code:
Screens:

Method
.select()for combo box should work well now (inatspibranch). So we’re closing the issue. The fix will be included into next major release (no exact deadline though).