Simulate a mouse click for side buttons

I know how to use mouse_event to simulate a mouse click for left or right buttons. What I would like to know is if this function or another in C # / C ++ allows you to simulate the mouse4 or mouse5 buttons that have gaming mice?

+6
source share
2 answers

mouse4 and mouse5 on Windows are called xbutton1 and xbutton2

You can use them:

 mouse_event(MOUSEEVENTF_XDOWN, NULL, NULL, XBUTTON1, NULL); mouse_event(MOUSEEVENTF_XDOWN, NULL, NULL, XBUTTON2, NULL); mouse_event(MOUSEEVENTF_XUP, NULL, NULL, XBUTTON1, NULL); mouse_event(MOUSEEVENTF_XUP, NULL, NULL, XBUTTON2, NULL); 
+1
source

You can create a RAWINPUT structure and send it using the WM_INPUT window window to the window.

WM_INPUT Link
RAWINPUT Link
link RAWINPUT P / Invoke

In particular, you will need to create a RAWMOUSE structure for use inside RAWINPUT . the RAWMOUSE usButtonFlags field may contain information about the 4th and 5th mouse buttons.

RAWMOUSE link
link RAWMOUSE P / Invoke
RAWMOUSEBUTTONS Enumeration P / Invoke reference

The exact implementation you need to use depends on the target application and platform. You may need to register a raw input window before it receives any WM_INPUT messages.

0
source

All Articles