djpnewton / vmulti

Virtual Multiple HID Driver (multitouch, mouse, digitizer, keyboard, joystick)
MIT License
401 stars 171 forks source link

How to send a mouse left button click(down and up) to HID? #31

Closed BruceMok closed 3 years ago

BruceMok commented 3 years ago

The "testvmulti.c" show us how to move mouse, but i have no idea to send mouse button event.

case REPORTID_MOUSE: // // Send the mouse report // printf("Sending mouse report\n"); //vmulti_update_mouse(vmulti, 0, 1000, 10000, 0); vmulti_update_mouse(vmulti, MOUSE_BUTTON_1, 18500, 18000, 0); break; I'm trying to do like this, but not worked.

djpnewton commented 3 years ago

The desktop input process might be a bit sensitive to how you send it events. You can try emulating how an actual hardware mouse might send events:

eg:

vmulti_update_mouse(vmulti, 0, 18500, 18000, 0); // move to location
Sleep(10);
vmulti_update_mouse(vmulti, MOUSE_BUTTON_1, 18500, 18000, 0); // press mouse button
Sleep(10);
vmulti_update_mouse(vmulti, 0, 18500, 18000, 0); // unpress mouse button
BruceMok commented 3 years ago

It works! thanks very much.