Advertisement
CasualGamer

T - Rex Bot 1

Jan 19th, 2020
3,138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.75 KB | None | 0 0
  1. #include <windows.h>
  2. #include <thread>
  3. #include <chrono>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. int get_Bitmap(int x, int y, HDC& hdcMemory, int width = 700, int height = 200) {
  9.     HDC hdcSource = GetDC(NULL);
  10.     hdcMemory = CreateCompatibleDC(hdcSource);
  11.     HBITMAP hBitmap = CreateCompatibleBitmap(hdcSource, width, height);
  12.     HBITMAP hBitmapOld = (HBITMAP)SelectObject(hdcMemory, hBitmap);
  13.     if (!BitBlt(hdcMemory, 0, 0, width, height, hdcSource, x, y, CAPTUREBLT | SRCCOPY)) {
  14.         cout << "BitBlt failed!" << endl;
  15.     }
  16.  
  17.     //clean up
  18.     DeleteObject(hBitmapOld);
  19.     DeleteObject(hBitmap);
  20.     ReleaseDC(NULL, hdcSource);
  21.  
  22.     return 0;
  23. }
  24.  
  25. POINT get_tail(HDC& dc, POINT origin,int startx = 0, int starty = 0, int width = 700, int height = 200) {
  26.     POINT p = { startx, starty };
  27.     for (int i = startx; i < startx + width; i++) {//x
  28.         for (int j = starty; j < starty + height; j++) {//y
  29.             COLORREF color = GetPixel(dc, i, j);
  30.             SetCursorPos(origin.x + i, origin.y + j);
  31.             if (color == 5460819) {
  32.                 p = { i, j };
  33.                 return p;
  34.             }
  35.         }
  36.     }
  37.     return p;
  38. }
  39.  
  40. int main() {
  41.     HDC hdcMemory = NULL;
  42.     POINT origin = {}, tail = {};//tail relative to origin
  43.     int width = 350;
  44.     int height = 200;
  45.     int i=0, j=0,downtime = 320;
  46.     COLORREF threat_color = 5460819;
  47.     COLORREF color = NULL;
  48.  
  49.     cout << "[N1] Get Map" << endl;
  50.     cout << "[N2] Get Tail" << endl;
  51.     cout << "[N3] Start Bot" << endl;
  52.     cout << "[N4] Pixel Info" << endl;
  53.     cout << "[N0] Stop | Exit" << endl;
  54.  
  55.     while (true) {
  56.         std::this_thread::sleep_for(std::chrono::milliseconds(500));
  57.         if (GetAsyncKeyState(VK_NUMPAD0)) { // Exit
  58.             if (hdcMemory != NULL)
  59.                 DeleteDC(hdcMemory);
  60.             return 0;
  61.         }
  62.         if (GetAsyncKeyState(VK_NUMPAD1)) { // get map
  63.             GetCursorPos(&origin);
  64.             get_Bitmap(origin.x, origin.y, hdcMemory, width, height);
  65.             cout << "We got the map!" << endl;
  66.         }
  67.         if (GetAsyncKeyState(VK_NUMPAD2)) { // get tail
  68.             POINT p;
  69.             GetCursorPos(&p);
  70.             tail = get_tail(hdcMemory, origin,p.x-origin.x,p.y-origin.y,30,30);
  71.             cout << "Oh f*ck it's a t-rex!" << endl;
  72.         }
  73.         if (GetAsyncKeyState(VK_NUMPAD4)) { // get pixel color
  74.             POINT p;
  75.             GetCursorPos(&p);
  76.             if (hdcMemory != NULL) { // variable where hdc is stored
  77.                 COLORREF color = GetPixel(hdcMemory, p.x - origin.x, p.y - origin.y);
  78.                 cout << "Absolute values" << endl;
  79.                 cout << "X: " << p.x << " Y: " << p.y << " Color: " << color << endl;
  80.             }
  81.             else
  82.                 cout << "Get map first!" << endl;
  83.         }
  84.     }
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement