Results 1 to 9 of 9
  1. #1
    iwiniwin's Avatar
    Join Date
    Feb 2013
    Gender
    male
    Posts
    187
    Reputation
    10
    Thanks
    849
    My Mood
    Cool

    color aim bot code

    Here is my code the bot is not scanning it builds fine just wont scan

    This is from fleeps how to color aimbot

    just copy paste it to notepad++

     


    #include "ScanContents.h"


    bool TakeScreenshot(std::string WindowToFind, BITMAP &bm, HBITMAP &hbmap, BITMAPINFO &bmi, HDC &hdcShot,
    HBITMAP &hbitmapOld, HWND &hwnd);




    void SetupBitmapInfo(BITMAPINFO &bmi, int bWidth, int bHeight, int bitsPerPixel);
    bool CompareColour(RGBQUAD * pPixels, int height, int width, int x, int y);
    void ScanBMP(ScanContents * scan);
    bool Aim_Bot(HWND appWnd, std::string GameWindow);
    MouseCoord CurrentMouseXY(0, 0);


    int main()
    {
    std::string GameWindow = "rgb - Windows Photo Viewer"; //Counter-Strike Source
    HWND appWnd = FindWindow(0, GameWindow.c_str());


    while(!appWnd)
    {
    system("CLS");
    HWND appWnd = FindWindow(0, GameWindow.c_str());
    std::cout << "Unable to find " << GameWindow.c_str() <<std::endl;
    Sleep(500);
    }


    POINT currentPos;
    GetCursorPos(& currentPos);
    CurrentMouseXY.X = currentPos.x;
    CurrentMouseXY.Y = currentPos.y;


    Aim_Bot(appWnd, GameWindow);
    system("Pause");
    return 0;
    }


    bool TakeScreenshot(std::string WindowToFind, BITMAP &bm, HBITMAP &hbmap, BITMAPINFO &bmi, HDC &hdcShot,
    HBITMAP &hbitmapOld, HWND &hwnd)


    {
    RECT rc;
    GetWindowRect(hwnd, &rc);


    hdcShot = CreateCompatibleDC(0);
    hbmap = CreateCompatibleBitmap(GetDC(0), rc.right - rc.left, rc.bottom - rc.top);
    SelectObject(hdcShot, hbmap);


    BitBlt(hdcShot, 0, 0, rc.right - rc.left, rc.bottom - rc.top,
    GetDC(0),rc.left,rc.top, SRCCOPY);



    if(!GetObject(hbmap, sizeof(BITMAP), (LPSTR)&bm))
    return false;


    int bitsPerPixel = bm.bmBitsPixel;


    if(bitsPerPixel != 32 || bm.bmPlanes != 1)
    return false;


    SetupBitmapInfo(bmi, bm.bmWidth, bm.bmHeight, bitsPerPixel);
    return true;
    }


    bool Aim_Bot(HWND appWnd, std::string GameWindow)
    {
    RECT rcWindow;
    GetWindowRect(appWnd, &rcWindow);
    BITMAP bm;
    HBITMAP hbmap;
    HBITMAP hbmapOld;
    BITMAPINFO bmi;
    HDC hdcShot;
    HDC hdfcScreen;


    RGBQUAD * pPixels;


    int TimeTakenScreenAndScan;
    while(true)
    {
    if(!GetAsyncKeyState('X'))
    {
    TimeTakenScreenAndScan = clock();


    if(TakeScreenshot(GameWindow, bm, hbmap, bmi, hdcShot, hbmapOld, appWnd))
    break;


    HBITMAP hbmapNew = CreateCompatibleBitmap(hdcShot, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top);


    HDC hdcShotNew = CreateCompatibleDC(hdcShot);


    HBITMAP OldBmp = (HBITMAP) SelectObject(hdcShotNew, hbmapNew);


    BitBlt(hdcShotNew, 0, 0, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top,
    hdcShot, 0,0, SRCCOPY);




    pPixels = new RGBQUAD[bm.bmWidth * bm.bmHeight];
    if(!pPixels)return false;


    SelectObject(hdcShotNew, OldBmp);


    if(!GetDIBits(hdcShotNew, hbmapNew, 0, bm.bmHeight, pPixels, &bmi, DIB_RGB_COLORS))
    {
    ReleaseDC(appWnd, hdcShot);
    delete[] pPixels;
    return false;
    }
    ReleaseDC(appWnd, hdcShot);


    ScanContents scanContentsMain(bm,rcWindow, pPixels);


    ScanBMP(&scanContentsMain);




    if(pPixels)
    free(pPixels);
    SelectObject(hdcShot, hbmapOld);
    DeleteObject(hbmap);
    DeleteDC(hdcShot);
    DeleteObject(hbmapNew);
    DeleteObject(OldBmp);
    DeleteDC(hdcShotNew);
    //std::cout << "out of scan, took " << clock() - TimeTakenScreenAndScan << " milliseconds" << std::endl;
    }
    }
    }
    void SetupBitmapInfo(BITMAPINFO &bmi, int bWidth, int bHeight, int bitsPerPixel)
    {
    bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmi.bmiHeader.biWidth = bWidth;
    bmi.bmiHeader.biHeight = bHeight;
    bmi.bmiHeader.biPlanes = 1;
    bmi.bmiHeader.biBitCount = bitsPerPixel;
    bmi.bmiHeader.biCompression = BI_RGB;
    bmi.bmiHeader.biSizeImage = 0;
    }
    void ShootBot(int x, int y)
    {
    mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
    mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
    }


    void ScanBMP(ScanContents * scan)
    {
    for(int y = (scan ->RcWindow.bottom - scan->RcWindow.top)/4;
    y < ((scan->RcWindow.bottom - scan->RcWindow.top) - (scan->RcWindow.bottom - scan->RcWindow.top)/3.5);
    y++)


    {
    for(int x = (scan ->RcWindow.right - scan->RcWindow.left)/4;
    x < ((scan->RcWindow.right - scan->RcWindow.left) - (scan->RcWindow.right - scan->RcWindow.left)/4);
    x++)
    {
    SetCursorPos(x+scan->RcWindow.left, (y+4)+scan->RcWindow.top);




    if(CompareColour(scan-> PPixels, scan->Bm.bmHeight, scan ->Bm.bmWidth, x, y))
    {
    //SetCursorPos(x+scan->RcWindow.left, (y+4)+scan->RcWindow.top);


    POINT currentPos;
    GetCursorPos(&currentPos);


    //ShootBot(x+scan->RcWindow.left, y+scan->RcWindow.top);


    CurrentMouseXY.X = currentPos.x;
    CurrentMouseXY.Y = currentPos.y;
    return;
    }
    }
    }
    }
    bool CompareColour(RGBQUAD * pPixels, int height, int width, int x, int y)
    {


    int p = (height-y-1)*width+x;


    if((int)pPixels[p].rgbRed > 215 && (int)pPixels[p].rgbGreen < 30 && (int)pPixels[p].rgbBlue < 30)
    {
    return true;




    }


    if(GetAsyncKeyState(VK_DELETE))
    {
    exit(0);
    }
    return false;


    }



     

    #include <process.h>
    #include <iostream>
    #include <Windows.h>
    #include <time.h>
    #include <stdlib.h>

    class ScanContents
    {
    public:
    BITMAP Bm;
    RECT RcWindow;
    RGBQUAD * PPixels;

    ScanContents(BITMAP bm, RECT rcWindow, RGBQUAD * pPixels)
    {
    Bm = bm;
    RcWindow = rcWindow;
    PPixels = pPixels;
    }


    };

    class MouseCoord
    {
    public:
    int X;
    int Y;
    MouseCoord (int x int y)

    X = x;
    Y = y;
    }
    Last edited by iwiniwin; 02-22-2013 at 09:15 AM.

  2. #2

  3. #3
    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
    @OP the code formatting is horrible, did you include the [ code ] [ /code ] tags? (no spaces)

    [ spoiler=SomethingUnderThisTab ]
    [ code ]
    ....
    ...
    [ /code]
    [/spoiler]
    '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.

  4. #4
    iwiniwin's Avatar
    Join Date
    Feb 2013
    Gender
    male
    Posts
    187
    Reputation
    10
    Thanks
    849
    My Mood
    Cool
    Code:
    #include "ScanContents.h"
    
    
    bool TakeScreenshot(std::string WindowToFind, BITMAP &bm, HBITMAP &hbmap, BITMAPINFO &bmi, HDC &hdcShot, 
    HBITMAP &hbitmapOld, HWND &hwnd);
    
    
    
    
    void SetupBitmapInfo(BITMAPINFO &bmi, int bWidth, int bHeight, int bitsPerPixel);
    bool CompareColour(RGBQUAD * pPixels, int height, int width, int x, int y);
    void ScanBMP(ScanContents * scan);
    bool Aim_Bot(HWND appWnd, std::string GameWindow);
    MouseCoord CurrentMouseXY(0, 0);
    
    
    int main()
    {
    std::string GameWindow = "rgb - Windows Photo Viewer";	//Counter-Strike Source      
    HWND appWnd = FindWindow(0, GameWindow.c_str());
    
    
    while(!appWnd)
    {
    system("CLS");
    HWND appWnd = FindWindow(0, GameWindow.c_str());
    std::cout << "Unable to find " << GameWindow.c_str() <<std::endl;
    Sleep(500);
    }
    
    
    POINT currentPos;
    GetCursorPos(& currentPos);
    CurrentMouseXY.X = currentPos.x;
    CurrentMouseXY.Y = currentPos.y;
    
    
    Aim_Bot(appWnd, GameWindow);
    system("Pause");
    return 0;
    }
    
    
    bool TakeScreenshot(std::string WindowToFind, BITMAP &bm, HBITMAP &hbmap, BITMAPINFO &bmi, HDC &hdcShot, 
    HBITMAP &hbitmapOld, HWND &hwnd)
    
    
    {
    RECT rc;
    GetWindowRect(hwnd, &rc);
    
    
    hdcShot = CreateCompatibleDC(0);
    hbmap = CreateCompatibleBitmap(GetDC(0), rc.right - rc.left, rc.bottom - rc.top);
    SelectObject(hdcShot, hbmap);
    
    
    BitBlt(hdcShot, 0, 0, rc.right - rc.left, rc.bottom - rc.top, 
    GetDC(0),rc.left,rc.top, SRCCOPY);
    
    
    
    if(!GetObject(hbmap, sizeof(BITMAP), (LPSTR)&bm))
    return false;
    
    
    int bitsPerPixel = bm.bmBitsPixel;
    
    
    if(bitsPerPixel != 32 || bm.bmPlanes != 1)
    return false;
    
    
    SetupBitmapInfo(bmi, bm.bmWidth, bm.bmHeight, bitsPerPixel);
    return true;
    }
    
    
    bool Aim_Bot(HWND appWnd, std::string GameWindow)
    {
    RECT rcWindow;
    GetWindowRect(appWnd, &rcWindow);
    BITMAP bm;
    HBITMAP hbmap;
    HBITMAP hbmapOld;
    BITMAPINFO bmi;
    HDC hdcShot;
    HDC hdfcScreen;
    
    
    RGBQUAD * pPixels;
    
    
    int TimeTakenScreenAndScan;
    while(true)
    {
    if(!GetAsyncKeyState('X'))
    {
      TimeTakenScreenAndScan = clock();
    
    
    if(TakeScreenshot(GameWindow, bm, hbmap, bmi, hdcShot, hbmapOld, appWnd))
    break;
    
    
    HBITMAP hbmapNew = CreateCompatibleBitmap(hdcShot, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top);
    
    
    HDC hdcShotNew = CreateCompatibleDC(hdcShot);
    
    
    HBITMAP OldBmp = (HBITMAP) SelectObject(hdcShotNew, hbmapNew);
    
    
    BitBlt(hdcShotNew, 0, 0, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, 
    hdcShot, 0,0, SRCCOPY);
    
    
    
    
    pPixels = new RGBQUAD[bm.bmWidth * bm.bmHeight];
    if(!pPixels)return false;
    
    
    SelectObject(hdcShotNew, OldBmp);
    
    
    if(!GetDIBits(hdcShotNew, hbmapNew, 0, bm.bmHeight, pPixels, &bmi, DIB_RGB_COLORS))
    {
    ReleaseDC(appWnd, hdcShot);
    delete[] pPixels;
    return false;
    }
    ReleaseDC(appWnd, hdcShot);
    
    
    ScanContents scanContentsMain(bm,rcWindow, pPixels);
    
    
    ScanBMP(&scanContentsMain);
    
    
    
    
    if(pPixels)
    free(pPixels);
    SelectObject(hdcShot, hbmapOld);
    DeleteObject(hbmap);
    DeleteDC(hdcShot);
    DeleteObject(hbmapNew);
    DeleteObject(OldBmp);
    DeleteDC(hdcShotNew);
    //std::cout << "out of scan, took " << clock() - TimeTakenScreenAndScan << " milliseconds" << std::endl;
    }
    }
    }
    void SetupBitmapInfo(BITMAPINFO &bmi, int bWidth, int bHeight, int bitsPerPixel)
    {
    bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmi.bmiHeader.biWidth = bWidth;
    bmi.bmiHeader.biHeight = bHeight;
    bmi.bmiHeader.biPlanes = 1;
    bmi.bmiHeader.biBitCount = bitsPerPixel;
    bmi.bmiHeader.biCompression = BI_RGB;
    bmi.bmiHeader.biSizeImage = 0;
    }
    void ShootBot(int x, int y)
    {
    mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
    mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
    }
    
    
    void ScanBMP(ScanContents * scan)
    {
    for(int y = (scan ->RcWindow.bottom - scan->RcWindow.top)/4;
    y < ((scan->RcWindow.bottom - scan->RcWindow.top) - (scan->RcWindow.bottom - scan->RcWindow.top)/3.5);
    y++)
    
    
    {
    for(int x = (scan ->RcWindow.right - scan->RcWindow.left)/4;
    x < ((scan->RcWindow.right - scan->RcWindow.left) - (scan->RcWindow.right - scan->RcWindow.left)/4);
    x++)
    {
        SetCursorPos(x+scan->RcWindow.left, (y+4)+scan->RcWindow.top);
     
    
     
    
    if(CompareColour(scan-> PPixels, scan->Bm.bmHeight, scan ->Bm.bmWidth, x, y))
    {
    //SetCursorPos(x+scan->RcWindow.left, (y+4)+scan->RcWindow.top);
    
    
    POINT currentPos;
    GetCursorPos(&currentPos);
    
    
     //ShootBot(x+scan->RcWindow.left, y+scan->RcWindow.top);
    
    
    CurrentMouseXY.X = currentPos.x;
    CurrentMouseXY.Y = currentPos.y;
    return;
    }
    }
    }
    }
    bool CompareColour(RGBQUAD * pPixels, int height, int width, int x, int y)
    {
    
    
    int p = (height-y-1)*width+x;
    
    
    if((int)pPixels[p].rgbRed > 215 && (int)pPixels[p].rgbGreen < 30 && (int)pPixels[p].rgbBlue < 30)
    {
    return true;
    
    
    
    
    }
    
    
    if(GetAsyncKeyState(VK_DELETE))
    {
    exit(0);
    }
    return false;
    
    
    }
    I believe my issue is in this scancontents.h file

    Code:
    #include <process.h>
    #include <iostream>
    #include <Windows.h>
    #include <time.h>
    #include <stdlib.h> 
    
    class ScanContents
    {
    public:
    	BITMAP Bm;
    	RECT  RcWindow;
    	RGBQUAD * PPixels;
    
    	ScanContents(BITMAP bm, RECT rcWindow, RGBQUAD * pPixels)
    	{
    		Bm = bm;
           RcWindow = rcWindow;
    	   PPixels = pPixels;
    	}
    
    
    };
    
    class MouseCoord
    {
    public:
    	int X;
    	int Y;
    	MouseCoord (int x  int y)   
           
    		X = x;
    	    Y = y;
    	}

  5. #5
    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
    Code:
    bool TakeScreenshot(std::string WindowToFind, BITMAP &bm, HBITMAP &hbmap, BITMAPINFO &bmi, HDC &hdcShot, 
    HBITMAP &hbitmapOld, HWND &hwnd)
    
    
    {
    RECT rc;
    GetWindowRect(hwnd, &rc);
    
    
    hdcShot = CreateCompatibleDC(0);
    hbmap = CreateCompatibleBitmap(GetDC(0), rc.right - rc.left, rc.bottom - rc.top);
    SelectObject(hdcShot, hbmap); // BP
    Set breakpoints and check the values: what are "hdcShot" | "hwnd" | "rc" | and "appWnd" ??
    (You copy-paste this code from somewhere? Maybe ask the OP : D)

    edit: I'm pretty sure it's the scope of the appWnd variable. Basically you're re-declaring a NEW variable named appWnd inside the { }. It's being set correctly, but once the scope changes, ie the end of the while { }, that copy of appWnd is gone, and the old (un-set) copy is the only one left. Variable Scope?
    But I don't know C++ so well, just a guess.
    Code:
    HWND appWnd = FindWindow(0, GameWindow.c_str());
    
    while(!appWnd)
    {
    system("CLS");
    HWND appWnd = FindWindow(0, GameWindow.c_str()); // BP after* this line <--HWND. Wait, why are you re-declaring !?
    Last edited by abuckau907; 02-25-2013 at 06:32 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.

  6. #6
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    This just goes to show windows api is from the devil

  7. #7
    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
    Not sure what you mean. The issue was that the variable was being declared inside the while { } loop (ie. more private scope) : that variable was being set to the correct Handle, but that variable (and it's value) go out of scope as soon as the while { } is done. He had a variable with the same name declared a few lines above, which is used a few lines below, but it's scope was hidden(and therefore value never set) by the local copy of the variable. aka Scope. And how C++ implements it. I thought?

    @OP Just erase the word 'HWND' from inside the while loop { } (because that's creating a new variable, NOT just setting the value of the one you declared a few lines above. -you want to assign, not declare new + assign)
    Erasing that 1 word should solve your problem. (Unless there are more, I didn't check)
    Last edited by abuckau907; 02-25-2013 at 10:01 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.

  8. #8
    salmonfish's Avatar
    Join Date
    Mar 2013
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0
    There's a missing semicolon at the end of the MouseCoord class in your header file

  9. #9
    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
    OP: Resolved ...? Common etiquette is to update the thread if a solution works. ++ If you actually explain something. (For anyone reading this post with similar issue, in the future..)

    google<<
    et·i·quette
    /ˈetikit/
    Noun
    The customary code of polite behavior in society or among members of a particular profession or group.
    Last edited by abuckau907; 03-05-2013 at 11:11 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] having some trouble with my color aim bot project
    By iwiniwin in forum C++/C Programming
    Replies: 4
    Last Post: 02-23-2013, 06:30 PM
  2. I Need Aim-Bot Codes
    By itsmebadman in forum CrossFire Hack Coding / Programming / Source Code
    Replies: 12
    Last Post: 04-21-2011, 10:16 AM
  3. AIM Bot
    By Dave84311 in forum WarRock - International Hacks
    Replies: 28
    Last Post: 06-12-2006, 10:45 PM
  4. Auto or aim bot
    By aaronm in forum WarRock - International Hacks
    Replies: 4
    Last Post: 01-13-2006, 04:10 PM
  5. aim bots
    By nutter in forum General Game Hacking
    Replies: 6
    Last Post: 12-27-2005, 11:56 AM