Controlling nonstandard classes with pywinauto
<p>I am using pywinauto in order to ease my work with certain program. I would like to select in this <a href="https://i.stack.imgur.com/OHbHV.png" rel="nofollow">combobox</a> item "vs. Reference". I used <code>app['Setup Potentiodynamic Experiment'].PrintControlIdentifiers()</code> to get name and class of the combobox. Python returned the following: </p>

<pre><code>TComboDJ - 'b'vs. Open Circuit''   (L987, T424, R1094, B445)

'b'TComboDJ5''
'b'vs. Open Circuit3''
'b'vs. Open CircuitTComboDJ3''
</code></pre>

<p>So, to do what I want, I used this:</p>

<pre><code>app['Setup Potentiodynamic Experiment']["TComboDJ5"].Select("vs. Reference")
</code></pre>

<p>And the following error appeared:</p>

<pre><code>Exception in Tkinter callback
Traceback (most recent call last):
  File "E:\PY\lib\tkinter\__init__.py", line 1550, in __call__
    return self.func(*args)
  File "E:/Python projects/test/test.py", line 40, in createxp
    app['Setup Potentiodynamic Experiment']["TComboDJ5"].Select("vs. Reference")
  File "E:\PY\lib\site-packages\pywinauto\application.py", line 245, in __getattr__
    return getattr(ctrls[-1], attr)
AttributeError: 'HwndWrapper' object has no attribute 'Select'
</code></pre>

<p>As far as I understand, pywinauto can't recognize the combobox as a combobox. Can something be done about it?</p>

<p><code>ComboBoxWrapper</code> can be created explicitly:</p>

<pre><code>from pywinauto.controls.win32_controls import ComboBoxWrapper
hwnd_wr = app['Setup Potentiodynamic Experiment']["TComboDJ5"].WrapperObject()
combo = ComboBoxWrapper(hwnd_wr)
combo.Select("vs. Reference")
</code></pre>

<p>Of course it would work if the combo box could respond to standard window messages like <code>CB_GETCOUNT</code>. And the output tells you that combined <code>&lt;title&gt;&lt;item_text&gt;</code> access names are fortunately available.</p>

python combobox pywinauto