Looking to start my first C++ Project

Posts 1630 of 43 · Page 2 of 3
Unless you have to add an extra header to Why06's code, it didn't compile for me, and for some reason it censors

S e t C l i p b o a r d D a t a

What I gave you should work to copy to the Clipboard.
[php]#include <iostream>
#include <windows.h>

using namespace std;

char* message;

int main()
{
cout<<"Please input the message you wish to be spammed: " << endl;
cin.getline(message, sizeof message);
cout<<message<<endl;
system("pause");

Se***ipboardTextA(message); // Set ClipboardTextA
return 0;
}

[/php]

Just a few problems. That should clear things up. Change the function to what's in comments without the spaces.

EDIT: My bad..... it appears that function doesn't exist xD... Guess no short cut's for me You'll have to do it David's way.

I just prefer ASCII... but I apparently I still have to do all that Allocation stuff which I suk with. Or never attempted to learn I should say.
Quote Originally Posted by why06 View Post
[php]#include <iostream>
#include <windows.h>

using namespace std;

char* message;

int main()
{
cout<<"Please input the message you wish to be spammed: " << endl;
cin.getline(message, sizeof message);
cout<<message<<endl;
system("pause");

Se***ipboardTextA(message); // Set ClipboardTextA
return 0;
}

[/php]

Just a few problems. That should clear things up. Change the function to what's in comments without the spaces.

EDIT: My bad..... it appears that function doesn't exist xD... Guess no short cut's for me You'll have to do it David's way.
You guys have been a great help and i'm only a few steps away from completing it, (against my will I might add.) But, this is what I have.

[php]#include <iostream>
#include <windows.h>
using namespace std;

char* pMessage;
char* text = pMessage;

int main()
{
cout <<"Please Input The Message You Wish To Be Spammed: ";
getline(cin, pMessage);
system("pause");
OpenClipboard(NULL);
EmptyClipboard();
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE,strlen(pMessage)+1);
LPTSTR textPointer = (LPTSTR)GlobalLock(hMem);
memcpy(textPointer,pMessage,strlen(pMessage)+1);
GlobalUnlock(hMem);
Se***ipboardData(CF_TEXT,hMem);
CloseClipboard();
return 0;
}
[/php]

No errors accept this, but it brings me back to my earlier issue. I don't believe that getline() can handle pointers, or I messed up and tried to convert variable types somewhere.

11 C:\Documents and Settings\iLoveCookies\Desktop\main.cpp no matching function for call to `getline(std::istream&, char*&)'
Quote Originally Posted by ilovecookies View Post
11 C:\Documents and Settings\iLoveCookies\Desktop\main.cpp no matching function for call to `getline(std::istream&, char*&)'
Well I suk with windows, but I can solve that for you atleast:
Code:
char message[100];

int main()
{
    cout<<"Please input the message you wish to be spammed: " << endl;
    cin.getline(message, sizeof message);
    cout<<message<<endl;
    system("pause");
    return 0;
}
getline has to be called on an ifstream object.
Quote Originally Posted by why06 View Post
Well I suk with windows, but I can solve that for you atleast:
Code:
char message[100];

int main()
{
    cout<<"Please input the message you wish to be spammed: " << endl;
    cin.getline(message, sizeof message);
    cout<<message<<endl;
    system("pause");
    return 0;
}
getline has to be called on an ifstream object.
Why, you are god. But there's something STILL wrong. All the syntax is correct, it compiles, it runs, it doesn't copy to clipboard. o_o If it copied to clipboard, I should be able to ctrl + v to display it has been copied right? Or will it only function within the program?
Quote Originally Posted by ilovecookies View Post
Why, you are god. But there's something STILL wrong. All the syntax is correct, it compiles, it runs, it doesn't copy to clipboard. o_o If it copied to clipboard, I should be able to ctrl + v to display it has been copied right? Or will it only function within the program?
You did add that code to David's code right? o_o
IT'S DONE! IF you read the post that I'm editing over, LOL i'm retarded. I used "V" instead of 'V', so yeah. I'mma test it all out and if it works, i'll post the results.

Well it is in fact done, but I have an issue. It copies the message to the clipboard, but it doesn't spam it. And I get no compile time errors. Here's the code. I tried doing it as 2 functions at first, a main, and the spam loop, but I decided it's probably be better to put them both together in main.

[php]#include <iostream>
#include <windows.h>
#include <time.h>
using namespace std;

char pMessage[100];



int main()
{
cout <<"Please Input The Message You Wish To Be Spammed: ";
cin.getline(pMessage,sizeof pMessage);
OpenClipboard(NULL);
EmptyClipboard();
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE,strlen(pMessage)+1);
LPTSTR textPointer = (LPTSTR)GlobalLock(hMem);
memcpy(textPointer,pMessage,strlen(pMessage)+1);
GlobalUnlock(hMem);
Se***ipboardData(CF_TEXT,hMem);
CloseClipboard();
while(1)
{
if(GetAsyncKeyState(VK_LSHIFT))
{
while (GetAsyncKeyState(!VK_RSHIFT))
{
short i=0;
for(i; i<11; i++)
keybd_event(VK_CONTROL,0x11,0,0);
keybd_event(VkKeyScan('v'),0x56,0,0);
keybd_event(VK_RETURN,0x0D,0,0);
}
}
}
Sleep(120000);
system("pause");
return 0;
}
[/php]
You are wrong when you said VB would have been a better language. What you meant was C# would have been a better language.
Well your halfway there. Now you just need to send the keys to another window....

Experiment with PostMessage(). Google it. I think you prbly need a handle to a window for it.
Quote Originally Posted by why06 View Post
Well your halfway there. Now you just need to send the keys to another window....

Experiment with PostMessage(). Google it. I think you prbly need a handle to a window for it.
I don't think I should need that, because CTRL + V is universal, so regardless of the window i'm in it should push buttons.
Quote Originally Posted by ilovecookies View Post
I don't think I should need that, because CTRL + V is universal, so regardless of the window i'm in it should push buttons.
If you press CTRL + V in your browser, would you also expect it to paste the same copied text in the Word document you have minimized?

It will only post the message in the window that's currently in view... What your trying to do is send virtual key presses to another window.
Quote Originally Posted by why06 View Post
If you press CTRL + V in your browser, would you also expect it to paste the same copied text in the Word document you have minimized?

It will only post the message in the window that's currently in view... What your trying to do is send virtual key presses to another window.
I'm pretty sure he would have what he is copying text to open as the active window.

Oh. And i think i see the problem. But besides that. HD, what do i need to include to use your sendkeys class? Just with the using directives it gives me errors about needing CLR, and i do not know how to turn it on.
Quote Originally Posted by why06 View Post
Well your halfway there. Now you just need to send the keys to another window....

Experiment with PostMessage(). Google it. I think you prbly need a handle to a window for it.
I think CA may have blocked this, I don't know, I don't play CA..

PostMessage also requires you to get the window handle. In this case I'm sure it's the text box. How would you go about finding the window handle?

If I'm wrong, let me know, I wouldn't want to be wasting my time looking something up if it doesn't exist.
Quote Originally Posted by Void View Post
I think CA may have blocked this, I don't know, I don't play CA..

PostMessage also requires you to get the window handle. In this case I'm sure it's the text box. How would you go about finding the window handle?

If I'm wrong, let me know, I wouldn't want to be wasting my time looking something up if it doesn't exist.
It might have... I don't remember.
If not:

How to get handle to any running process by its name - CodeProject

Here is a tutorial on how to get a process's handle from a process name.

And if so there's more thin one way to skin a pig. (sendkeys, Keyboard Hook, etc.)

and lol. zeco why you delete ur post? Now ur speaking gibberish o_O
Bah
Hum
Meow (one second)
Posts 1630 of 43 · Page 2 of 3
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?