| View previous topic :: View next topic |
| Author |
Message |
sphere90 Grandmaster Cheater
Reputation: 0
Joined: 24 Jun 2006 Posts: 912
|
Posted: Sun Apr 12, 2009 7:48 am Post subject: [HELP] Press and hold key using SendInput |
|
|
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 |
|
 |
Bizarro I post too much
Reputation: 0
Joined: 01 May 2007 Posts: 2648
|
Posted: Sun Apr 12, 2009 8:22 am Post subject: |
|
|
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 |
|
 |
sphere90 Grandmaster Cheater
Reputation: 0
Joined: 24 Jun 2006 Posts: 912
|
Posted: Sun Apr 12, 2009 8:24 am Post subject: |
|
|
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 |
|
 |
TraxMate Master Cheater
Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Sun Apr 12, 2009 9:21 am Post subject: |
|
|
| 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 |
|
 |
sphere90 Grandmaster Cheater
Reputation: 0
Joined: 24 Jun 2006 Posts: 912
|
Posted: Sun Apr 12, 2009 9:22 am Post subject: |
|
|
| 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 |
|
 |
TraxMate Master Cheater
Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Sun Apr 12, 2009 9:38 am Post subject: |
|
|
| It works for me (atleast on MapleStory).
|
|
| Back to top |
|
 |
manc Grandmaster Cheater
Reputation: 1
Joined: 16 Jun 2006 Posts: 551
|
Posted: Sun Apr 12, 2009 10:38 pm Post subject: |
|
|
| 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 |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Mon Apr 13, 2009 9:11 am Post subject: |
|
|
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 |
|
 |
TraxMate Master Cheater
Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Mon Apr 13, 2009 11:20 am Post subject: |
|
|
@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 |
|
 |
|