Advertisement
roctbb

Clicker

Mar 1st, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <windows.h>
  3.  
  4. bool KeyIsPressed(unsigned char k) {
  5.     USHORT status = GetAsyncKeyState(k);
  6.     return (((status & 0x8000) >> 15) == 1) || ((status & 1) == 1);
  7. }
  8.  
  9. int WINAPI WinMain(HINSTANCE hInst, HINSTANCE P, LPSTR CMD, int nShowCmd) {
  10.  
  11.     HWND target = (HWND)0x0004068E;
  12.     //  pt is for the mouse position, wrect is for the client information. The mouse coords to be sent to the window
  13.     //      must be relative to the top-left corner of the client area, so I have to include that too.
  14.     POINT pt;
  15.     RECT wrect;
  16.  
  17.     while (true) {
  18.         //  ctrl + esc to quit
  19.         if (KeyIsPressed(VK_CONTROL) && KeyIsPressed(VK_ESCAPE)) {
  20.             break;
  21.         }
  22.  
  23.         //  ctrl + left alt to send messages every 5 milliseconds to the target window
  24.         if (KeyIsPressed(VK_CONTROL) && KeyIsPressed(VK_LMENU)) {
  25.             GetCursorPos(&pt);
  26.             GetClientRect(target, &wrect);
  27.             //  Final argument holds the mouse positions
  28.             //PostMessage(target, WM_LBUTTONDOWN, MK_LBUTTON, (pt.x - wrect.left) & ((pt.y - wrect.top) << 16));
  29.             //PostMessage(target, WM_LBUTTONUP, MK_LBUTTON, (pt.x - wrect.left) & ((pt.y - wrect.top) << 16));
  30.             PostMessage(target, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(pt.x - wrect.left, pt.y - wrect.top));
  31.             PostMessage(target, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(pt.x - wrect.left, pt.y - wrect.top));
  32.  
  33.             Sleep(1);
  34.         }
  35.  
  36.     }
  37.  
  38.     return 0;
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement