Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Simulate Mouse Presses C++

Name: Anonymous 2011-10-28 17:29

I'm trying to write a program that at the underlying level simulates mouse events. The basic example of what I want it to do is move the mouse, press the mouse down, move the mouse again, and let mouse up to draw a line in say, MS Paint... or the Doodle or Die application (http://doodle.no.de);

The problem I run into is that neither Doodle or die nor MSPaint seem to accept that I am issuing mouse down events... except that MSPaint works fine if I am using a non drawing tool such as the Eraser or Selection.


int main(int argc, char *argv[])
{
    tagINPUT inp;
    tagMOUSEINPUT mi;
    DWORD moveFlags = (MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE);
    DWORD downFlags = (MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN);
    DWORD upFlags = (MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTUP);

    mi.dwFlags = moveFlags;
    mi.dx = 5000;
    mi.dy = 2000;
    inp.type = INPUT_MOUSE;
    inp.mi = mi;

    SendInput(1, &inp, sizeof inp);

    tagMOUSEINPUT mi2;
    tagINPUT inp2;

    SetCursorPos(1500, 500);

    mi2.dwFlags = downFlags;
    inp2.type = INPUT_MOUSE;
    inp2.mi = mi2;
    SendInput(1, &inp2, sizeof inp2);

    SetCursorPos(500,200);
    mi2.dwFlags = upFlags;
    inp2.type = INPUT_MOUSE;
    inp2.mi=mi2;
    SendInput(1, &inp2, sizeof inp2);
   
    return 0;
}


This was just really shit shod together code to try to get something working.

Basically, if MSPaint is up and I have the erase selected, it will erase a line from those 2 points like it should...but if I have the brush selected it will do nothing. Doodle or die (I believe is flash) does the same thing and will not draw.

I'm using windows.h's SendInput, however I have tried the deprecated mouse_event and it does the same thing.

Any ideas on how to get it to actually accept my leftDown and leftUp events?

Name: Anonymous 2011-10-28 22:21

Find one of those programs that records and plays back mouse events like WinMacro:
http://senthilthecoder.com/software/winmacro/download.html

Inspect the source and modify to your needs.

>>8
Totally unnecessarily overcomplicated way of doing it.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List