Results 1 to 4 of 4
  1. #1
    Epuron's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Location
    Toronto, ON
    Posts
    66
    Reputation
    10
    Thanks
    22
    My Mood
    Breezy

    Help me with Spammer

    Hey guys, Thanks for visiting here. I need help with my c++ chat spammer coded in Dev c++. I had just started today with coding and i need help with it. Everything seems to work but the keystrokes. The keystrokes only work on Notepad and Microsoft Word and Wordpad. It does not work on Browsers like IE or Chrome. I also tried doing it on adult chats or chatrooms on the Browser and the keystrokes do not enter in the chat.

    #include <iostream> #include <stdio.h> #include <Windows.h> #include "winuser - Pastebin.com

    Here is the source code. Hopefully someone will help me

    Also, this is my first project so please give me feedback on how i did on this project and tell me what parts i should improve on.

    Thanks

  2. #2
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    Just a guess, but keybd_event usually happens in pairs - keydown and keyup. You only have keydown?
    Code:
             for(int z=0;z<y;z++)
             {
                             SendMessage(edit, EM_REPLACESEL, (WPARAM)TRUE, (LPARAM)text.c_str());
                             Sleep(5);
                             keybd_event(VK_RETURN,0x0D, 0, 0); 
             }
    try
    Code:
      for(int z=0;z<y;z++)
             {
                             SendMessage(edit, EM_REPLACESEL, (WPARAM)TRUE, (LPARAM)text.c_str());
                             Sleep(5);
                             keybd_event(VK_RETURN,0x0D, 0, 0); // key_down
                             keybd_event(VK_RETURN,0x0D, 1, 0); //key_up. There is a constant defined somewhere.
             }
     

    1) Name your variables; x,y is not very informative. I had to analyze the loop for a moment longer than normal. Not a big deal, but not ideal either.
    bool spamBot(string text, int x, int y)
    {
    HWND spamWindow = GetForegroundWindow(); //problem starts here, only keystrokes notepad help!
    if(spamWindow == NULL)
    return FALSE;
    //Handle of notepad control
    HWND edit = FindWindowEx( spamWindow, NULL, _T( "Edit" ), NULL );
    if(edit == NULL)
    return FALSE;
    for(int z=0;z<y;z++)
    {
    .....


    2) You did "using namespace std;"
    but still prefix things with the namespace : p Not sure if that's good/bad/either.
    int main()
    {
    std::string text;
    std::cout << "Insert Desired Text: " << endl;
    getline(cin, text);
    3) Use if / elseif (instead of 2 sepearate if statements; they're obviously connected)
    if (start == "y")
    {
    cout << "5" << endl;
    Sleep(1000);
    cout << "4" << endl;
    Sleep(1000);
    cout << "3" << endl;
    Sleep(1000);
    cout << "2" << endl;
    Sleep(1000);
    cout << "1" << endl;
    Sleep(1000);
    spamBot(text, intervels, numOfTimes);
    }
    if (start == "n")
    {
    return 0;
    }
    So if the user input 'y', then obviously the 2nd if statement's body won't execute -- but it still checks the condition. It's only a couple (?) clock cycles, so not really a big deal, but it's a very easy fix, and it's common to the language, so why not.
    If you use else if ( )

    then once a branch of the IF has been executed, it won't check the rest of the branches.
    Code:
    if (start == 'y')
    {
    ...
    }
    else if (start == 'n')
    {
    ...
    }
    else
    {
    //invalid input
    }
    So if the user types in 'y', it will execute it's body and then leave the entire IF statement, and not check any other cases. (You only had one other case, so again, not a big deal).


    4) This will probably never occur?
    You're calling main() and restart() recursively (?)

    void restart()
    {
    cout << endl;
    cout << endl;
    main();
    willRestart = "null";
    text = "null";
    intervels = 0;
    numOfTimes = 0;
    start = "null";
    }
    So, before 'restart()' can return, it has to call main --> and technically main could call 'restart()' again, and so on, forever. Eventually you'd run out of stack space (ram).

    I guess it's fine, as all recursive functions do that. But if there is ever a situation where a user (or users..) continuously choose to restart, eventually it will crash. Just saying : p It's not likely, but if you could re-structure the code, you might try to do so.

    -optional
    Code:
    if (start == "y")
    {
             cout << "5" << endl;
             Sleep(1000);
             cout << "4" << endl;
             Sleep(1000);
             cout << "3" << endl;
             Sleep(1000);
             cout << "2" << endl;
             Sleep(1000);
             cout << "1" << endl;
             Sleep(1000);
                     spamBot(text, intervels, numOfTimes);
    }
    could become
    Code:
    if (start == 'y')
    {
        for (int i = 5; i > 0; --i)
        {
        cout << i << endl;
        Sleep(1000);
        }
     spamBot(text, intervels, numOfTimes);
    }
    5 lines, counting the braces on their own line vs. 10. Is maybe more clear the way you have it now.
    Last edited by abuckau907; 11-01-2013 at 11:12 PM.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  3. The Following User Says Thank You to abuckau907 For This Useful Post:

    Epuron (11-02-2013)

  4. #3
    Epuron's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Location
    Toronto, ON
    Posts
    66
    Reputation
    10
    Thanks
    22
    My Mood
    Breezy
    Ok ill try and ill message you back if it works

    EDIT: Well it didn't work but thanks tho. But if you could help me with this again, i would like to say that this works on Notepad only but doesn't work anywhere else for some reason :/
    Last edited by Epuron; 11-02-2013 at 01:14 PM.

  5. #4
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    Quote Originally Posted by Epuron View Post
    .
    Your code example specifically targets Notepad by looking for a window titled "Edit"
    ..I assume you change that part when you try it with another program/game? Please post the code you use when targeting another application.

    HWND spamWindow = GetForegroundWindow(); //problem starts here, only keystrokes notepad help!
    if(spamWindow == NULL)
    return FALSE;
    //Handle of notepad control
    HWND edit = FindWindowEx( spamWindow, NULL, _T( "Edit" ), NULL );
    if(edit == NULL)
    return FALSE;
    ^^I think you should just use FindWindow(NULL,"caption here") to get the window's handle. Not sure why you're using GetForegroundWindow(); ??

    I think the problem is you're calling SendMessage() with the wrong hWnd. ?


    Change your code to display debugging errors like "Window not found", or "Unable to obtain handle for window titled *******", instead of just returning false. So you know what's actually happening other than "it doesn't work".
    Last edited by abuckau907; 11-02-2013 at 01:39 PM.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

Similar Threads

  1. [Help Request] Help me with VIP question? pweasee
    By koreankid919 in forum CrossFire Help
    Replies: 5
    Last Post: 06-24-2011, 02:57 PM
  2. [Help Request] Someone help me with the hacks.
    By mark15 in forum Combat Arms Help
    Replies: 18
    Last Post: 06-15-2011, 03:04 AM
  3. [Help Request] Help me with : 192.168.0.1
    By Acosiluiqie in forum Minecraft Help
    Replies: 6
    Last Post: 06-02-2011, 06:47 PM
  4. [HELP] Me With My Spammer[/solved]
    By dylan40 in forum Visual Basic Programming
    Replies: 7
    Last Post: 04-19-2010, 10:12 AM
  5. Help with Spammer in Vb 08
    By Jakerzdog in forum Combat Arms Help
    Replies: 2
    Last Post: 10-23-2009, 05:48 AM