Kalmat / PyWinCtl

Cross-Platform module to get info on and control windows on screen
Other
179 stars 19 forks source link

GetAllWindows hangs when it encounters dummy window created by the same process #53

Closed leoshusar closed 1 year ago

leoshusar commented 1 year ago

Hi! I just found your fork after searching why PyGetWindow is not working well for me - it was sometimes crashing while calling .activate(). But apart from this it was working fine.

So I just upgraded to PyWinCtl, but after calling getAllWindows() in my specific case it hangs. I found it's happening in my code here:

a = pwc.getAllWindows() # succeeds
self.visualizer = o3d.visualization.O3DVisualizer(self.name) # type: ignore
a = pwc.getAllWindows() # hangs

I tried to debug it and it seems like the Open3D is opening one visible window and one invisible dummy window, unused by user. I have both HWNDs and while it's stuck, I tried to get info about them in C#. Here are my results: image

In Python it hangs on the getWindowTextLength, but I don't know why, my theory is it's because it's owned by the same process. I found this in docs. I can query them in my C# test app without problems and it always returns the name as "dummy". I also tried to call pwc.getAllWindows() in separate Python instance and it also succeeded (although with the dummy window filtered out).

PyGetWindow is not affected because it's calling those problematic methods for only visible windows.