| View previous topic :: View next topic |
| Author |
Message |
AwayTheWInd Master Cheater
Reputation: 0
Joined: 11 Sep 2007 Posts: 450
|
Posted: Sun Mar 22, 2009 7:56 am Post subject: [C++ Help] Holding down a key. |
|
|
Ok, i cant get my program to hold down a key. im specifically using this method:
keybd_event(VK_SPACE,0,0,0);
and leaving it like that.
It seems to only press space once, and not hold it down o.O
whats wrong with it?
_________________
|
|
| Back to top |
|
 |
talkerzero Grandmaster Cheater
Reputation: 1
Joined: 24 Jul 2008 Posts: 560 Location: California
|
Posted: Sun Mar 22, 2009 8:20 am Post subject: |
|
|
| keybd_event will press the key, not hold it down/let it go. You can accomplish what you're trying to do with SendInput.
|
|
| Back to top |
|
 |
AwayTheWInd Master Cheater
Reputation: 0
Joined: 11 Sep 2007 Posts: 450
|
Posted: Sun Mar 22, 2009 8:22 am Post subject: |
|
|
keybd_event uses SendInput.
also, i tried SendInput and it did not work.
these are my functions:
void SpaceDown()
{
Input.type = INPUT_KEYBOARD;
Input.ki.wVk = VK_SPACE;
Input.ki.dwFlags = 0;
Input.ki.time = 0;
SendInput(1,&Input, sizeof(INPUT));
RtlZeroMemory(&Input, sizeof(INPUT));
}
void SpaceUp()
{
Input.type = INPUT_KEYBOARD;
Input.ki.wVk = VK_SPACE;
Input.ki.dwFlags = KEYEVENTF_KEYUP;
Input.ki.time = 0;
SendInput(1,&Input, sizeof(INPUT));
RtlZeroMemory(&Input, sizeof(INPUT));
}
_________________
|
|
| Back to top |
|
 |
|