如何在pywinauto中的url里面输入大括号
How to enter braces inside url in pywinauto
我正在尝试像这样在 pywinauto 中输入 url "D:\Eudora(07NOV2008).mbx" 但它跳过大括号并像这样输入 "D:\Eudora07NOV2008.mbx",我该如何解决这个问题。
问题不清楚,但似乎使用了方法 .type_keys()
。此方法尝试解析键名在 {}
大括号中的特殊键(如 {ENTER}
),完整列表在 keyboard module 文档中描述。此方法对于任何 window and/or 元素的特殊键组合很有用。对于上述用例,代码应如下所示:
.type_keys(r'D:{\}Eudora{(}07NOV2008{)}.mbx', with_spaces=True)
# the last argument tells the method to not skip spaces
对于原始文本输入,更合适的方法是 .set_edit_text()
,即按原样输入文本。它不支持特殊键解析。
对于一些罕见的情况,还有一种更有用的方法 .set_value()
(仅限 UIA 后端)。
Win32 后端包含静默文本输入法 .send_chars()
和 .send_keystrokes()
,它们甚至不需要将元素置于聚焦状态。
the Remote Execution Guide 中描述了其中许多方法。
我正在尝试像这样在 pywinauto 中输入 url "D:\Eudora(07NOV2008).mbx" 但它跳过大括号并像这样输入 "D:\Eudora07NOV2008.mbx",我该如何解决这个问题。
问题不清楚,但似乎使用了方法 .type_keys()
。此方法尝试解析键名在 {}
大括号中的特殊键(如 {ENTER}
),完整列表在 keyboard module 文档中描述。此方法对于任何 window and/or 元素的特殊键组合很有用。对于上述用例,代码应如下所示:
.type_keys(r'D:{\}Eudora{(}07NOV2008{)}.mbx', with_spaces=True)
# the last argument tells the method to not skip spaces
对于原始文本输入,更合适的方法是 .set_edit_text()
,即按原样输入文本。它不支持特殊键解析。
对于一些罕见的情况,还有一种更有用的方法 .set_value()
(仅限 UIA 后端)。
Win32 后端包含静默文本输入法 .send_chars()
和 .send_keystrokes()
,它们甚至不需要将元素置于聚焦状态。
the Remote Execution Guide 中描述了其中许多方法。