3

I've been tinkering with the win32api library on Python and interacting with Notepad. I now want to try it on an online game to automate some boring tasks but I'm scared I get banned for this.

Is for example a click generated with PostMessageA() differentiable from a real click ? And if yes, is it common to check for this ?

1
  • Faking the click itself may be not so difficult, but the mouse movements can be used for detecting scripting activities. A script never moves a mouse like it would do a human.
    – Robert
    May 24, 2023 at 12:11

1 Answer 1

2

If a game wants it can easily distinguish between simulated and real mouse clicks. For example, a game can install low-level mouse hook (it will not require admin privileges) and look at LLMHF_INJECTED flag in the MSLLHOOKSTRUCT structure available inside LowLevelMouseProc callback function.
To deceive a game, you need a button press simulation being generated inside a HID driver.

For example, Logitech gaming series mice/keyboards have such a possibility: they execute user-written Lua scripts inside its official mouse/keyboard driver. The driver is native: it's written by Logitech and signed by Microsoft, it is bundled with GHub Logitech software. Simulated from a Lua script button clicks are indistinguishable from real clicks.

Another option is to use a self-made external hardware device: a USB mouse device that listens from another COM/USB-port what actions it should do. Since the device is a real mouse handled by a standard Microsoft HID driver, a game would be unable to detect the fake.

Button click timing is another problem when you are trying to avoid being banned for using any kind of mouse automation. You should use realistic delay intervals between simulated button press/release events without a repeatable pattern. In other words, you should use some randomization, in Logitech Lua scripts you can use Sleep(math.random(min_delay, max_delay)) for this purpose.

2
  • The thing is I'd like to be able to use my program in the background while still using my computer, and I think what you described with Lua can only interact with the focus/foreground window. And I think it isn't possible to fake the LLMHF_INFECTED flag
    – Mostunique
    May 24, 2023 at 19:54
  • In other words, you want to send a mouse click event to a background window? It might be not working at all even if game does not make any attempt to detect automation.
    – ESkri
    May 24, 2023 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.