Im using the code below in roblox surf as strafe helper. Make it when right click is…
- User
Im using the code below in roblox surf as strafe helper. Make it when right click is held down, keep how it captures if mouse is going left or right and pressind a or d BUT make software not give other applications mouse movement anymore like block it out and make it press A + left arrow or D + right arrow instead depending where mouse is moving.
#include <windows.h> #include #include #include
// Function to simulate key press using scan codes void PressKey(WORD scanCode) { INPUT input = {}; input.type = INPUT_KEYBOARD; input.ki.wScan = scanCode; input.ki.dwFlags = KEYEVENTF_SCANCODE; SendInput(1, &input, sizeof(INPUT)); }
void ReleaseKey(WORD scanCode) { INPUT input = {}; input.type = INPUT_KEYBOARD; input.ki.wScan = scanCode; input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP; SendInput(1, &input, sizeof(INPUT)); }
// Helper class to manage key states class KeyState { public: std::atomic aPressed; std::atomic dPressed;
codeKeyState() : aPressed(false), dPressed(false) {} void PressA() { if (!aPressed.load()) { PressKey(0x1E); // Scan code for 'A' aPressed = true; } } void ReleaseA() { if (aPressed.load()) { ReleaseKey(0x1E); // Scan code for 'A' aPressed = false; } } void PressD() { if (!dPressed.load()) { PressKey(0x20); // Scan code for 'D' dPressed = true; } } void ReleaseD() { if (dPressed.load()) { ReleaseKey(0x20); // Scan code for 'D' dPressed = false; } } void ReleaseAll() { ReleaseA(); ReleaseD(); }};
// Function to bring Roblox window to foreground HWND GetRobloxWindow() { HWND hwnd = FindWindow(NULL, NULL); while (hwnd != NULL) { wchar_t title[256]; GetWindowText(hwnd, title, sizeof(title) / sizeof(wchar_t)); std::wstring windowTitle(title); if (windowTitle.find(L"Roblox") != std::wstring::npos) { return hwnd; } hwnd = FindWindowEx(NULL, hwnd, NULL, NULL); } return NULL; }
// Constants for thresholds and timings const LONG MOVEMENT_THRESHOLD = 5; // Minimum pixels of movement before switching keys const DWORD KEY_PRESS_DURATION = 10; // Minimum duration to hold a key in milliseconds
// Function to get the current time in milliseconds DWORD GetCurrentTimeMs() { return GetTickCount(); }
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static bool isRightButtonDown = false; static KeyState keyState; static HWND robloxHwnd = NULL;
- Assistant