Advertisement
sasha2483785

Untitled

Apr 18th, 2023
873
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. #include <conio.h>
  4. #include <tchar.h>
  5. using namespace std;
  6. bool bState{ false };
  7.  
  8. void menu(bool bState)
  9. {
  10.     // Clears and prints to the console
  11.     system("cls");
  12.  
  13.     std::cout << "autobasket\n";
  14.  
  15.     if (bState)
  16.     {
  17.         std::cout << "Status: ON\n";
  18.     }
  19.     else
  20.     {
  21.         std::cout << "Status: OFF\n";
  22.     }
  23. }
  24. double traectory(int x) {
  25.     double distance = x - 334;
  26.     double coef = distance / (1450 - 334);
  27.     return coef;
  28. }
  29. int main()
  30.  
  31. {
  32.    
  33.     menu(bState);
  34.     while (true) {
  35.  
  36.         // Check if 'X' is pressed
  37.         if (GetAsyncKeyState(0x58) & 1)
  38.         {
  39.            
  40.             // Switch bState value
  41.             bState = !bState;
  42.             // Print menu to console
  43.             menu(bState);
  44.         }
  45.         setlocale(LC_CTYPE, "Russian"); //Руссификатор
  46.         POINT cursor;
  47.        
  48.         HWND Handle;
  49.        
  50.        
  51.        
  52.         pair<int, int> ring;
  53.         pair<int, int> ball;
  54.         ball.first = 334;
  55.        
  56.        
  57.         if(bState){
  58.            
  59.             for (int i = 337; i < 1700; i +=2)
  60.             {
  61.                 ring.second = 0;
  62.                 HDC hdc = GetDC(0);
  63.                 GetCursorPos(&cursor);
  64.  
  65.                 Handle = WindowFromPoint(cursor);
  66.  
  67.                 SetCursorPos(i,1000);
  68.                 COLORREF  c = GetPixel(hdc, i, 1000);
  69.  
  70.                 int iRed = GetRValue(c);
  71.                 int iBlue = GetBValue(c);
  72.                 int iGreen = GetGValue(c);
  73.                
  74.                 if ((c == RGB(114, 70, 70))|| (c == RGB(156, 109, 109))) {
  75.                     ring.first = i;
  76.                    
  77.                    
  78.                    
  79.                     for (int j = 1000; j > 40; j -=5)
  80.                     {
  81.                         HDC hdc = GetDC(0);
  82.                         GetCursorPos(&cursor);
  83.  
  84.                         Handle = WindowFromPoint(cursor);
  85.  
  86.                         SetCursorPos(ring.first, j);
  87.                         COLORREF  c = GetPixel(hdc, ring.first, j);
  88.                         if (c == RGB(73, 37, 37)) {
  89.                             ring.second = j;
  90.                             ReleaseDC(Handle, hdc);
  91.                          
  92.                             break;
  93.                         }
  94.  
  95.                     }
  96.                 }
  97.                 if (ring.second != 0)break;
  98.             }
  99.             cout << "coef is " << traectory(ring.first) << endl;
  100.             SetCursorPos(ball.first, ring.second/traectory(ring.first));
  101.                 while (true) {
  102.  
  103.                     HDC hdc = GetDC(0);
  104.                     GetCursorPos(&cursor);
  105.  
  106.                     Handle = WindowFromPoint(cursor);
  107.                     COLORREF  c = GetPixel(hdc, cursor.x, cursor.y);
  108.                     if (c == RGB(255, 168, 61)) {
  109.                         mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
  110.                         mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
  111.                         ReleaseDC(Handle, hdc);
  112.                         break;
  113.                     }
  114.  
  115.             }
  116.            
  117.         }
  118.  
  119.         /* if (c ==RGB(255,255,255) )
  120.          {
  121.              cout << "Ok";
  122.          }
  123.          else
  124.          {
  125.              cout << "Not";
  126.          }
  127.          */
  128.     }
  129.    
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement