Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <Windows.h>
- #define KeyDown(Key) (GetAsyncKeyState(Key) & 0x8000)
- inline bool press(INPUT *kbInput, bool down)
- {
- kbInput->ki.dwFlags = KEYEVENTF_SCANCODE;
- if (!down)
- {
- kbInput->ki.dwFlags |= KEYEVENTF_KEYUP;
- }
- SendInput(1, kbInput, sizeof(INPUT));
- return down;
- }
- int main()
- {
- POINT centre, current;
- bool leftDown = false, rightDown = false;
- bool spacedown = false;
- INPUT leftKey, rightKey, spacekey;
- ZeroMemory(&leftKey, sizeof(INPUT));
- ZeroMemory(&rightKey, sizeof(INPUT));
- ZeroMemory(&spacekey, sizeof(INPUT));
- leftKey.type = rightKey.type = spacekey.type= INPUT_KEYBOARD;
- leftKey.ki.dwFlags = rightKey.ki.dwFlags = spacekey.ki.dwFlags = KEYEVENTF_SCANCODE;
- leftKey.ki.wScan = 0x1E;
- rightKey.ki.wScan = 0x20;
- spacekey.ki.wScan = 0x39;
- bool toggle = false;
- while (KeyDown(VK_RETURN) == NULL)
- {
- Sleep(250);
- }
- GetCursorPos(¢re);
- while (KeyDown(VK_END) == NULL)
- {
- GetCursorPos(¤t);
- if (KeyDown(VK_MBUTTON) != NULL) //TOGGLE KEY
- {
- toggle = !toggle;
- Sleep(200);
- }
- if (KeyDown(0x2D) != NULL || toggle) //HOTKEY or TOGGLE ACTIVATED
- {
- if (current.x < centre.x && !leftDown) //walk left (stop moving right first)
- {
- if (rightDown)
- {
- rightDown = press(&rightKey, false);
- }
- leftDown = press(&leftKey, true);
- }
- else if (current.x > centre.x && !rightDown) //walk right (stop moving left first)
- {
- if (leftDown)
- {
- leftDown = press(&leftKey, false);
- }
- rightDown = press(&rightKey, true);
- }
- }
- else
- {
- if (leftDown)
- leftDown = press(&leftKey, false);
- if (rightDown)
- rightDown = press(&rightKey, false);
- }
- Sleep(5);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement