Fixed CLICK and RIGHT CLICK bindings

This commit is contained in:
CTurt 2014-12-13 21:27:32 +00:00
parent f373be6ce9
commit 490d3c7632

View file

@ -14,25 +14,41 @@ inline unsigned int mapVirtualKey(unsigned int key) {
void simulateKeyNewpress(unsigned int key) {
if(!key) return;
INPUT ip;
ip.type = INPUT_KEYBOARD;
ip.ki.wScan = mapVirtualKey(key);
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
ip.ki.wVk = 0;
ip.ki.dwFlags = KEYEVENTF_SCANCODE;
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.ki.wScan = mapVirtualKey(key);
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
ip.ki.wVk = 0;
ip.ki.dwFlags = KEYEVENTF_SCANCODE;
}
SendInput(1, &ip, sizeof(INPUT));
}
void simulateKeyRelease(unsigned int key) {
if(!key) return;
INPUT ip;
ip.type = INPUT_KEYBOARD;
ip.ki.wScan = mapVirtualKey(key);
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
ip.ki.wVk = 0;
ip.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
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.ki.wScan = mapVirtualKey(key);
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
ip.ki.wVk = 0;
ip.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
}
SendInput(1, &ip, sizeof(INPUT));
}