pywinauto routinely takes 30s or more to find top_window()
See original GitHub issueExpected Behavior
Better performance. Is there a way to speed this up? Where is all the time going? Should I profile it to find out?
Actual Behavior
Takes 30s+ to find top_window.
Short Example of Code to Demonstrate the Problem
import pywinauto, time
myexe = "" # Full path to the .exe file I'm automating
myargs = "" # arguments to it
myapp = pywinauto.application.Application(backend="uia").start(f'{myexe} "{myargs}"')
start=time.perf_counter()
mywindow = myapp.top_window()
end=time.perf_counter()
print(f"Took {end-start}s to find top window.")
Always 30s+ for me and the app starts rapidly, it just sits there as I do for a half minute waiting for top_window() to return.
Specifications
- Pywinauto version: 0.6.8
- Python version and bitness: 3.83 64 bit
- Platform and OS: Windows 10
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
It takes a long time to find window using pywinauto
Still I think the time which is required could be reduced by using a more efficient code. I currently do this: app =...
Read more >How To's — pywinauto 0.6.8 documentation
Dialog is a window containing several other GUI elements/controls like buttons, ... these get passed to the pywinauto.findwindows.find_elements() function.
Read more >pywinauto.findwindows — pywinauto 0.6.8 documentation
It's a very low level API. Better use Application and WindowSpecification objects described in the Getting Started Guide. Possible values are: class_name ...
Read more >Waiting for Long Operations — pywinauto 0.6.8 documentation
A GUI application behaviour is often unstable and your script needs waiting until a new ... that could help you to make your...
Read more >Getting Started Guide — pywinauto 0.6.8 documentation
Once you have installed pywinauto - how do you get going? ... But Python can hide this wrapper_object() call so that you have...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you for your reply! Yes, it is specific for “uia” only. Win32 takes nanoseconds, no matter of build type (wich is about 1000 times faster than what we consider “normal” for “uia”).
sys.coinit_flags = 2
does not help.I’ve faced the same issue: top_window() for the release build of our app takes less than 1 second, but when it comes to debug build, the same operation takes about 40 sec while the app is completely responsive. I asked a programmer about differences and got the answer: “Debug build starts additional COM server (which opens a lot of interfaces). Allegedly, pywinauto tries each available interface to find the suitable one.” Switching off the COM server made the time of the two builds comparable.