【问题标题】:pywinauto: Passing a string parameter instead of an identifier namepywinauto:传递字符串参数而不是标识符名称
【发布时间】:2020-12-06 13:55:08
【问题描述】:

我第一次在“社区”... 首先-您在这里找到了很棒的平台-谢谢!

我的问题: 我正在使用 pywinauto 来控制自己开发的 GUI(称为 SuperGUI)。 我知道如何从其 ComboBox 中选择一个项目,但我想从用户那里获取 item_name,然后将其作为 ComboBox.parameter 发送到对话框并“单击”它。

这些是相关的控件标识符:

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")

当然:

dlg.COMPort.ComboBox.COM14.click_input()

工作正常。 但我需要“COM14”作为字符串参数...

这里哪种方式最好?

谢谢各位!

【问题讨论】:

    标签: python string parameters pywinauto


    【解决方案1】:

    在尝试和尝试之后,我决定切换到 backend='win32' 而不是 'uia'。 这让我可以通过使用 .select('item') 选项而不是 click_input() 从 ComboBox 中选择一个选项,并且问题解决了!!

    谢谢。

    【讨论】:

      猜你喜欢
      • 2018-05-08
      • 1970-01-01
      • 1970-01-01
      • 2021-06-21
      • 2015-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多