user14774239
user14774239

Reputation: 11

pywinauto: Passing a string parameter instead of an identifier name

first time for me in the "neighborhood"... First of all - great platform you got here - thanks !

My question: I'm using pywinauto to control a self developed GUI (called SuperGUI). I know how to select an item from its ComboBox, but I would like to get the item_name from the user, and then send it to the dialog as a ComboBox.parameter and "click" it.

These are the relevant control identifiers:

Pane - 'COM- Port'    (L367, T256, R639, B457)

   |    |    | ['COM- PortPane', 'COM- Port', 'Pane12']

   |    |    | child_window(title="COM- Port", auto_id="groupBox3", control_type="Pane")

   |    |    |    |

   |    |    |    | Button - 'Refresh'    (L376, T405, R497, B431)

   |    |    |    | ['RefreshButton', 'Refresh', 'Button29']

   |    |    |    | child_window(title="Refresh", auto_id="button_COM_refresh", control_type="Button")

   |    |    |    |

   |    |    |    | ComboBox - 'Baud rate: 6 Mbps, 8b, no parity'    (L376, T368, R497, B389)

   |    |    |    | ['Baud rate: 6 Mbps, 8b, no parityComboBox', 'Baud rate: 6 Mbps, 8b, no parity', 'ComboBox7', 'Baud rate: 6 Mbps, 8b, no parity0', 'Baud rate: 6 Mbps, 8b, no parity1']

   |    |    |    | child_window(title="Baud rate: 6 Mbps, 8b, no parity", auto_id="comboBox_COM_port", control_type="ComboBox")

   |    |    |    |    |

   |    |    |    |    | Edit - 'Baud rate: 6 Mbps, 8b, no parity'    (L379, T371, R477, B386)

   |    |    |    |    | ['All available ports:Edit', 'Edit15']

   |    |    |    |    | child_window(title="Baud rate: 6 Mbps, 8b, no parity", auto_id="1001", control_type="Edit")

   |    |    |    |    |

   |    |    |    |    | Button - 'Open'    (L481, T369, R496, B388)

   |    |    |    |    | ['Open', 'OpenButton', 'Button30']

   |    |    |    |    | child_window(title="Open", control_type="Button")

   |    |    |    |

   |    |    |    | Static - 'All available ports:'    (L373, T339, R485, B352)

   |    |    |    | ['Static11', 'All available ports:Static', 'All available ports:']

   |    |    |    | child_window(title="All available ports:", auto_id="label9", control_type="Text")

   |    |    |    |

   |    |    |    | Static - 'Baud rate: 6 Mbps, 8b, no parity'    (L373, T309, R563, B322)

   |    |    |    | ['Baud rate: 6 Mbps, 8b, no parity2', 'Baud rate: 6 Mbps, 8b, no parityStatic', 'Static12']

   |    |    |    | child_window(title="Baud rate: 6 Mbps, 8b, no parity", auto_id="label21", control_type="Text")

of course that:

dlg.COMPort.ComboBox.COM14.click_input()

works fine. but I need "COM14" to be a string parameter...

Which way would be the best here?

Thanks Guys !

Upvotes: 0

Views: 270

Answers (1)

user14774239
user14774239

Reputation: 11

After trying and trying, I decided to switch to backend='win32' instead of 'uia'. This allowed me to pick one choice from ComboBox by using the .select('item') option instead of click_input(), and problem solved !!

Thanks.

Upvotes: 1

Related Questions