Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * main.cpp
- * bot
- *
- * Created by Geoffrey on 28/10/10.
- * Copyright 2010 __MyCompanyName__. All rights reserved.
- *
- */
- #include <iostream> // I/O
- #include "main.h"
- #include <windows.h> //This is what we need for the SendInput functions
- int main()
- {
- DWORD dwHandleHotKeys;
- CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)HandleHotKeys, NULL, NULL, &dwHandleHotKeys);
- //On Exit
- ExitThread(dwHandleHotKeys);
- INPUT Input;
- Input.type = INPUT_MOUSE;
- Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN; //Clicks the mouse down.
- SendInput(true, &Input, sizeof(Input));
- Input.mi.dwFlags = MOUSEEVENTF_LEFTUP; //Releases the mouse clock.
- SendInput(true, &Input, sizeof(Input));
- return 0;
- }
- void forward(seconds)
- {
- INPUT Input;
- Input.type = INPUT_KEYBOARD;
- Input.ki.wvK = 'W';
- Input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
- SendInput(true, &Input, sizeof(Input));
- sleep(seconds);
- Input.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(true, &Input, sizeof(Input));
- }
- void HandleHotKeys()
- {
- for(;;)
- {
- cin >> mystring;
- if (mystring == "forward") {
- INPUT Input;
- Input.type = INPUT_MOUSE;
- Input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
- Input.mi.dx = GetSystemMetrics(SM_CXSCREEN) / 2;
- Input.mi.dy = GetSystemMetrics(SM_CYSCREEN) / 2;
- forward(1);
- }
- }
- //Create a loop to look for hotkeys.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement