Reputation: 133
Is it possible to detect if the middle button is being held down in c++? I saw this question, but it did not mention anything about listening for buttons except the left mouse button.
I want
int main(){
while (1){
while((GetKeyState(VK_LBUTTON) & 0x100) != 0){
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
Sleep(10);
}
}
return 0;
}
but instead of triggering when the left button is pressed, triggering when the middle button is pressed.
Upvotes: 0
Views: 420
Reputation: 26703
You are specifically asking about how to do something for the middle mouse button which you have only found explained for the left mouse button. (At least you stress that very much, though I do not see how the shown code is applicable....)
So when searching for MOUSEEVENTF_LEFTDOWN
and VK_LBUTTON
I found that e.g. here, they are listed among very promising siblings, especially MOUSEEVENTF_MIDDLEDOWN
and VK_MBUTTON
.
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-mouse_event
https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
Since you only ask about the difference between left and middle, you should be set with this information.
Upvotes: 1