Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. /*
  2.  *  main.cpp
  3.  *  bot
  4.  *
  5.  *  Created by Geoffrey on 28/10/10.
  6.  *  Copyright 2010 __MyCompanyName__. All rights reserved.
  7.  *
  8.  */
  9. #include <iostream>  // I/O
  10. #include "main.h"
  11. #include <windows.h> //This is what we need for the SendInput functions
  12. int main()
  13. {
  14.     DWORD dwHandleHotKeys;
  15.     CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)HandleHotKeys, NULL, NULL, &dwHandleHotKeys);
  16.     //On Exit
  17.     ExitThread(dwHandleHotKeys);
  18.    
  19.    
  20.     INPUT Input;
  21.     Input.type = INPUT_MOUSE;
  22.     Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;     //Clicks the mouse down.
  23.     SendInput(true, &Input, sizeof(Input));
  24.     Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;       //Releases the mouse clock.
  25.     SendInput(true, &Input, sizeof(Input));
  26.    
  27.  
  28.     return 0;
  29. }
  30. void forward(seconds)
  31. {
  32.     INPUT Input;
  33.     Input.type = INPUT_KEYBOARD;
  34.     Input.ki.wvK = 'W';
  35.     Input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
  36.     SendInput(true, &Input, sizeof(Input));
  37.     sleep(seconds);
  38.     Input.ki.dwFlags = KEYEVENTF_KEYUP;
  39.     SendInput(true, &Input, sizeof(Input));
  40. }
  41. void HandleHotKeys()
  42. {
  43.     for(;;)
  44.     {
  45.         cin >> mystring;
  46.         if (mystring == "forward") {
  47.             INPUT Input;
  48.             Input.type = INPUT_MOUSE;
  49.             Input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
  50.             Input.mi.dx = GetSystemMetrics(SM_CXSCREEN) / 2;
  51.             Input.mi.dy = GetSystemMetrics(SM_CYSCREEN) / 2;
  52.             forward(1);
  53.            
  54.  
  55.         }
  56.     }
  57.     //Create a loop to look for hotkeys.
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement