I'm using a pywinauto in a project and it works well. On some screens when there are lots of controls the search takes a bit long, but I can deal with that.
What I want to know is if there's a way to re-use a control without needing to search for it again? For example a button I want to click multiple times.
eg. code:
main_app = Application(backend="uia").connect(path=app_path)
button = main_app.child_window(auto_id="Button1", control_type="Button")
button.click_input()
button.click_input()
each time I use click_input() it takes the same amount of time, I assume this is because it's redoing the search each time. Is there a way to do this where the second call would be much faster?
For buttons I could get the coordinates of the button, and use a mouse.click_input(coords) or something, but I want to know more generically, like if I want to do .texts() on an Edit as well.
thanks!
You can save the found wrapper into a variable:
button_spec = main_app.child_window(auto_id="Button1", control_type="Button")
button = button_spec.wrapper_object()
# or
button = button_spec.wait('enabled', timeout=10) # if you need to wait more than default 5 sec.
button.click_input()
button.click_input()