#include <iostream>
#include <ctime>
#include <windows.h>
POINT Center, CurPos;
bool FirstTime = true;
int SendKeyPress(unsigned short KeyCode, bool IsDown);
int main()
{
printf("Z to set strafe center point");
while (true)
{
if (GetAsyncKeyState(0x5A) & (1 << 15))
{
if (FirstTime)
{
GetCursorPos(&Center);
FirstTime = false;
printf("Strafebot activated\nHold Z to strafe");
MessageBox(NULL, "Center Position Set", "Strafe Bot", NULL);
}
GetCursorPos(&CurPos);
if (CurPos.x > Center.x)
{
SendKeyPress(0x20, true);
Sleep(2);
SendKeyPress(0x20, false);
}
else if (CurPos.x < Center.x)
{
SendKeyPress(0x1e, true);
Sleep(2);
SendKeyPress(0x1e, false);
}
}
}
return 0;
}
int SendKeyPress(unsigned short KeyCode, bool KeyDown)
{
INPUT InputData;
InputData.type = INPUT_KEYBOARD;
InputData.ki.wScan = KeyCode;
InputData.ki.time = time(NULL);
InputData.ki.dwExtraInfo = 0;
if (KeyDown)
InputData.ki.dwFlags = KEYEVENTF_SCANCODE;
else
InputData.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
return SendInput(1, &InputData, sizeof(InputData));
}
