pid = GetWeChatPID('WeChat.exe')
app = Application(backend='uia').connect(process=pid)
# 拿到微信主窗口
win_main_Dialog = app.window(class_name='WeChatMainWndForPC')
win_main_Dialog1 = app.window(class_name='CefWebViewWnd')
win_main_Dialog2 = app.window(class_name='CMenuWnd')
#win_main_Dialog1 = app.window(found_index=0,class_name='WeChatMainWndForPC').type_keys('~')
win = app[u'微信']
# 将窗口最大化
win.maximize()
手动:
win_main_Dialog.print_control_identifiers(depth=None,filename=None)
根据结果找按钮:
Button - '导诊?挂号' (L304, T714, R614, B762)
| | | | | | | | | | | ['导诊?挂号Button', 'Button26', '导诊?挂号']
| | | | | | | | | | | child_window(title="导诊?挂号", control_type="Button")
按钮:
导诊?挂号Button Button26 child_window(title="导诊?挂号", control_type="Button")
按钮位置:Button - '导诊?挂号' (L304, T714, R614, B762)
写命令:(26减一:25)
search = win_main_Dialog.child_window(control_type="Button",found_index=25).type_keys('~')
search.double_click_input()
或者:
search = win_main_Dialog.child_window(title="导诊?挂号", control_type="Button")
search.double_click_input()
另一例子:
win_main_Dialog1.print_control_identifiers(depth=None,filename=None)
Control Identifiers:
Dialog - '微信' (L320, T0, R960, B760)
['微信Dialog', '微信', 'Dialog']
child_window(title="微信", control_type="Window")
|
| Pane - '' (L301, T-19, R979, B779)
| ['Pane', 'Pane0', 'Pane1']
|
| Pane - '' (L322, T63, R958, B758)
| ['Pane2']
| |
| | Pane - '' (L322, T63, R958, B758)
| | ['Pane3']
| | |
| | | Document - '' (L322, T63, R958, B758)
| | | ['Document', 'Document0', 'Document1']
| | | child_window(auto_)
search.double_click_input()