View previous topic :: View next topic |
Author |
Message |
Deine Mutter Expert Cheater Reputation: 1
Joined: 05 Apr 2006 Posts: 181
|
Posted: Sun Apr 22, 2007 11:20 am Post subject: [C/++] SendInput Problem |
|
|
I'm trying to write a text with SendInput in notepad, i wrote this function
Code: | void WriteText(char* cText){
INPUT Input;
for(int i = 0; i < lstrlen(cText); i++){
ZeroMemory(&Input, sizeof(Input));
Input.type = INPUT_KEYBOARD;
Input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
Input.ki.wVk = VkKeyScan(cText[i]);
SendInput(1, &Input, sizeof(Input));
}
} |
It works pretty fine, but if i wanna write a word like "LAGGER", the output will always be "LAGER" (just one 'G') .. so, whats wrong?
_________________
|
|
Back to top |
|
|
DeltaFlyer Grandmaster Cheater Reputation: 0
Joined: 22 Jul 2006 Posts: 666
|
Posted: Sun Apr 22, 2007 11:34 am Post subject: |
|
|
You need to send a keyup for every keydown that you send. Right now you're only sending keydown.
Code: |
void WriteText(char* cText){
INPUT Input;
for(int i = 0; i < lstrlen(cText); i++){
ZeroMemory(&Input, sizeof(Input));
Input.type = INPUT_KEYBOARD;
Input.ki.wVk =VkKeyScan(cText[i]);
SendInput(1, &Input, sizeof(Input));
Input.ki.dwFlags = KEYEVENTF_KEYUP; //set flag as key up, if not set, it's key down
SendInput(1, &Input, sizeof(Input));
}
}
|
_________________
Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for?
Last edited by DeltaFlyer on Sun Apr 22, 2007 11:37 am; edited 1 time in total |
|
Back to top |
|
|
Deine Mutter Expert Cheater Reputation: 1
Joined: 05 Apr 2006 Posts: 181
|
Posted: Sun Apr 22, 2007 11:37 am Post subject: |
|
|
Oh^^
Thank you very much^^
_________________
|
|
Back to top |
|
|
Noz3001 I'm a spammer Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Sun Apr 22, 2007 11:58 am Post subject: |
|
|
Code: | void SendKey(BYTE vKey)
{
INPUT Input;
ZeroMemory(&Input, sizeof(Input));
Input.type = INPUT_KEYBOARD; // keyboard
Input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
Input.ki.wVk = vKey; // Virtual Key
SendInput(1, &Input, sizeof(INPUT));
} |
|
|
Back to top |
|
|
|