Advertisement
vlatkovski

Auto clicker

Oct 30th, 2018
757
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #define WINVER 0x0601
  4. #include <windows.h>
  5. using namespace std;
  6.  
  7.  
  8. const int SCREEN_WIDTH = 1024;
  9. const int SCREEN_HEIGHT = 768;
  10.  
  11. const int START_WAIT = 2000;
  12. const int CLICK_DELAY = 4;
  13.  
  14. int main() {
  15.  
  16.     INPUT input;
  17.     input.type = INPUT_MOUSE;
  18.     input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE|MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP);
  19.     input.mi.mouseData = 0;
  20.     input.mi.dwExtraInfo = NULL;
  21.     input.mi.time = 0;
  22.  
  23.     POINT p;
  24.     string waitstr;
  25.     cout << "To start, enter anything and press enter, and wait " << double(START_WAIT)/1000.0 << " seconds.\n";
  26.     while (1) {
  27.         getline(cin, waitstr);
  28.         Sleep(START_WAIT);
  29.         if (GetCursorPos(&p)) {
  30.             input.mi.dx = p.x * (0xFFFF / SCREEN_WIDTH);
  31.             input.mi.dy = p.y * (0xFFFF / SCREEN_HEIGHT);
  32.         }
  33.         for (int i = 0; i < 2000; ++i) {
  34.             SendInput(1, &input, sizeof(INPUT));
  35.             Sleep(CLICK_DELAY);
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement