Kalmat / PyWinCtl

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

getWindowsWithTitle and getActiveWindow return None when running on virtual frame buffer #92

Closed klapnek closed 1 month ago

klapnek commented 1 month ago

Hi,

Thank you very much for your efforts on making "pygetwindow" to run on Linux.

We are working on a CI/CD pipeline including automated UI testing, where we run our UI alongside robot framework and communicate with it through the UI's API, verifying screenshots and check if texts in all translations fit within their bounds. Further more, we use pyWinCtl and pyautogui to actually control the UI and test its functionality.

I'm happy to report that it runs from both the PowerShell as well as from Ubuntu WSL2 on my Windows machine. What I really would like though, is to be able to run it on our build server on a virtual framebuffer, using Xvfb.

Unfortunately, at the moment, when running our script on a virtual framebuffer ($ xvfb-run ./application.py) it does start the application (we know, because verifying the screenshots works), but when we try to get the window handle, getWindowsWithTitle(name) and getAllAppsNames() return an empty list, and getActiveWindow() returns None.

Do you think it is possible to get it to work under Xvfb? I maybe able to contribute, if you can tell me where to look next. I'm kinda running out of ideas.

I have tried running it on Xvfb under WSL2, as well as on a native Linux machine (our build server). The main goal is to be able to run it on our build server, if it would also work under WSL2, that would be even more pleasurable.

Thanks in advance.

klapnek commented 1 month ago

Now that I think about it, of course the window list is empty. I run my application on a virtual framebuffer, not a virtual window manager. No window manager: No windows!

Sorry for bothering you.

Kalmat commented 1 month ago

Thank you so much for your interest, and my apologies for my late reply.

Unfortunately I don't know Xvfb, but googling around shows there is no Xserver to query. You're likely right: no window manager, no windows.

Have you tried using these commands?

DISPLAY=:1 wmctrl -l
xwininfo -root -tree

If any of these commands has a valid output, perhaps you can parse it.

Keep it up!

klapnek commented 1 month ago

Hi,

Thank you for your reply.

In the mean time I actually got it working by first starting fluxbox, and then my UI application.

Thank you for your time

Op zo 1 sep. 2024 20:02 schreef Kalmat @.***>:

Thank you so much for your interest, and my apologies for my late reply.

Unfortunately I don't know Xvfb, but googling around shows there is no Xserver to query. You're likely right: no window manager, no windows.

Have you tried using these commands?

DISPLAY=:1 wmctrl -l xwininfo -root -tree

If any of these commands has a valid output, perhaps you can parse it.

Keep it up!

— Reply to this email directly, view it on GitHub https://github.com/Kalmat/PyWinCtl/issues/92#issuecomment-2323443795, or unsubscribe https://github.com/notifications/unsubscribe-auth/AV5OBDKPXWYPWB3GSSNCOWTZUNJBRAVCNFSM6AAAAABNODSNPKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRTGQ2DGNZZGU . You are receiving this because you modified the open/close state.Message ID: @.***>