Send mouse clicks to minimized window

Matt Wheeler m at funkyhat.org
Mon Aug 28 17:24:05 EDT 2017


On Mon, 28 Aug 2017 at 12:30 <gabriel.lins97 at gmail.com> wrote:

> I'm using python to automate some seriously boring stuff at work, but
> would like to improve current code.
>
> The way it is now, PyAutoGui moves mouse and clicks the Application. I am,
> therefore, hostage of my python "assistant", as I cannot use my computer
> while the .py is running.
>

Running your automation in a VM, or as a dedicated user if you're able to
run it on a terminal server, is probably a more reliable option.


> Is there any way to send mouse clicks to minimized windows, in so that it
> does not interfere with normal using of my computer?
>

pywinauto [0] will happily send events to non-focussed & minimised windows
as long as you don't need to use the _input() versions of the control
methods.
However doing that may cause the automated application to "steal" focus, so
it might not help much with your desire to keep the computer usable (I'm
not sure if this always happens, so it's worth trying).


> I'm on Windows and have tried pywin32, but could not manage to make it to
> work. Also tried ctypes, with same results. I'm really new to python. Also,
> I could migrate to Linux if that's necessary.
>

What is the application that you're automating? Mentioning migrating to
Linux as an option makes me wonder whether you are working with a web
application, in which case selenium is probably a better option than a
window-manager level automation tool (and will also solve the focus problem
for you).


[0] https://github.com/pywinauto/pywinauto
-- 

--
Matt Wheeler
http://funkyh.at



More information about the Python-list mailing list