Alex Rivera | Logout

How to detect if mouse click is legit or automated?

Asked 2011-02-23T13:52:31.440
9

How to know if a mouse click is simulated or not? When mouse click send by a program or real mouse device

... I'm programming a system detection for a game to avoid bots, autoclicks,etc that only accept legit mouse clicks

Edit
Report

3 Answers

7

Although the blog post itself is about a different issue, I refer you to Raymond Chen's excellent Old New Thing. In this specific blog post he talks about the validity of message parameters going into an application, but also makes the point that:

There's no point discussing the possibility that the sender of the message is playing tricks and lying to you because (1) your program should just go along with the ruse and respond to fake menu messages as if they were real menu messages, because (2) there's no way to tell that you're being lied to anyway. To detect lying, you'd have to be able to read into the mindset of the programmer who sent you the message.

Essentially the argument is that you should respond to mouse clicks as mouse clicks, regardless of how those clicks were generated.

answered 2011-02-23T14:29:51.957
2

Is mouse keys simulated mouse input or legit? The point of simulating mouse input is to make them look exactly like real mouse input. If the simulation is doing its job, then your job is impossible. Sorry, that's the blessing & curse of software for you. Here are some more imperfect ideas:

  1. Use GetKeyboardState and verify that the button states are correct. If the message faker is using PostMessage, they will likely not be setting keyboard state and this would indicate fakery.
  2. If you are targeting known applications that are doing the input simulation, detect them and complain. This is not perfect at all for many reasons.
  3. Fuzzy logic, as many other people have suggested.

You need to be creative and figure out the difference between a simulated event and a real one to you, as there is no generalized answer.

answered 2011-02-23T20:46:31.037
0

I'm not sure there is a way to determine with perfect accuracy whether a mouse click is automated or not. I mean, you could write your own USB driver that sits in between the native mouse driver and the OS and relays only "real" clicks to you. However, even that can be defeated by plugging in a USB device (like a smartphone) that's programmed to send USB packets to host computer.

What are you trying to accomplish that requires you to distinguish between real mouse clicks and fake ones?

answered 2011-02-23T14:04:14.560

Your Answer