Zuckerjunkie

Simple Clicker

Sep 4th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <windows.h>
  2.  
  3. /*
  4.     Code grabbed from http://www.cplusplus.com/forum/lounge/17053/
  5.     I altered it to make it work with the middle click as it's a convinient key
  6. */
  7.  
  8. bool KeyIsPressed (unsigned char k)
  9. {
  10.     USHORT status = GetAsyncKeyState(k);
  11.     return (((status & 0x8000) >> 15) == 1) || ((status & 1) == 1);
  12. }
  13.  
  14. int WINAPI WinMain (HINSTANCE hInst, HINSTANCE P, LPSTR CMD, int nShowCmd)
  15. {
  16.     char k = 0x45;  // 0x45 = E, 0x50 = P; WM_RBUTTONDOWN = Middle click
  17.  
  18.     while (true) {
  19.         INPUT Input= {0}; // Create our input.
  20.         Input.type = INPUT_MOUSE;
  21.  
  22.         while ( !KeyIsPressed (k) ) { Sleep (100); }
  23.         while ( KeyIsPressed (k) ) {}
  24.         while ( !KeyIsPressed (k) ) {
  25.             // Let input know we are using the mouse.
  26.             Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;  // We are setting left mouse button down.
  27.             SendInput( 1, &Input, sizeof(INPUT) );    // Send the input.
  28.  
  29.             ZeroMemory( &Input, sizeof(INPUT) );      // Fills a block of memory with zeros.
  30.             Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;    // We are setting left mouse button up.
  31.             SendInput( 1, &Input, sizeof(INPUT) );    // Send the input.
  32.  
  33.             Sleep (10);
  34.         }
  35.         while ( KeyIsPressed (k) ) {}
  36.     }
  37.     return 0;
  38. }
Add Comment
Please, Sign In to add comment