Need message

Hi im trying to make a program that sends a message to a text file or skype and such i only want 1 message so far i only get 1 million messages that keep going all over the .txt i also want it to press enter and enter once but im having bad luck with this any suggestions?
SendKeys::Send ("Message") ;
SendKeys::Send ("{ENTER}") ;
Can you show us the definition of SendKeys::Send(char*) ?
What do you mean? im still new to C++
When you use SendKeys::Send ("Message") ; you are calling a function called Send() with the character array "Message". What is done inside the function is unknown to me without the code. We need that body if we want to help you.

It's probably in a SendKeys.h header. If you don't have the body of the Send() function, you'll need to refer to the documentation of the function which should be available on the same website that you got the header from.

Edit:
Another thing that you could look for is that the Send() function is not called inside a loop. Something like this:
1
2
for (int i =0; i < 1000000; i++)
    SendKeys::Send ("Message");

would send the message one million times as you had mentioned.
Last edited on
Well im putting this on a timer
for (int i =0; i < 1000000; i++)
SendKeys::Send ("Message");
But i need this on a timer that goes in 5 second then send the message onto text
That explains it!!!

To do this from scratch, you need to do some multi-threading which is not a beginner subject. To help we need to know what platform (windows/linux) you are using and what compiler you are using (To see if you support C++11).

I like to use Qt's QTimer class which lets me create a clock and pass a callback function to it. The clock will call this function ever X milliseconds indefinitely or for a specified number of times. To use this class, you need to install the Qt SDK.
http://qt-project.org/doc/qt-4.8/QTimer.html

I'm sure there are other classes available in other libraries that others can recommend.


Edit: Idea! If you are using a C++11 compiler, you can use std::thread to create a thread. (see http://en.cppreference.com/w/cpp/thread/thread)
Then you can do this inside of that thread:
1
2
3
4
5
6
7
8
void MyThreadFunction()
{
    while(true)
    {
        SendKeys::Send ("Message");
        Sleep(5000); // Pauses for 5sec
    }
}


To use Sleep() you need to include <windows.h> on a windows machine. I'm not sure what the equivalent is on a linux machine.

Last edited on
Ive used this and get error sleep identifier not found
SendKeys::Send ("Message");
Sleep(5000); // Pauses for 5sec
Im using MCV C++ express 2010
I think you should just go search up some C++ tutorials, it seems like you have no clue what you're doing

You're getting that error because you havent included the right header for that function

As StewBond said you need to include <windows.h> to use that function
Last edited on
Agreed
Topic archived. No new replies allowed.