Looking to start my first C++ Project

Posts 31–43 of 43 · Page 3 of 3
Quote Originally Posted by why06 View Post
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
Because I can't be bothered. Though technically I suppose I did get it to work.
That's not what I meant Why06, but thank you.

I meant like. . .

Whenever making a program using Windows API and you make a text box you'd normally do something like..

[php]
HWND textbox;
textbox = CreateWindow("edit","",WS_VISIBLE | WS_CHILD | WS_BORDER,x,y,sizex,sizey,ParentWindow,(HMENU)1,NU LL,NULL);
[/php]

If I wanted to send a message like, WM_CHAR to that text box, normally I would need the window handle, which in this case is 'textbox'.

How would you find the window handle without access to the source?

Sorry for extreme off topicness.

I'm probably completely wrong about all of that. ^^
Well.. David that's really specific.... I don't imagine you would need to find the text box since when you press enter the cursor is moved to the textbox automatically.... :l

Also since it is a DirectX game it most likely doesn't use the standard Windows text box, but some version of DirectX's implementation of it.
Quote Originally Posted by why06 View Post
Well.. David that's really specific.... I don't imagine you would need to find the text box since when you press enter the cursor is moved to the textbox automatically.... :l

Also since it is a DirectX game it most likely doesn't use the standard Windows text box, but some version of DirectX's implementation of it.
I was talking about using PostMessage. Having the window(or textbox) active doesn't change when you're using PostMessage.
Quote Originally Posted by Void View Post
I was talking about using PostMessage. Having the window(or textbox) active doesn't change when you're using PostMessage.
I'm confused. I thought you were talking about finding the handle to the text box. In which case I was saying since in a game there is now Windows textbox you could not find the handle for it. Rather it has its on graphics for a textbox and that text box has no handle. Only the Game process has a handle, even though it might have seperate threads, So you would only need the handle for that Process. When you sent the enter key the textbox would be opened up to type in (atleast in CA). I know your on about something, maybe I'm just not getting it...
Quote Originally Posted by zeco View Post
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.
create a new .net console project and use sendkeys::sendwait.
or create a new C# project and use SendKeys.SendWait
Well it's done enough for me. I'll probably go onto make it better, but till then it'll remain my own personal spammer, but for those here in the C++ section, you get dibs on the source code. (Oh boy!) But in all honesty, it's crap tastic. It does however perform my basic task. Which would be to spam the same thing 7 times every 30 seconds (Had to make the spam low or the time high to prevent chat ban, so I went with the middle.)

In order to use, double click the executable. A window will pop up prompting you for the message you wish to spam, simply type anything you want in, and hit enter. Then, go into combat arms, or yahoo messenger, or Live Messenger, wherever you want to spam, and press the left shift key. This will start the spamming loop. And the spam loop will continue until you press the Right Shift key. AND! It can be activated/deactivated anytime you want.

NOTE: IF you intend to spam in combat arms with this, make sure you activate it IN GAME, because it is NOT chat ban protected, as in, you can spam all you want in game, but if you try to spam in the channel, you'll get chat banned. This is where the On/Off feature is handy, turn on the spam in game, and off in the lobby.

NOTE: MAKE SURE YOU TURN IT OFF IF YOU DON'T WANT SPAM, it DOES NOT distinguish between windows, and will spam anywhere the cursor is.

NOTE: All suggestions welcome.


[php]////////////////////////////////////
// Big thanks to everyone //
// in the MPGH C++ section //
// who helped me write my //
// First actual program. //
// Should you use my spammer //
// source, for whatever you //
// see fit, please give credit //
// Where due. //
// I would like to //
// Extend a special thanks //
// to Davidm44 for the massive //
// Amount of help he gave me //
//Regarding the keybd_event //
// functions and the clipboard //
// API. //
//Credits: iLoveCookies, Davidm44,//
// Why06, and Hell_Demon //
///////////////////////////////////
#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<7; i++)
{
keybd_event(VK_RETURN,0x0D,0,0);
keybd_event(VK_RETURN,0x0d,KEYEVENTF_KEYUP,0);
Sleep(100);
keybd_event(VK_RCONTROL,0x11,0,0);
keybd_event(VkKeyScan('v'),0x56,0,0);
Sleep(100);
keybd_event(VK_RETURN,0x0D,0,0);
Sleep(100);
keybd_event(VK_RCONTROL,0x11,KEYEVENTF_KEYUP,0);
keybd_event(VkKeyScan('v'),0x56,KEYEVENTF_KEYUP,0) ;
Sleep(100);
keybd_event(VK_RETURN,0x0D,KEYEVENTF_KEYUP,0);

}
Sleep(30000);
}

}

}
EmptyClipboard();
system("pause");
return 0;
}

[/php]


EDIT! I lied. <_< I'm gonna post it in the CA section, since I posted it on my VIP forum, and someone over there is leeching stuff to the CA section here.
Well. It's about time... xD

Jk. I will try it out. Good work cookies. I think I learned just as much as you from your lil project
Code:
char *pPwnage()
{
    if(cookies.app.length<helldemons.app.length) return "the noob didnt use .net o_O";
    else return "the noob pwns meh :(";
}
replace noob with <3333
Well I tried to Update it a little bit, make it a little bit neater so that I could add more features later on and it look cleaner. BUT I ran into a problem, no compiler or linker errors, but it doesn't spam any more. It runs basically the same way it did before, just made the spam loop it's own function, and still used the the same method to turn it on/off.

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

char pMessage[100];


void SpamLoop(void)
{
while(1)
{
short i=0;
for(i; i<7; i++)
{
keybd_event(VK_RETURN,0x0D,0,0);
keybd_event(VK_RETURN,0x0d,KEYEVENTF_KEYUP,0);
Sleep(100);
keybd_event(VK_RCONTROL,0x11,0,0);
keybd_event(VkKeyScan('v'),0x56,0,0);
Sleep(100);
keybd_event(VK_RETURN,0x0D,0,0);
Sleep(100);
keybd_event(VK_RCONTROL,0x11,KEYEVENTF_KEYUP,0);
keybd_event(VkKeyScan('v'),0x56,KEYEVENTF_KEYUP,0) ;
Sleep(100);
keybd_event(VK_RETURN,0x0D,KEYEVENTF_KEYUP,0);

}
Sleep(30000);
}
}


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();
if(GetAsyncKeyState(VK_LSHIFT))
{
while (!GetAsyncKeyState(VK_RSHIFT))
{
SpamLoop();
}
}
EmptyClipboard();
system("pause");
return 0;
}

[/php]
The hot key part of the code must be in an infinite loop otherwise it does a single check, which is almost instantly. Then it goes on to emptying the clipboard. Also, if somehow, you do manage to get the hot key before moving on to emptying the clipboard, it's going to keep spitting those keyboard events at you, it's in an infinite loop, it won't ever stop.

I believe when analyzing code for logical errors, you have to consider the order of the functions and statements.
Yeah agreed infinite loops are a must for proper hotkeys
proof of concept example:
bool x = true
while(x = true){
spank a vbfag;
}
yeah basically this is it
of course u have to remember to issue a condition to toggle the loop or ur comp may meltdown unless u wanna see vbfags getting spanked lol
well there are other ways todo it but this is just a general idea
to break out of a while/for/whatever loop:
Code:
for(int x=0;x<100;x++)
{
    for(int y=0;y<100;y++)
    {
        if(y==50) break; //break out of loop y
    }
}
if you're in a for loop and want to skip that one, but continue forward:
Code:
for(int x=0;x<100;x++)
{
    if(x == 5) continue; //skip
so if(GetAsyncKeyState(VK_NUMPAD0)&1) break; would make you break out of the while loop when you press numpad 0
Posts 31–43 of 43 · Page 3 of 3
This thread is closed for replies.

Similar Threads

Talk with us