0

I'm want to simulate a mouse click down in a certain position (not where the mouse cursor is at the current moment):

    INPUT    Input={0};
    // left down 
    Input.type = INPUT_MOUSE;
    Input.mi.dwFlags  = MOUSEEVENTF_VIRTUALDESK | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN;
    Input.mi.dx = normalized_x;
    Input.mi.dy = normalized_y;
    ::SendInput(1,&Input,sizeof(INPUT));

I'm getting this event in the target process, but with coordinates that are the "real" coordinates of the current mouse pointer position and not what I've sent. What am I missing? Is this a normal behavior?

Sanich
  • 1,739
  • 6
  • 25
  • 43
  • It certainly *can* be normal, it is not uncommon for an app to use the current mouse position instead of the position in the WM_LBUTTONDOWN message. Programmers expect them to be the same. Best to add a MOUSEEVENTF_MOVE event as well. – Hans Passant Sep 08 '15 at 09:16
  • @HansPassant I don't want to change the position of the mouse, only send the click to some position. Of course I can save the last position, move with click to the desired position and return to the last position. But then, what is the purpose of the `dx` and `dy` parameters if i use only `MOUSEEVENTF_LEFTDOWN` without `MOUSEEVENTF_MOVE`? – Sanich Sep 08 '15 at 09:20
  • There is a point about these parameters, you have to talk to the programmer of this app why he didn't get the point. This just isn't going to go anywhere of course, you know what his answer is going to be. Use UI Automation instead. – Hans Passant Sep 08 '15 at 09:42

0 Answers0