'How to simulate real mouse and keyboard in game when virtual events are blocked?
I'm trying to write a bot for game MU Online but it is protected by Game Guard software which seems to be blocking every script involving mouse and keyboard events.
Interestingly, the Windows 10 On-Screen Keyboard is actually sending keystrokes into the game window without any problems. Unfortunately I don't know how to mimic the OSK way of handling keyboard events.
I also tried running everything as administrator but it didn't help.
Here is what I have tried already, every example is supposed to click left mouse button once and press "i". I added 3 seconds delay to have some time to activate game window.
# PyAutoGui
import pyautogui
import time
time.sleep(3)
pyautogui.click()
pyautogui.press("i")
# PyDirectInput
import pydirectinput
import time
time.sleep(3)
pydirectinput.click()
pydirectinput.press("i")
# Autoit
import ait
import time
time.sleep(3)
ait.click()
ait.press("i")
# PyAutoIt
import autoit
import time
time.sleep(3)
autoit.mouse_click("left")
autoit.send("i")
# Pynput
from pynput.mouse import Button, Controller
from pynput.keyboard import Key, Controller
import time
time.sleep(3)
mouse = Controller()
mouse.press(Button.left)
mouse.release(Button.left)
keyboard = Controller()
keyboard.press("i")
keyboard.release("i")
Everything works fine as long as I don't activate the game window - then nothing is happening.
Do you have any ideas what else I could try?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
