简体   繁体   English

模拟鼠标单击侧按钮

[英]Simulate mouse click for side buttons

I am aware of how to use mouse_event to simulate a mouse click for the left or right buttons. 我知道如何使用mouse_event模拟鼠标左键或右键。 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 gaming mice have? 我想知道的是,如果C#/ C ++中的这个功能或其他功能允许您模拟游戏鼠标所具有的mouse4或mouse5按钮?

mouse4 and mouse5 in windows are named xbutton1 and xbutton2 mouse4mouse5在窗口被命名为xbutton1xbutton2

You can use these: 你可以使用这些:

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);

You could create a RAWINPUT structure and send it using the WM_INPUT windows message to the window. 您可以创建RAWINPUT结构并使用WM_INPUT窗口消息将其发送到窗口。

WM_INPUT reference WM_INPUT参考
RAWINPUT reference RAWINPUT参考
RAWINPUT P/Invoke reference RAWINPUT P / Invoke参考

Speifically, you will need to create a RAWMOUSE struct for use inside the RAWINPUT . RAWMOUSE ,您需要创建一个RAWMOUSE结构,以便在RAWINPUT使用。 the RAWMOUSE 's usButtonFlags field can contain info regarding the 4th and 5th mouse buttons. RAWMOUSEusButtonFlags字段可以包含有关第4和第5个鼠标按钮的信息。

RAWMOUSE reference RAWMOUSE参考
RAWMOUSE P/Invoke reference RAWMOUSE P / Invoke参考
RAWMOUSEBUTTONS Enumeration P/Invoke reference RAWMOUSEBUTTONS枚举P / Invoke引用

The exact implementation you will need to use depends on the target application and platform. 您需要使用的确切实现取决于目标应用程序和平台。 You may need to register the window for raw input before it will receive any WM_INPUT messages. 您可能需要在接收任何WM_INPUT消息之前注册原始输入窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM