this is a window of the software being tested. In the red box is the
spyPP
UI Spy ControlType:"ControlType.ToolBar"
from pywinauto.application import Application
import pywinauto
app = Application().connect(title_re=".*")
win_dgg = app.window(handle=0x000E0BC4)
-sharp
win_dgg.print_control_identifiers()
-sharp
execution result:
Control Identifiers:
WindowsForms10.Window.8.app.0.2bf8098_r15_ad1 - "toolStrip1" (L254, T388, R645, B428)
["WindowsForms10.Window.8.app.0.2bf8098_r15_ad1", "toolStrip1", "toolStrip1WindowsForms10.Window.8.app.0.2bf8098_r15_ad1"]
child_window(title="toolStrip1", class_name="WindowsForms10.Window.8.app.0.2bf8098_r15_ad1")
from pywinauto.application import Application
import pywinauto
app = Application().connect(title_re=".*")
win_dgg = app.window(handle=0x000E0BC4)
tool_bar = win_dgg.ToolBar
-sharptoolbar
tool_bar.Click("")
error report performed
execution result:
Traceback (most recent call last):
File "C:\Python36-32\lib\site-packages\pywinauto\application.py", line 245, in __resolve_control
criteria)
File "C:\Python36-32\lib\site-packages\pywinauto\timings.py", line 449, in wait_until_passes
raise err
pywinauto.timings.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "F:\pythontest\utest\tools.py", line 12, in <module>
tool_bar.Click("")
File "C:\Python36-32\lib\site-packages\pywinauto\application.py", line 351, in __getattribute__
ctrls = self.__resolve_control(self.criteria)
File "C:\Python36-32\lib\site-packages\pywinauto\application.py", line 248, in __resolve_control
raise e.original_exception
File "C:\Python36-32\lib\site-packages\pywinauto\timings.py", line 427, in wait_until_passes
func_val = func(*args)
File "C:\Python36-32\lib\site-packages\pywinauto\application.py", line 209, in __get_ctrl
ctrl = self.backend.generic_wrapper_class(findwindows.find_element(**ctrl_criteria))
File "C:\Python36-32\lib\site-packages\pywinauto\findwindows.py", line 87, in find_element
raise ElementNotFoundError(kwargs)
pywinauto.findwindows.ElementNotFoundError: {"best_match": "ToolBar", "top_level_only": False, "parent": <win32_element_info.HwndElementInfo - "toolStrip1", WindowsForms10.Window.8.app.0.2bf8098_r15_ad1, 920516>, "backend": "win32"}
after learning to use pywinauto, for the first time, I still don"t understand the official documents. How can I find the toolbar and click on it? please take a look at it for me, ask for advice, thank you!