asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.22k stars 1.24k forks source link

Move the mouse using Python in a virtual machine [RESOLVED] #818

Closed lucassfernando closed 11 months ago

lucassfernando commented 11 months ago

I need to create an automation that performs clicks and enters information into a virtual machine. I have access to a VM where I access via RDP which is where this project needs to be running, it is a server that is always on. However, when I run it and close the VM, it generates an error because it cannot find my mouse. I've already tried using the PyAutoGUI and Pynput libraries... I believe that regardless of the library I use, it will generate the error of not finding the mouse and keyboard due to the fact that I have closed the VM application. Any solution?

lucassfernando commented 11 months ago

I put my project to execute and use a command in cmd inside the VM tscon rdp-tcp#0 /dest:console , after executing this command you will be disconnected, but the keyboard and mouse will work normally.

Check it out here: https://learn.microsoft.com/en-us/answers/questions/1086036/is-it-possible-to-have-a-virtual-mouse-or-keyboard

I tested with the PyAutoGUI library and was unsuccessful even using the method mentioned above. So, I needed to use the ahk library