Sending a string to a program.

I have a project, to make a program that spams chat programs. I've been trying to figure out how to send a string to an open program such as notepad, or a chat window. I know how to simulate keystrokes but I have yet to figure out or find out any way of sending a string to a program. pseudo code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int main()
{ 
string a;
int howManyTimes;
cin >> a;
cin >> howManyTimes;

//user enters "pizza"
for(int i = 0; i < howManyTimes; i++)
{
//now I want "pizza" to be sent to the program
keystroke enter or whatever the correct syntax is
sleep 
}
}


Did you try std::cout << a << std::endl;? What other way do you have of sending the message?
Topic archived. No new replies allowed.