Pyautogui not working in game window

I am doing some tests using Pyautogui in games. But in those games that change your cursor and full screen games, neither method works.

I am trying now at Ragnarok Online.

I tried:

pyautogui.click()
pyautogui.moveTo(x, y, time)
pyautogui.moveRel(x, y)

      

None of them work when inside the game window. They work great outside.

Is there a way to make it work? Or another library that I could use?

By the way, win32api.SetCursorPos((x,y))

it doesn't work either.

Thank.

+3


source to share


1 answer


Source Pyautogui

def _sendMouseEvent(ev, x, y, dwData=0):
    assert x != None and y != None, 'x and y cannot be set to None'
    width, height = _size()
    convertedX = 65536 * x // width + 1
    convertedY = 65536 * y // height + 1
    ctypes.windll.user32.mouse_event(ev, ctypes.c_long(convertedX), ctypes.c_long(convertedY), dwData, 0)

      

and this is the win32API that was called SendInput

internally.

The function SendInput

inserts input events into the same queue as the hardware device, but the events are flagged with a flag LLMHF_INJECTED

that can be detected by interceptors. To avoid this flag, you will probably have to write your own driver.

There are many answers and questions about how to simulate a keyboard in a DirectX game that some may say and some say that it is not possible. And you can try this answer which might say



but in my opinion it is necessary to use directx interface to communicate with hardware for speed, then SendInput

insert events only into message queue. And you want to use SendInput

or Mouse_Event

. Since speaking,

No problems that cannot be solved with a different level of indirection

add a message queue for the game.

as? VMware.It is done.

+3


source







All Articles