simulate key press

i would like to simulate the "w" key being pressed. as if iwas pressing it on the keyboard but the computer does it for me.

1
2
3
4
5
6
7
8
9
10
11
#include <Windows.h>

using namespace std;

int main()
{
	while (true)
	{
		SendInput(0x57);
	}
}
why would you need to simulate having w pressed? why cant you do this?
or is this for a lets say menu screen or an effect in a quote.

#include <iostream>
#include <stdlib.h>

using namespace std;

string input;

int main()
{
while (true)
{
cin >> input;
cout << input << endl;
}
}
Last edited on
Registered users can post here. Sign in or register to post.