Fixed CLICK and RIGHT CLICK bindings
This commit is contained in:
parent
f373be6ce9
commit
490d3c7632
1 changed files with 30 additions and 14 deletions
|
@ -14,25 +14,41 @@ inline unsigned int mapVirtualKey(unsigned int key) {
|
||||||
void simulateKeyNewpress(unsigned int key) {
|
void simulateKeyNewpress(unsigned int key) {
|
||||||
if(!key) return;
|
if(!key) return;
|
||||||
|
|
||||||
INPUT ip;
|
INPUT ip = { 0 };
|
||||||
|
|
||||||
|
if(key == VK_LBUTTON || key == VK_RBUTTON) {
|
||||||
|
ip.type = INPUT_MOUSE;
|
||||||
|
ip.mi.dwFlags = key == VK_LBUTTON ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_RIGHTDOWN;
|
||||||
|
}
|
||||||
|
else {
|
||||||
ip.type = INPUT_KEYBOARD;
|
ip.type = INPUT_KEYBOARD;
|
||||||
ip.ki.wScan = mapVirtualKey(key);
|
ip.ki.wScan = mapVirtualKey(key);
|
||||||
ip.ki.time = 0;
|
ip.ki.time = 0;
|
||||||
ip.ki.dwExtraInfo = 0;
|
ip.ki.dwExtraInfo = 0;
|
||||||
ip.ki.wVk = 0;
|
ip.ki.wVk = 0;
|
||||||
ip.ki.dwFlags = KEYEVENTF_SCANCODE;
|
ip.ki.dwFlags = KEYEVENTF_SCANCODE;
|
||||||
|
}
|
||||||
|
|
||||||
SendInput(1, &ip, sizeof(INPUT));
|
SendInput(1, &ip, sizeof(INPUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
void simulateKeyRelease(unsigned int key) {
|
void simulateKeyRelease(unsigned int key) {
|
||||||
if(!key) return;
|
if(!key) return;
|
||||||
|
|
||||||
INPUT ip;
|
INPUT ip = { 0 };
|
||||||
|
|
||||||
|
if(key == VK_LBUTTON || key == VK_RBUTTON) {
|
||||||
|
ip.type = INPUT_MOUSE;
|
||||||
|
ip.mi.dwFlags = key == VK_LBUTTON ? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_RIGHTUP;
|
||||||
|
}
|
||||||
|
else {
|
||||||
ip.type = INPUT_KEYBOARD;
|
ip.type = INPUT_KEYBOARD;
|
||||||
ip.ki.wScan = mapVirtualKey(key);
|
ip.ki.wScan = mapVirtualKey(key);
|
||||||
ip.ki.time = 0;
|
ip.ki.time = 0;
|
||||||
ip.ki.dwExtraInfo = 0;
|
ip.ki.dwExtraInfo = 0;
|
||||||
ip.ki.wVk = 0;
|
ip.ki.wVk = 0;
|
||||||
ip.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
|
ip.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
|
||||||
|
}
|
||||||
|
|
||||||
SendInput(1, &ip, sizeof(INPUT));
|
SendInput(1, &ip, sizeof(INPUT));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue