[Help] C++ SendInput

Posts 1–5 of 5 · Page 1 of 1
[Help] C++ SendInput
[PHP]
void GenerateKey(BYTE vk) {

INPUT Input;
ZeroMemory(&Input, sizeof(Input));
Input.type = INPUT_KEYBOARD;
Input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
Input.ki.wVk = vk;
SendInput(1, &Input, sizeof(INPUT));

return;
}

GenerateKey((UCHAR)VkKeyScan('1'));
GenerateKey(0x31);
[/PHP]

I'm trying to use SendInput to activate an in-game Hotkey(1) which uses a Health Pot bound to that Key.. The problem is that it only calls the 1 Hotkey once, after that it will not use another Potion but it will output 1's in the text-box.. I've narrowed the problem down to the function not releasing the Key after calling it(KEYEVENTF_KEYUP) however I am not sure how to include this in the SendInput function >_<..

Pretty much all I need is a little help understanding how to use the code I have now(which does what I want it to.. almost..) and then release the Key(KEYEVENTF_KEYUP) so that the next time it's called it will be ready again..

Thanks in advance!
+NULL
(GetAsyncKeyState(VK_NUMPAD1)<0)

/
Code:
void GenerateKey(BYTE vk) { 
    INPUT Input;
    ZeroMemory(&Input, sizeof(Input));
    Input.type = INPUT_KEYBOARD;
    Input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
    Input.ki.wVk = vk;
    SendInput(1, &Input, sizeof(INPUT));

    ZeroMemory(&Input, sizeof(Input));
    Input.type = INPUT_KEYBOARD;
    Input.ki.dwFlags = KEYEVENTF_KEYUP;
    Input.ki.wVk = vk;
    SendInput(1, &Input, sizeof(INPUT));

    return;
}
Not tested, but it should look like this
Yes that solved my problem, but now I have ran into another
I'm trying to use the same function to Auto-Attack(Shift+Right Click) but it's not releasing LShift now..

[php]void GenerateKey(BYTE vk) {
INPUT Input;
ZeroMemory(&Input, sizeof(Input));
Input.type = INPUT_KEYBOARD;
Input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
Input.ki.wVk = vk;
SendInput(1, &Input, sizeof(INPUT));

return;
}
void GenerateKey2(BYTE vk) {

INPUT Input;
ZeroMemory(&Input, sizeof(Input));
Input.type = INPUT_KEYBOARD;
Input.ki.dwFlags = KEYEVENTF_KEYUP;
Input.ki.wVk = vk;
SendInput(1, &Input, sizeof(INPUT));

return;
}


void AutoSkill()
{
GenerateKey(0xA0);
Sleep(200);
mouse_event(MOUSEEVENTF_RIGHTDOWN, x, y, 0, 0);
Sleep(100);
mouse_event(MOUSEEVENTF_RIGHTUP, x, y, 0, 0);
Sleep(200);
GenerateKey2(0xA0);
}[/php]


It sends the keys fine(LShift + Right Click) but it doesn't release LShift properly for some reason ><
Never mind, I managed to get the same result(and much easier mind you..) from keybd_event..
This simulates pressing 1, works for what I need it to so.. lol

[php]keybd_event(0x31,MapVirtualKey(0x31,0),0,0);
keybd_event(0x31,MapVirtualKey(0x31,0),KEYEVENTF_K EYUP,0);
[/php]
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us