Question

I am attempting to take control of mouse events on the desktop using pywinauto. Specifically, I am looking to make different applications active by sending a mouse click to their windows, and ideally to be able to move windows with well known title bar coordinates around.

I've tried doing app.connect_() calls to both "explorer" and "dwm" but with the exception of a DialogWrapper with the class "Progman" I've had no joy. Searching about with SWAPY has yielded similarly poor results.

I'm not a Windows programmer so I hope I'm missing something fairly obvious here. Any hints would be well received.

Thanks

Was it helpful?

Solution

Below is some code that will click on the desktop at (900, 50) using pywinauto.

Note that using ClickInput() rather than Click() is important.


import pywinauto.application

app = pywinauto.application.Application()
comapp = app.connect_(path = "explorer")

for i in comapp.windows_():
    if "Progman" == i.FriendlyClassName():
        i.ClickInput(coords=(900, 50))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top