Hi, I have been making a macro building program. I am trying to handle mouse events right now. I have made a program that hooks the mouse, then puts information into a text file which is then read by another program. The recorder writes the delay in milliseconds, so the events don't just happen at one time. It then writes the type of the event. Then it writes the other information like X and Y, right mouse button, wheel, intensity, etc. . I have no idea if this is a good way to do this or not, or how to read the file so I can simulate mouse events. Please help.:icon_neutral:

The code is attached. I'm using Dev-C++
Here is some output from the program that records the mouse:

1922 MMOVE 530 437
1938 MMOVE 529 437
3078 MWHEEL 120
7422 MDOWN R
7594 MUP R
11031 MMOVE 529 436
11094 MMOVE 529 435
11172 MMOVE 529 435
11188 MMOVE 529 434
11250 MMOVE 529 434
11860 MMOVE 528 434
11875 MMOVE 528 434
11953 MMOVE 527 434
12547 MDOWN L
12625 MUP L

Recommended Answers

All 4 Replies

you want to read it? easy.

use an ifstream object on the file, read it into an event_info structure (like struct event_info { int something;string event;int x;int y; } )

and simulate the events (mouse_event for mup/mdown, SetCursorPos() for move)

*walks away now*

funnily enough, I have just finished making the exact same thing :), take a look at it if you like, its pretey cool and allows you set set playback speeds & more. Hopefully I will also help you with your problem.

My one saves all the data in pure binary, so it is a bit more compressed than the way your trying to do it. It saves each event in the following structure:

[B]eventID[/B]   [B]keyCode[/B]   [B]x[/B]   [B]y[/B]   [B]delay[/B]

Each variable uses exactly 2 bytes.

I have attached the project, I forgot to mention that its not a console application, but a Win32 API project.
Sorry about my un-neat / un-commented code :P

commented: You always give me something I am looking for. Great! +1

Ive gone through mine, formatted and commented it to make it easier to understand, also fixed a couple big problems in it.

Hope it helps :P


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.