Results 1 to 4 of 4
  1. #1
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,221
    Thanks
    211
    Thanked 2,224 Times in 289 Posts
    Rep Power
    10

    [C++] How to make a simple bot

    In this tutorial I will explain to you how to program a bot. I will not post enough of the source code for you to make a copy pasta bot.

    First, you will need to include the windows.h header file.
     #include <windows.h> //This is what we need for the SendInput functions
    int main()
    {
    return 0;
    }

    The first function we can use to simulate keystrokes or mouse functions is SendInput().
    SendInput - Synthesizes keystrokes, mouse motions, and button clicks.
    The SendInput function requires the use of the INPUT object.
    INPUT - Used by SendInput to store information for synthesizing input events such as keystrokes, mouse movement, and mouse clicks.
    . So let us declare an INPUT object and have it setup for a mouse click.
     INPUT Input;
    Input.type = INPUT_MOUSE;
    Input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
    Input.mi.dx = X * (65535.0f / (GetSystemMetrics(SM_CXSCREEN) -1));
    Input.mi.dy = Y * (65535.0f / (GetSystemMetrics(SM_CYSCREEN) -1));

    If you just put this code in and compile + debug it, nothing will happen because we did not pass this through SendInput yet. Before I explain how to use SendInput, I will explain what this code above means. Since we set the input type to INPUT_MOUSE, we fill in Input.mi.dwFlags with what we want the mouse to do. In this case, we want to move the mouse. That is why we used MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE.
    MOUSEEVENTF_ABSOLUTE - Contains information about a simulated mouse event.
    Next we filled in the X and Y position of where we want the mouse to land.

    Now we can move on to SendInput.
     SendInput(true, &Input, sizeof(Input)); 

    After this piece of code, you will notice the mouse does move. You should know where this goes.

    Try to make the mouse click now. You should used MOUSEEVENTF_LEFTDOWN and MOUSEEVENTF_LEFTUP. You also need to call SendInput twice.
     INPUT Input;
    Input.type = INPUT_MOUSE;
    Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN; //Clicks the mouse down.
    SendInput(true, &Input, sizeof(Input));
    Input.mi.dwFlags = MOUSEEVENTF_LEFTUP; //Releases the mouse clock.
    SendInput(true, &Input, sizeof(Input));


    Here is a keystroke example with the keyboard input.
     INPUT Input;
    Input.type = INPUT_KEYBOARD;
    Input.ki.dwFlags = /* Figure it out yourself */
    Input.ki.wVk = Virtual Key Codes;

    Virtual Key Codes Table
    The hint here is that it is very similar to a mouse click but, you use this KEYEVENTF_EXTENDEDKEY and KEYEVENTF_KEYUP.
     Input.ki.wvK = 'A';
    Input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
    SendInput(true, &Input, sizeof(Input));
    Input.ki.dwFlags = KEYEVENTF_KEYUP;
    SendInput(true, &Input, sizeof(Input));

    Now you need to turn it on and off. The smart way to do this is create a thread and have it watch for the hotkeys and then create another thread to simulate those keystrokes. For this we need the CreateThread function.
     int main()
    {
    DWORD dwHandleHotKeys;
    CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)HandleHotKeys, NULL, NULL, &dwHandleHotKeys);
    //On Exit
    ExitThread(dwHandleHotKeys);
    }

    void HandleHotKeys()
    {
    //Create a loop to look for hotkeys.
    }

    Before I close off this tutorial, I should tell you that this is probably blocked by MANY anti-hacking applications. And for use the Sleep() function for delays between keystrokes.
    Author: ?(^_^?)(?^_^)?
    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

  2. #2
    sh1ft
    sh1ft is offline
    New member sh1ft's Avatar
    Join Date
    2011 Dec
    Location
    Asia
    Posts
    17
    Thanks
    9
    Thanked 10 Times in 4 Posts
    Rep Power
    0
    Even the simple code kinda confuse me lol.
    Btw Dwar..should i start learn from c language or assembly first

  3. #3
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,221
    Thanks
    211
    Thanked 2,224 Times in 289 Posts
    Rep Power
    10
    Quote Originally Posted by sh1ft View Post
    should i start learn from c language or assembly first
    It's depended on your aim... if you have free time, if you already know what programming is, you can try ASM. No matter what you choose, just learn and improve your skills
    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

  4. The Following User Says Thank You to Dwar For This Useful Post:


  5. #4
    kerapu
    kerapu is offline
    Guest
    Join Date
    2014 Oct
    Location
    malaysia
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    thanks

    can you make some video tutorial

Visitors found this page by searching for:

bot programming tutorial

c bot tutorial

c bot programming

how to make a bot in Cc game bot programmingc how to make a simple botbotnet programming tutorialsendinput MOUSEEVENTF_LEFTDOWNc how to make a bothow to make a c botc botbot programmieren tutorialhow to create a bot in chow to make a bot with c how to make a bot c sendinput c tutorialhow to make bot c sendinput bot c game bothow to make a game bot c c simple botsendinput example c how to make bot using c how to make bot in c game bot programming tutorial

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •