Need message

Oct 28, 2012 at 3:54pm
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}") ;
Oct 28, 2012 at 3:57pm
Can you show us the definition of SendKeys::Send(char*) ?
Oct 28, 2012 at 4:28pm
What do you mean? im still new to C++
Oct 28, 2012 at 4:41pm
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 Oct 28, 2012 at 4:42pm
Oct 28, 2012 at 4:52pm
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
Oct 28, 2012 at 5:00pm
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 Oct 28, 2012 at 5:07pm
Oct 28, 2012 at 5:18pm
Ive used this and get error sleep identifier not found
SendKeys::Send ("Message");
Sleep(5000); // Pauses for 5sec
Im using MCV C++ express 2010
Oct 28, 2012 at 5:32pm
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 Oct 28, 2012 at 5:34pm
Oct 28, 2012 at 9:35pm
Agreed
Topic archived. No new replies allowed.