Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C/++] SendInput Problem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Deine Mutter
Expert Cheater
Reputation: 1

Joined: 05 Apr 2006
Posts: 181

PostPosted: Sun Apr 22, 2007 11:20 am    Post subject: [C/++] SendInput Problem Reply with quote

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
View user's profile Send private message
DeltaFlyer
Grandmaster Cheater
Reputation: 0

Joined: 22 Jul 2006
Posts: 666

PostPosted: Sun Apr 22, 2007 11:34 am    Post subject: Reply with quote

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
View user's profile Send private message
Deine Mutter
Expert Cheater
Reputation: 1

Joined: 05 Apr 2006
Posts: 181

PostPosted: Sun Apr 22, 2007 11:37 am    Post subject: Reply with quote

Oh^^

Thank you very much^^

_________________
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Sun Apr 22, 2007 11:58 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites