Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.76 KB | None | 0 0
  1. #include<iostream>
  2. #define WINVER 0x0500
  3. #include<windows.h>
  4.  
  5. using namespace std;
  6.  
  7. void pressKeyB(int mK)
  8. {
  9.     /*HKL kbl = GetKeyboardLayout(0);
  10.     INPUT ip;
  11.     ip.type = INPUT_KEYBOARD;
  12.     ip.ki.time = 0;
  13.     ip.ki.dwFlags = KEYEVENTF_UNICODE;
  14.     if ((int)mK<65 && (int)mK>90) //for lowercase
  15.     {
  16.         ip.ki.wScan = 0;
  17.         ip.ki.wVk = VkKeyScanEx( mK, kbl );
  18.     }
  19.     else //for uppercase
  20.     {
  21.         ip.ki.wScan = mK;
  22.         ip.ki.wVk = 0;
  23.  
  24.     }
  25.     ip.ki.dwExtraInfo = 0;
  26.     SendInput(1, &ip, sizeof(INPUT));*/
  27.     //Structure for the keyboard event
  28.     INPUT ip;
  29.  
  30.     //Set up the INPUT structure
  31.     ip.type = INPUT_KEYBOARD;
  32.     ip.ki.time = 0;
  33.     ip.ki.wVk = 0; //We're doing scan codes instead
  34.     ip.ki.dwExtraInfo = 0;
  35.  
  36.     //This let you do a hardware scan instead of a virtual keypress
  37.     ip.ki.dwFlags = KEYEVENTF_SCANCODE;
  38.     ip.ki.wScan = mK;  //Set a unicode character to use (A)
  39.  
  40.     //Send the press
  41.     SendInput(1, &ip, sizeof(INPUT));
  42.  
  43.     //Prepare a keyup event
  44.     ip.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
  45.     SendInput(1, &ip, sizeof(INPUT));
  46. }
  47.  
  48. void checkButton(HDC& hdc, int but, int x, int y, int i, int& col, int r_p, int g_p, int b_p) {
  49.     int r, g, b;
  50.     COLORREF color;
  51.     color = GetPixel(hdc, x, y);
  52.     r = GetRValue(color);
  53.     g = GetGValue(color);
  54.     b = GetBValue(color);
  55.     //cout << p.x << " " << p.y << endl;
  56.     cout << x << " " << y << " " << endl;
  57.     if ((r != r_p or g != g_p or b != b_p) and (i - col >= 3)) {
  58.         pressKeyB(but);
  59.         col = i;
  60.     }
  61.     cout << r << " " << g << " " << b << endl;
  62. }
  63.  
  64. void findColor() {
  65.     int i = 0, r, g, b;
  66.     int A = 0x1e, S = 0x1f, D = 0x20, F = 0x21, G = 0x22, H = 0x23;
  67.     //HWND hwnd;
  68.     HDC hdc;
  69.     //hwnd = GetDesktopWindow();
  70.     //RECT rect;
  71.     //GetWindowRect(hwnd,&rect);
  72.     //if ( hwnd == NULL ) exit(3);
  73.     hdc = GetDC(NULL);
  74.     int x = 650, y = 860;
  75.     int a = -9, s = -9, d = -9, f = -9, gh = -9, h = -9;
  76.     while(1) {
  77.         i++;
  78.         POINT p;
  79.         //GetCursorPos(&p);
  80.         //color = GetPixel(hdc, p.x, p.y);
  81.         checkButton(hdc, A, 500, y, i, a, 141, 186, 181);
  82.         checkButton(hdc, S, 650, y, i, s, 2, 25, 32);
  83.         checkButton(hdc, D, 850, y, i, d, 1, 91, 60);
  84.         checkButton(hdc, F, 1020, y, i, f, 2, 119, 76);
  85.         checkButton(hdc, G, 1200, y, i, gh, 0, 56, 45);
  86.         checkButton(hdc, H, 1380, y, i, h, 5, 23, 36);
  87.         //cout << i << endl;
  88.     }
  89.     ReleaseDC(NULL, hdc);
  90. }
  91. int main() {
  92.     cout << 1 << endl;
  93.     int A = 0x1e, S = 0x1f, D = 0x20, F = 0x21, G = 0x22, H = 0x23;
  94.     Sleep(1000);
  95.     findColor();
  96.     for(int i = 0; i < 1000; ++i) {
  97.         Sleep((i * 430 + 555) % 1110);
  98.         pressKeyB(G);
  99.     }
  100.     return 0;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement