from pywinauto.application import Application
app = Application(backend="win32").start(r"C:\Program Files\CrystalDiskMark8\DiskMark64.exe")
dlg = app[" CrystalDiskMark 8.0.4 x64 [Admin] "]
dlg.print_control_identifiers()
""" app = Application(backend="uia").start("notepad.exe")
dlg = app["无标题 - 记事本"]
dlg.print_control_identifiers() """
这个是我的代码,我想要选中CMD Tool打开的窗口,并且列出它上面可以操作的菜单选项等
相同的代码,打开记事本则没有问题
报错如下:
PS C:\0_Python\Key_Mouse> & C:/Users/ward/AppData/Local/Programs/Python/Python37/python.exe c:/0_Python/Key_Mouse/Jira/1015_Edge.py
Traceback (most recent call last):
File "C:\Users\ward\AppData\Local\Programs\Python\Python37\lib\site-packages\pywinauto\application.py", line 258, in __resolve_control
criteria)
File "C:\Users\ward\AppData\Local\Programs\Python\Python37\lib\site-packages\pywinauto\timings.py", line 458, in wait_until_passes
raise err
pywinauto.timings.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:/0_Python/Key_Mouse/Jira/1015_Edge.py", line 8, in
dlg.print_control_identifiers()
File "C:\Users\ward\AppData\Local\Programs\Python\Python37\lib\site-packages\pywinauto\application.py", line 613, in print_control_identifiers
this_ctrl = self.__resolve_control(self.criteria)[-1]
File "C:\Users\ward\AppData\Local\Programs\Python\Python37\lib\site-packages\pywinauto\application.py", line 261, in __resolve_control
raise e.original_exception
File "C:\Users\ward\AppData\Local\Programs\Python\Python37\lib\site-packages\pywinauto\timings.py", line 436, in wait_until_passes
func_val = func(*args, **kwargs)
File "C:\Users\ward\AppData\Local\Programs\Python\Python37\lib\site-packages\pywinauto\application.py", line 203, in __get_ctrl
dialog = self.backend.generic_wrapper_class(findwindows.find_element(**criteria[0]))
File "C:\Users\ward\AppData\Local\Programs\Python\Python37\lib\site-packages\pywinauto\findwindows.py", line 87, in find_element
raise ElementNotFoundError(kwargs)
pywinauto.findwindows.ElementNotFoundError: {'best_match': ' CrystalDiskMark 8.0.4 x64 [Admin] ', 'backend': 'uia', 'process': 5260}