Advertisement
vlatkovski

Autoclicker 2

Jan 26th, 2020
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 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 = 1360;
  9. const int SCREEN_HEIGHT = 768;
  10.  
  11. const int CLICK_DELAY = 10; // in milliseconds
  12.  
  13. int main() {
  14.  
  15.     INPUT input;
  16.     input.type = INPUT_MOUSE;
  17.     input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE|MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP);
  18.     input.mi.mouseData = 0;
  19.     input.mi.dwExtraInfo = NULL;
  20.     input.mi.time = 0;
  21.  
  22.     POINT p;
  23.     string waitstr;
  24.     cout << "To activate, press DELETE.\n";
  25.  
  26.     bool active = false;
  27.  
  28.     while (true) {
  29.         SHORT keyState = GetAsyncKeyState(VK_DELETE);
  30.         bool isToggled = keyState & 1;
  31.         if (isToggled) {
  32.             active = !active;
  33.         }
  34.         if (active) {
  35.             if (GetCursorPos(&p)) {
  36.                 p.x += 3;
  37.                 p.y += 2;
  38.                 input.mi.dx = p.x * (0xFFFF / SCREEN_WIDTH);
  39.                 input.mi.dy = p.y * (0xFFFF / SCREEN_HEIGHT);
  40.             }
  41.             SendInput(1, &input, sizeof(INPUT));
  42.             Sleep(CLICK_DELAY);
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement