-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
82 lines (73 loc) · 1.55 KB
/
main.cpp
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <Windows.h>
#include <iostream>
#include <stdio.h>
#include "VK_Controls.h"
#define _ GetAsyncKeyState
bool doSprinting = false;
bool lastValue = true;
using namespace std;
struct profile {
string text_enable = "[Sprinting(Toggled)]";
string text_disable = "[Not Sprinting]";
int hotKey = VK_I;
};profile pro;
void loadProfile(void) {
freopen("./toggle_sprint.config","r",stdin);
getline(cin,pro.text_enable);//read the first line
getline(cin,pro.text_disable);//read the second line
cin>>hex>>pro.hotKey;//read the third line
fclose(stdin);
cout<<"loading profile...";
}
void render(void) {
if(lastValue != doSprinting) {
system("cls");
char hotKey_ascii = pro.hotKey;
cout<<"Hotkey: "<<hotKey_ascii<<"\n\n";
if(doSprinting) {
cout<<pro.text_enable<<'\n';
} else {
cout<<pro.text_disable<<'\n';
}
lastValue = doSprinting;
}
}
void behavior(void) {
if (_(pro.hotKey) < 0) {//Press hot key = switch mode
if (!doSprinting) {
doSprinting = true;
//cout<<doSprinting<<endl;
} else {
doSprinting = false;
VK_Up(VK_CTRL);
//cout<<doSprinting<<endl;
}
Sleep(100);
}
if(doSprinting) {
if(_(VK_W) < 0) {
VK_Down(VK_CTRL);
} else {
VK_Up(VK_CTRL);
}
}
}
void mainLoop(void) {
behavior();
render();
Sleep(1);
}
int main() {
cin.tie(0),cout.tie(0);
loadProfile();
Sleep(1000);
while(true) {
mainLoop();
if(_(VK_ESC) < 0 && _(VK_SHIFT) < 0) {
break;
}
}
exit(0);
}
//[Sprinting(Key Held)]
//[Sprinting(Toggled)]