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 


[HELP] Press and hold key using SendInput

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
sphere90
Grandmaster Cheater
Reputation: 0

Joined: 24 Jun 2006
Posts: 912

PostPosted: Sun Apr 12, 2009 7:48 am    Post subject: [HELP] Press and hold key using SendInput Reply with quote

How do I simulate pressing and holding a key using SendInput?
_________________
Give a hungry man a fish and he'll be full for a day. Teach a hungry man how to fish and he'll be full for the rest of his life.
Back to top
View user's profile Send private message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Sun Apr 12, 2009 8:22 am    Post subject: Reply with quote

u specify it inside INPUT struct


Code:
void SendKey (UINT Key, int times)
{
   for (int i=0;i<times;i++)
   {
      INPUT Input;
      ZeroMemory(&Input, sizeof(Input));
      Input.type = INPUT_KEYBOARD; // keyboard
      Input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
      Input.ki.wVk =(WORD) Key; // Virtual Key
      SendInput(1, &Input, sizeof(INPUT));
      
      Input.ki.dwFlags = KEYEVENTF_KEYUP;
      SendInput(1, &Input, sizeof(INPUT));
   }
}

void KeyDown (UINT Key)
{
   INPUT Input;
   ZeroMemory(&Input, sizeof(Input));
   Input.type = INPUT_KEYBOARD; // keyboard
   Input.ki.wVk =(WORD) Key; // Virtual Key
   Input.ki.dwFlags = 0;
   
   SendInput(1, &Input, sizeof(INPUT));
}

void KeyUp (UINT Key)
{
   INPUT Input;
   ZeroMemory(&Input, sizeof(Input));
   Input.type = INPUT_KEYBOARD; // keyboard
   Input.ki.wVk =(WORD) Key; // Virtual Key
   Input.ki.dwFlags = KEYEVENTF_KEYUP;
   
   SendInput(1, &Input, sizeof(INPUT));
}

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils
Back to top
View user's profile Send private message
sphere90
Grandmaster Cheater
Reputation: 0

Joined: 24 Jun 2006
Posts: 912

PostPosted: Sun Apr 12, 2009 8:24 am    Post subject: Reply with quote

So I guess I still need to use a loop to achieve that.
_________________
Give a hungry man a fish and he'll be full for a day. Teach a hungry man how to fish and he'll be full for the rest of his life.
Back to top
View user's profile Send private message
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Sun Apr 12, 2009 9:21 am    Post subject: Reply with quote

You don't need to use a loop to simulate holding a key. Just send KeyDown() to simulate holding down a key, and when you want to release the key send KeyUp().
Back to top
View user's profile Send private message
sphere90
Grandmaster Cheater
Reputation: 0

Joined: 24 Jun 2006
Posts: 912

PostPosted: Sun Apr 12, 2009 9:22 am    Post subject: Reply with quote

TraxMate wrote:
You don't need to use a loop to simulate holding a key. Just send KeyDown() to simulate holding down a key, and when you want to release the key send KeyUp().

If that works, I won't be posting here in the first place.

_________________
Give a hungry man a fish and he'll be full for a day. Teach a hungry man how to fish and he'll be full for the rest of his life.
Back to top
View user's profile Send private message
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Sun Apr 12, 2009 9:38 am    Post subject: Reply with quote

It works for me (atleast on MapleStory).
Back to top
View user's profile Send private message
manc
Grandmaster Cheater
Reputation: 1

Joined: 16 Jun 2006
Posts: 551

PostPosted: Sun Apr 12, 2009 10:38 pm    Post subject: Reply with quote

TraxMate wrote:
It works for me (at least on MapleStory).


works for me too

ie.

KeyDown(0x27);
Sleep 5000;
KeyUp(0x27);


will make you walk right for 5 seconds in maplestory o,o

but the question is, does this even have anything to do with maplestory? I just assumed so due to Bizzaro's post. Nvm I just confused myself but yeah, surely Google could yield some useful results.
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Apr 13, 2009 9:11 am    Post subject: Reply with quote

But that is using iMax Macro? right?

How do you know he's not sending multiple key strokes in a row waiting till the user ends it with a KeyUp of the same value?

Anyways, If you download something like ControlSpy from Microsoft, and you test out key presses on controls you see that there is a WM_KEYDOWN message for every time a character comes up, regardless if your holding it down, then once you release it, a WM_KEYUP message.

_________________
Back to top
View user's profile Send private message
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Mon Apr 13, 2009 11:20 am    Post subject: Reply with quote

@lurc: I've never used iMax Macro, I used SendInput from my own app.

Anyways, if that doesn't work for what you are trying to do then I guess you'll need to use it in a loop.
Back to top
View user's profile Send private message
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