Search code examples
pyautogui

Is there a way for pyautogui to work without taking over mouse/keyboard control?


I was able to write a simple game bot using pyautogui.click, pyautogui.locateonscreen, and a bunch of if/while statements.

The bot works fine, however, is there a way for the bot to work without taking over mouse control?

Example: I would like to be able to browse stackoverflow.com with the bot running.


Solution

  • No, pyautogui only simulates user input which will take over the mouse/ keyboard. From their github, "All keyboard presses done by PyAutoGUI are sent to the window that currently has focus, as if you had pressed the physical keyboard key." And similarly the mouse automation just sends commands to the OS as if you had physically moved/ clicked your mouse.

    To write a program to control a game while still allowing you to use user control (mouse/ keyboard) you will have to directly send commands to the game by manipulating the game's memory. This is called making a "trainer". https://en.wikipedia.org/wiki/Trainer_(games)