pywinauto微信控制命令选项分析
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_id="158940464", control_type="Document")
| | |
| | | Pane - '' (L322, T63, R958, B758)
| | | ['Pane4']
| | | |
| | | | Document - '' (L0, T0, R0, B0)
| | | | ['Document2']
|
| Pane - '' (L320, T0, R960, B760)
| ['Pane5']
| |
| | Pane - '' (L320, T0, R960, B26)
| | ['Pane6']
| | |
| | | Pane - '' (L320, T0, R960, B26)
| | | ['Pane7']
| | | |
| | | | Pane - '' (L320, T0, R858, B26)
| | | | ['Pane8']
| | | |
| | | | Button - '最小化' (L858, T0, R892, B26)
| | | | ['Button', '最小化Button', '最小化', 'Button0', 'Button1']
| | | | child_window(title="最小化", control_type="Button")
| | | |
| | | | Button - '最大化' (L892, T0, R926, B26)
| | | | ['Button2', '最大化', '最大化Button']
| | | | child_window(title="最大化", control_type="Button")
| | | |
| | | | Button - '关闭' (L926, T0, R960, B26)
| | | | ['Button3', '关闭Button', '关闭']
| | | | child_window(title="关闭", control_type="Button")
| |
| | Pane - '' (L320, T27, R960, B61)
| | ['Pane9']
| | |
| | | Pane - '' (L320, T27, R336, B61)
| | | ['Pane10']
| | |
| | | Button - '后退' (L336, T27, R361, B52)
| | | ['Button4', '后退Button', '后退']
| | | child_window(title="后退", control_type="Button")
| | |
| | | Pane - '' (L393, T32, R394, B47)
| | | ['Pane11']
| | |
| | | Button - '刷新' (L410, T27, R435, B52)
| | | ['Button5', '刷新Button', '刷新']
| | | child_window(title="刷新", control_type="Button")
| | |
| | | Button - '用默认浏览器打开' (L441, T27, R466, B52)
| | | ['Button6', '用默认浏览器打开Button', '用默认浏览器打开']
| | | child_window(title="用默认浏览器打开", control_type="Button")
| | |
| | | Pane - '' (L466, T27, R913, B61)
| | | ['Pane12']
| | |
| | | Button - '浮窗' (L919, T27, R944, B52)
| | | ['Button7', '浮窗', '浮窗Button']
| | | child_window(title="浮窗", control_type="Button")
| | |
| | | Pane - '' (L944, T27, R960, B61)
| | | ['Pane13']
| |
| | Pane - '' (L320, T61, R960, B756)
| | ['Pane14']
| | |
| | | Pane - '' (L320, T61, R324, B756)
| | | ['Pane15']
| | |
| | | Pane - '' (L324, T61, R956, B756)
| | | ['Pane16']
| | |
| | | Pane - '' (L956, T61, R960, B756)
| | | ['Pane17']
| |
| | Pane - '' (L320, T756, R960, B760)
| | ['Pane18']
找刷新按钮:
Button - '刷新' (L410, T27, R435, B52)
| | | ['Button5', '刷新Button', '刷新']
| | | child_window(title="刷新", control_type="Button")
写命令:(26减一:25)
search = win_main_Dialog.child_window(control_type="Button",found_index=4).type_keys('~')
search.double_click_input()
或者:
search = win_main_Dialog.child_window(title="刷新", control_type="Button")
search.double_click_input()