0
votes

I am trying to record my in-game mouse movement so I can play it back. The game is Call of Duty 4, although that isn't relevant to this question. What is relevant is that most First Person Shooter games re-center the mouse cursor when you move it, so that you never hit any borders. I can't find anything about this online after searching for a while. I am currently using a mouse hook (WH_MOUSE) in order to keep track of the mouse movements (WM_MOUSEMOVE). When I list these messages, I can see that the cursor is pulled back to screenResolutionX / 2, screenResolutionY / 2 (the center of the screen).

My first attempt at figuring this out was to ignore the messages if they are equal to the center of the screen, so that when I play back these mouse movements, the re-centering is ignored. I assumed this would solve the problem, but now when I play back the mouse movements the mouse goes too far (way off from what I recorded). When I do the same recording/playing back in the main menu of the game (where the cursor isn't re-centered), the playback is incredibly accurate. My question is: what can I do to record mouse movements in the game accurately, given that the game re-centers my cursor?

Thanks in advance.

Edit: let me clarify what I'm asking. I want to only record actual user mouse input, not the game re-centering the mouse cursor.

2
Sounds like you should intercept the mouse messages before they get sent to the game's window. Though I'm not sure how exactly would one go about doing that, TBH - YePhIcK
I've come across that SO post, however I don't agree that a driver/filter is necessary to accomplish what I'm trying to do. That would only be the case if I wanted to intercept the mouse data before it gets to Windows, instead I want to intercept it before it gets to the game -- but without the re-centering. Maybe there's a way to determine the origin of the mouse message, and if it was sent by the game process then I ignore it? I couldn't find anything like this though.. - R. Loh
"Windows" is an overloaded term. In the context above the "window" means "game's window", not the "Windows the OS" - YePhIcK
Sorry, it wasn't a response to you, but to the other guy linking an SO post. But people keep removing their comments or something. - R. Loh
If you want to record genuine mouse input, use Raw Input. - IInspectable

2 Answers

0
votes

In order to intercept those mouse messages you'd have to make a filter driver or a hook. Here's a nice article (with code) on the subject:

http://www.oblita.com/interception.html

That article is based on this Windows API: SetWindowsHookEx and shold be a good starting point for you.

0
votes

Have you considered Low Level Mouse Hook? It intercepts mouse messages earlier than just mouse hook.