-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCS2-autostop.cpp
More file actions
60 lines (51 loc) · 1.8 KB
/
CS2-autostop.cpp
File metadata and controls
60 lines (51 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <windows.h>
void pressKeys(bool Wkey, bool Akey, bool Skey, bool Dkey) {
// Press W, A, S, D
if (Skey)
keybd_event(0x57, 0, 0, 0); // W key down
if (Dkey)
keybd_event(0x41, 0, 0, 0); // A key down
if (Wkey)
keybd_event(0x53, 0, 0, 0); // S key down
if (Akey)
keybd_event(0x44, 0, 0, 0); // D key down
}
void autoRelease() {
// Release W, A, S, D
keybd_event(0x57, 0, KEYEVENTF_KEYUP, 0); // W key up
keybd_event(0x41, 0, KEYEVENTF_KEYUP, 0); // A key up
keybd_event(0x53, 0, KEYEVENTF_KEYUP, 0); // S key up
keybd_event(0x44, 0, KEYEVENTF_KEYUP, 0); // D key up
}
void mainBrake(int button) {
std::cout << "Press Space key to trigger W, A, S, D keys..." << std::endl;
while (true) {
bool temp = false;
bool Wkey = (GetAsyncKeyState(0x57) & 0x8000);
bool Akey = (GetAsyncKeyState(0x41) & 0x8000);
bool Skey = (GetAsyncKeyState(0x53) & 0x8000);
bool Dkey = (GetAsyncKeyState(0x44) & 0x8000);
// Check if Space key is pressed VK_SPACE
if (GetAsyncKeyState(button) & 0x8000) {
std::cout << "Brake!" << std::endl;
pressKeys(Wkey, Akey, Skey, Dkey);
temp = true;
Sleep(10);
std::cout << "Release!" << std::endl;
autoRelease();
}
while (GetAsyncKeyState(button) & 0x8000) {
Sleep(10);
}
Sleep(10); // Small delay to avoid high CPU usage
}
}
int main() {
int button = VK_SPACE; // Trigger button
mainBrake(button);
return 0;
}
// if your pc blocks my .exe file, you can compile this .cpp file by
// g++ CS2-autostop.cpp -o CS2-autostop.exe -lgdi32
// and then run the compiled .exe file