What is the best way to inject mouse event to application?

I have recorded all of user’s action when mouse up event incurring.
do you know some extra way to inject the recorded event to application ?

I am looking Desktop::setMousePosition(…), but it can move only position and it dosen’t generate click event.

There’s nothing in juce to do that - you’d need to use OS calls to somehow send fake mouse events to the system queue. Not easy!

Or you could do it by calling the ComponentPeer mouse handling methods, I guess. You’d need to work out which ComponentPeer is under the mouse and call handleMouseDown, etc directly.

for the test, I wrote some code like bellowing.
but, it didn’t work… can you figure out the reason ?

/* this function call is working /
this function call is not working /
this function call is not working */

I used 500 mili second for just testing.

Maybe because the componentpeers expect relative co-ords? And you’d need to send your own mouse-move events, too - the setMousePosition updates the mouse pos without actually sending any move messages.

I have modified the codes.
peer->handleMouseMove (sx, sy, 500);
It still doesn’t work.
all function calls in upper codes are not working at all.

is there any threshold time to handle mouse event inside juce core ?

maybe because you’re not sending enter/exit events?..

I took the other way and it could be easier then bellowing.
I have added new api inside Desktop Class.

enum MouseEventFlag
    MouseMoveEvent = 0,
    MouseDownEvent = 1,
    MouseUpEvent = 2,
    MouseWheel = 3
static void setMousePosition (int x, int y);
static void injectInputKey (unsigned short key, unsigned short keyExtention);
static void injectInputMouse (int x, int y, int event=Desktop::MouseMoveEvent, int wheelValue=0);

It works fine with little treaky way to execute multiple command to window system to reproduce recorded same sequence.

Window XP is OK, my window system is OK, but I am not sure XWindows and OSX. It might have similar function or way.

I used SendInput(…) command and a Thread to manipulate command sets without message holding in WindowsXP during feeding.

That’s good to hear. By the way, “bellowing” is probably not quite the word you were looking for!

damn. i was pissing myself laughing without even looking at the post! lol

while I was writing new message, there was previous messages below of text input box. and I misunderstood that using below and following… :oops:

thanks for teaching good engilish, I have learnt a new word in english. :smiley: