c++ sendInput to siege problem
hello , i met a problem of siege with c++. i tried to use sendinput function to press 'q' for me and lean left. it works in notepad, r6 chat. it presses 'q' for me. but it doesnt help me lean, it helps me knife and open the scoreboard instead.
code:
Code:
class KeyBot
{
private:
INPUT _buffer[1];
public:
KeyBot();
void KeyUp(char key);
void KeyDown(char key);
void KeyClick(char key);
};
KeyBot::KeyBot()
{
_buffer->type = INPUT_KEYBOARD;
_buffer->ki.wScan = 0;
_buffer->ki.time = 0;
_buffer->ki.dwExtraInfo = 0;
}
void KeyBot::KeyUp(char key)
{
_buffer->ki.wVk = key;
_buffer->ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, _buffer, sizeof(INPUT));
}
void KeyBot::KeyDown(char key)
{
_buffer->ki.wVk = key;
_buffer->ki.dwFlags = 0;
SendInput(1, _buffer, sizeof(INPUT));
}
void KeyBot::KeyClick(char key)
{
KeyDown(key);
Sleep(10);
KeyUp(key);
}
int main(void) {
KeyBot bot;
while (true)
{
if (GetAsyncKeyState(0x26)) { //0x45 = E
//0x51 = Q
//0x26 = up
//0x25 = left
//0x27 = right
bot.KeyDown(0x51);
Sleep(10);
bot.KeyUp(0x51);
}
Sleep(100);
}
so when i press up arrow now, it presses q for me. but not lean for me. does anyone know whats the problem?
- - - Updated - - -
another tested code :
while 1
if(getkey(uparrow)){
INPUT ip;
ip.type = INPUT_KEYBOARD;
ip.ki.wScan = 0;
ip.ki.time = 2;
ip.ki.dwExtraInfo = 0;
ip.ki.wVk = 0x51;
ip.ki.dwFlags = 0;
SendInput(1, &ip, sizeof(INPUT));
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));