0

I want to generate a mouse click at a specific position inside a game(Everquest project 1999). As it turns out the game only takes mouse input directly from the port. I have previously used PyAutoGUI Java Robot pywin32 and many similar modules and libraries but all fail to deliver a click inside the game since its not absorbing virtual clicks. There is no possible solution for this on all of the internet. Is there any way to inject a mouse click in the IO stream like a natural mouse click.

import pyautogui
pyautogui.click(100, 150)

This is an example of a virtually generated click that doesn't gets absorbed by the game.

Ammar H Sufyan
  • 97
  • 1
  • 3
  • 13

2 Answers2

1

With libraries like pyinput you can only emulate mouse events in the window that is in focus/foreground and only if it is in the same process. If you want to generally inject or monitor mouse or keyboard events also in processes different from the calling process (like in your case) you have to establish a mouse hook or keyboard hook in windows.

https://learn.microsoft.com/en-us/windows/win32/winmsg/about-hooks https://www.codeproject.com/Articles/19858/Global-Windows-Hooks

In linux is the evdev system and xdotool

In java on windows you have to invoke JNI like in this library : https://github.com/kwhat/jnativehook

Also see this programmatically mouse click in another window and this git https://github.com/boppreh/mouse

ralf htp
  • 9,149
  • 4
  • 22
  • 34
0

Even the Windows hooks didn't work with the game. We ended up opening the game on a remote desktop server and running the automation code over it, which worked.

Ammar H Sufyan
  • 97
  • 1
  • 3
  • 13