Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <iostream>
- #include <thread>
- #include <chrono>
- #include <string>
- #include <fstream>
- #define callReturn CallNextHookEx((HHOOK)NULL, nCode, wParam, lParam);
- using namespace std;
- KEYBDINPUT kinput[2];
- int keyBind[2];
- bool key_down[2];
- LRESULT CALLBACK keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
- KBDLLHOOKSTRUCT* kb = (KBDLLHOOKSTRUCT*)lParam;
- int key;
- if (kb->vkCode != keyBind[0] && kb->vkCode != keyBind[1]) return callReturn;
- if (wParam != WM_KEYDOWN && wParam != WM_KEYUP) return callReturn;
- if (kb->vkCode == keyBind[0])
- key = 0;
- else key = 1;
- if (wParam == WM_KEYUP) {
- key_down[key] = false;
- return callReturn;
- }
- if (!key_down[key]) {
- kinput[key].dwFlags = 0;
- INPUT inputs[1];
- inputs[0].type = INPUT_KEYBOARD;
- inputs[0].ki = kinput[key];
- int res = SendInput(1, inputs, sizeof(INPUT));
- this_thread::sleep_for(chrono::milliseconds(10));
- kinput[key].dwFlags = 2;
- inputs[0].ki = kinput[key];
- res = SendInput(1, inputs, sizeof(INPUT));
- key_down[key] = true;
- }
- return callReturn;
- }
- int main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
- {
- printf("#########################################################\n");
- printf("#\t\t\t\t\t\t\t#\n");
- printf("#\t\t osu!mania scratch fix\t\t#\n");
- printf("#\t\t\t\t\t\t\t#\n");
- printf("#\t\t\tHow to use:\t\t\t#\n");
- printf("#\t\t\t\t\t\t\t#\n");
- printf("#\t Set your two scratch binds in the cfg\t\t#\n");
- printf("#\t file (windows virtual key codes) and\t\t#\n");
- printf("#\t bind the scratches in-game to 1 and 2.\t#\n");
- printf("#\t\t\t\t\t\t\t#\n");
- printf("#\t\t\t\t\t\t\t#\n");
- printf("#\t This app needs to be run as admin or\t\t#\n");
- printf("#\t osu! will freak out for some reason.\t\t#\n");
- printf("#\t\t\t\t\t\t\t#\n");
- printf("#\t\t\t\t\t\t\t#\n");
- printf("#########################################################\n");
- // Init
- ifstream config("scratcher.cfg");
- if (!config.is_open())
- return 0;
- while(!config.eof())
- {
- string line;
- getline(config, line);
- config >> keyBind[0] >> keyBind[1];
- }
- config.close();
- kinput[0].wVk = 0x31;
- kinput[0].wScan = 0;
- kinput[0].time = 0;
- kinput[1].wVk = 0x32;
- kinput[1].wScan = 0;
- kinput[1].time = 0;
- // Hook
- HHOOK hook = SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)keyboardHookProc, NULL, 0);
- // Handle messages
- MSG msg;
- while (GetMessage(&msg, NULL, 0, 0) > 0) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement