| View previous topic :: View next topic |
| Author |
Message |
NuclearPowered Master Cheater
Reputation: 0
Joined: 30 Dec 2007 Posts: 345
|
Posted: Wed Feb 27, 2008 9:07 am Post subject: C++ help needed on sending keystrokes |
|
|
| Code: |
loop:
if(GetAsyncKeyState(VK_F12))
{
cout << "Lololol";
Sleep(1000);
}
if(GetAsyncKeyState(VK_F11))
{
return 0;
}
goto loop;
}
|
What I want it to do is when I press F12 it types "You got roflmayonaise" and then presses enter.
I added the sleep to prevent it from sending lololol 5000x when I just hold F12 for 10 milliseconds...
Also I need a better way of looping because I heard using goto is really bad.
I checked up SendInput on msdn but I dont understand microsoft language :/
All help is appreciated.
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Wed Feb 27, 2008 9:51 am Post subject: |
|
|
while (0)
{
}
for (;
{
}
|
|
| Back to top |
|
 |
Zand Master Cheater
Reputation: 0
Joined: 21 Jul 2006 Posts: 424
|
Posted: Wed Feb 27, 2008 10:00 am Post subject: |
|
|
while(TRUE)
same as
while(1)
never tried while(0)...
or
#define EVER ;;
for(EVER)
{
}
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Feb 27, 2008 10:05 am Post subject: Re: C++ help needed on sending keystrokes |
|
|
| NuclearPowered wrote: | | Code: |
loop:
if(GetAsyncKeyState(VK_F12))
{
cout << "Lololol";
Sleep(1000);
}
if(GetAsyncKeyState(VK_F11))
{
return 0;
}
goto loop;
}
|
What I want it to do is when I press F12 it types "You got roflmayonaise" and then presses enter.
I added the sleep to prevent it from sending lololol 5000x when I just hold F12 for 10 milliseconds...
Also I need a better way of looping because I heard using goto is really bad.
I checked up SendInput on msdn but I dont understand microsoft language :/
All help is appreciated. |
Yes, goto is bad. Also make a way to exit, since I'm assuming you're using a thread to do GetAsyncKeyState.
Also also, try this: http://www.codeproject.com/KB/cpp/togglekeys.aspx
|
|
| Back to top |
|
 |
systat Advanced Cheater
Reputation: 0
Joined: 15 Feb 2008 Posts: 54
|
Posted: Wed Feb 27, 2008 1:02 pm Post subject: |
|
|
| Code: | void SendSpam(string Txt) {
for(int i=0;i<Txt.length();i++) {
keybd_event(BYTE(VkKeyScan(Txt[i])),0,0,0);
}
keybd_event(VK_RETURN,0,0,0);
} |
There you go, multifunctional spammer.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Thu Feb 28, 2008 5:49 am Post subject: |
|
|
Where are you trying to send the key strokes to? Or just type it to a console window?
_________________
- Retired. |
|
| Back to top |
|
 |
|