Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #define WINVER 0x0500
- #include<windows.h>
- using namespace std;
- void pressKeyB(int mK)
- {
- /*HKL kbl = GetKeyboardLayout(0);
- INPUT ip;
- ip.type = INPUT_KEYBOARD;
- ip.ki.time = 0;
- ip.ki.dwFlags = KEYEVENTF_UNICODE;
- if ((int)mK<65 && (int)mK>90) //for lowercase
- {
- ip.ki.wScan = 0;
- ip.ki.wVk = VkKeyScanEx( mK, kbl );
- }
- else //for uppercase
- {
- ip.ki.wScan = mK;
- ip.ki.wVk = 0;
- }
- ip.ki.dwExtraInfo = 0;
- SendInput(1, &ip, sizeof(INPUT));*/
- //Structure for the keyboard event
- INPUT ip;
- //Set up the INPUT structure
- ip.type = INPUT_KEYBOARD;
- ip.ki.time = 0;
- ip.ki.wVk = 0; //We're doing scan codes instead
- ip.ki.dwExtraInfo = 0;
- //This let you do a hardware scan instead of a virtual keypress
- ip.ki.dwFlags = KEYEVENTF_SCANCODE;
- ip.ki.wScan = mK; //Set a unicode character to use (A)
- //Send the press
- SendInput(1, &ip, sizeof(INPUT));
- //Prepare a keyup event
- ip.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
- SendInput(1, &ip, sizeof(INPUT));
- }
- void checkButton(HDC& hdc, int but, int x, int y, int i, int& col, int r_p, int g_p, int b_p) {
- int r, g, b;
- COLORREF color;
- color = GetPixel(hdc, x, y);
- r = GetRValue(color);
- g = GetGValue(color);
- b = GetBValue(color);
- //cout << p.x << " " << p.y << endl;
- cout << x << " " << y << " " << endl;
- if ((r != r_p or g != g_p or b != b_p) and (i - col >= 3)) {
- pressKeyB(but);
- col = i;
- }
- cout << r << " " << g << " " << b << endl;
- }
- void findColor() {
- int i = 0, r, g, b;
- int A = 0x1e, S = 0x1f, D = 0x20, F = 0x21, G = 0x22, H = 0x23;
- //HWND hwnd;
- HDC hdc;
- //hwnd = GetDesktopWindow();
- //RECT rect;
- //GetWindowRect(hwnd,&rect);
- //if ( hwnd == NULL ) exit(3);
- hdc = GetDC(NULL);
- int x = 650, y = 860;
- int a = -9, s = -9, d = -9, f = -9, gh = -9, h = -9;
- while(1) {
- i++;
- POINT p;
- //GetCursorPos(&p);
- //color = GetPixel(hdc, p.x, p.y);
- checkButton(hdc, A, 500, y, i, a, 141, 186, 181);
- checkButton(hdc, S, 650, y, i, s, 2, 25, 32);
- checkButton(hdc, D, 850, y, i, d, 1, 91, 60);
- checkButton(hdc, F, 1020, y, i, f, 2, 119, 76);
- checkButton(hdc, G, 1200, y, i, gh, 0, 56, 45);
- checkButton(hdc, H, 1380, y, i, h, 5, 23, 36);
- //cout << i << endl;
- }
- ReleaseDC(NULL, hdc);
- }
- int main() {
- cout << 1 << endl;
- int A = 0x1e, S = 0x1f, D = 0x20, F = 0x21, G = 0x22, H = 0x23;
- Sleep(1000);
- findColor();
- for(int i = 0; i < 1000; ++i) {
- Sleep((i * 430 + 555) % 1110);
- pressKeyB(G);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement