Skip to content

Commit 5d8e5bc

Browse files
committed
Rename SnapTap to AutoStop, Add Toggle/Hold for AutoStop
1 parent 97d05bb commit 5d8e5bc

File tree

10 files changed

+84
-35
lines changed

10 files changed

+84
-35
lines changed

ErScripts/SnapTap.cpp renamed to ErScripts/AutoStop.cpp

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,53 @@ inline void PressAndRelease(char key, std::vector<int>& recentDelays) {
3333
ErScripts::Keyboard(key, false, false);
3434
}
3535

36-
void ErScripts::SnapTap() {
36+
//bool curMenuState = (GetAsyncKeyState(VK_INSERT) & 0x8000) != 0;
37+
//
38+
//// Check if key state changed from not pressed to pressed
39+
//if (curMenuState && !prevMenuState) {
40+
// globals::menuState = !globals::menuState;
41+
//
42+
// if (globals::menuState && ErScripts::GetWindowState() && ErScripts::GetCursorState()) {
43+
// showChat = true;
44+
// ErScripts::Keyboard(0x55, true, false); // U
45+
// std::this_thread::sleep_for(std::chrono::milliseconds((std::rand() % 100 + 16)));
46+
// ErScripts::Keyboard(0x55, false, false);
47+
// }
48+
// else if (showChat) {
49+
// showChat = false;
50+
// ErScripts::Keyboard(VK_ESCAPE, true, false); // ESCAPE
51+
// std::this_thread::sleep_for(std::chrono::milliseconds((std::rand() % 100 + 16)));
52+
// ErScripts::Keyboard(VK_ESCAPE, false, false);
53+
// }
54+
//}
55+
//
56+
//prevMenuState = curMenuState;
57+
58+
void ErScripts::AutoStop() {
3759
std::thread([this]() {
3860
std::vector<int> recentDelays;
3961
bool aWasPressed = false;
4062
bool dWasPressed = false;
4163

64+
bool state = false;
65+
bool statePrev = false;
66+
4267
while (!globals::finish) {
43-
if (cfg->snapTapState) {
68+
if (cfg->autoStopState) {
4469
if (ErScripts::GetWindowState() && ErScripts::GetCursorState()) {
45-
if (GetAsyncKeyState(cfg->snapTapBind) & 0x8000) {
70+
bool bindState = GetAsyncKeyState(cfg->autoStopBind) & 0x8000;
71+
72+
if (cfg->autoStopToggleState) {
73+
if (bindState && !statePrev) {
74+
state = !state;
75+
}
76+
}
77+
else {
78+
state = bindState;
79+
}
80+
statePrev = bindState;
81+
82+
if (state) {
4683
bool aPressed = GetAsyncKeyState('A') & 0x8000;
4784
bool dPressed = GetAsyncKeyState('D') & 0x8000;
4885

ErScripts/Config.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ void Config::load(const std::string& filename) {
7878
read(json["round-start-alert"]["volume"], roundStartAlertVolume);
7979
read(json["round-start-alert"]["file-name"], roundStartAlertFileName);
8080

81-
/* Snap Tap */
82-
read(json["snap-tap"]["state"], snapTapState);
83-
read(json["snap-tap"]["bind"], snapTapBind);
81+
/* Auto Stop */
82+
read(json["auto-stop"]["state"], autoStopState);
83+
read(json["auto-stop"]["bind"], autoStopBind);
84+
read(json["auto-stop"]["toggle"]["state"], autoStopToggleState);
8485

8586
/* Watermark */
8687
read(json["watermark"]["state"], watermarkState);
@@ -178,9 +179,10 @@ void Config::save(const std::string& filename) const {
178179
json["round-start-alert"]["volume"] = roundStartAlertVolume;
179180
json["round-start-alert"]["file-name"] = roundStartAlertFileName;
180181

181-
/* Snap Tap */
182-
json["snap-tap"]["state"] = snapTapState;
183-
json["snap-tap"]["bind"] = snapTapBind;
182+
/* Auto Stop */
183+
json["auto-stop"]["state"] = autoStopState;
184+
json["auto-stop"]["bind"] = autoStopBind;
185+
json["auto-stop"]["toggle"]["state"] = autoStopToggleState;
184186

185187
/* Watermark */
186188
json["watermark"]["state"] = watermarkState;

ErScripts/Config.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ class Config {
8181
int roundStartAlertVolume{ 100 };
8282
std::string roundStartAlertFileName{ "" };
8383

84-
/* Snap Tap */
85-
bool snapTapState{ false };
86-
int snapTapBind{ 0 };
84+
/* Auto Stop */
85+
bool autoStopState{ false };
86+
int autoStopBind{ 0 };
87+
bool autoStopToggleState{ false };
8788

8889
/* Watermark */
8990
bool watermarkState{ true };

ErScripts/ErScripts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ErScripts {
3131
void KillSay();
3232
void KillSound();
3333
void RoundStartAlert();
34-
void SnapTap();
34+
void AutoStop();
3535
private:
3636
static HWND hwnd;
3737

ErScripts/ErScripts.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@
179179
<ClCompile Include="Render.cpp" />
180180
<ClCompile Include="RGBCrosshair.cpp" />
181181
<ClCompile Include="SimpleSound.cpp" />
182-
<ClCompile Include="SnapTap.cpp" />
182+
<ClCompile Include="AutoStop.cpp" />
183183
<ClCompile Include="SoundsShellcodes.h" />
184184
<ClCompile Include="SteamTools.cpp" />
185-
<ClCompile Include="main.cpp" />
185+
<ClCompile Include="Main.cpp" />
186186
<ClCompile Include="UIAccess.c" />
187187
<ClCompile Include="Updater.cpp" />
188188
</ItemGroup>

ErScripts/ErScripts.vcxproj.filters

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
</Filter>
5757
</ItemGroup>
5858
<ItemGroup>
59-
<ClCompile Include="main.cpp">
59+
<ClCompile Include="Main.cpp">
6060
<Filter>Main</Filter>
6161
</ClCompile>
6262
<ClCompile Include="Logger.cpp">
@@ -164,7 +164,7 @@
164164
<ClCompile Include="Updater.cpp">
165165
<Filter>Functions\Updater</Filter>
166166
</ClCompile>
167-
<ClCompile Include="SnapTap.cpp">
167+
<ClCompile Include="AutoStop.cpp">
168168
<Filter>Functions\Functions</Filter>
169169
</ClCompile>
170170
</ItemGroup>

ErScripts/Menu.cpp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ inline const char* dropBombKeyName = GetKeyName(cfg->dropBombBind);
6666
inline bool dropBombButtonState = false;
6767
inline const char* selfKickKeyName = GetKeyName(cfg->selfKickBind);
6868
inline bool selfKickButtonState = false;
69-
inline const char* snapTapKeyName = GetKeyName(cfg->snapTapBind);
70-
inline bool snapTapButtonState = false;
69+
inline const char* autoStopKeyName = GetKeyName(cfg->autoStopBind);
70+
inline bool autoStopButtonState = false;
7171
inline char killSayText[256]{};
7272
inline char killSoundFileName[256]{};
7373
inline char roundStartAlertFileName[256]{};
@@ -144,7 +144,7 @@ void Overlay::Menu() noexcept {
144144
KillSayMenu();
145145
KillSoundMenu();
146146
RoundStartAlertMenu();
147-
SnapTapMenu();
147+
AutoStopMenu();
148148
GradientManagerMenu();
149149
WatermarkMenu();
150150
FPSLimitMenu();
@@ -167,7 +167,7 @@ void Overlay::Menu() noexcept {
167167
jumpThrowKeyName = GetKeyName(cfg->jumpThrowBind);
168168
dropBombKeyName = GetKeyName(cfg->dropBombBind);
169169
selfKickKeyName = GetKeyName(cfg->selfKickBind);
170-
snapTapKeyName = GetKeyName(cfg->snapTapBind);
170+
autoStopKeyName = GetKeyName(cfg->autoStopBind);
171171

172172
if (ImGui::FindWindowByName(" Bomb Timer"))
173173
ImGui::SetWindowPos(" Bomb Timer", { cfg->bombTimerPos[0], cfg->bombTimerPos[1] });
@@ -631,27 +631,33 @@ void Overlay::RoundStartAlertMenu() noexcept {
631631
}
632632
}
633633

634-
void Overlay::SnapTapMenu() noexcept {
634+
void Overlay::AutoStopMenu() noexcept {
635635
ImGui::TableNextRow();
636636
ImGui::TableSetColumnIndex(0);
637-
ImGui::Checkbox("Snap Tap", &cfg->snapTapState);
637+
ImGui::Checkbox("Auto Stop", &cfg->autoStopState);
638638
ImGui::TableSetColumnIndex(1);
639639

640-
if (ImageButton("##SnapTap", (ImTextureID)settingsTexture, { 22, 22 })) {
641-
ImGui::OpenPopup("SnapTap Settings");
640+
if (ImageButton("##AutoStop", (ImTextureID)settingsTexture, { 22, 22 })) {
641+
ImGui::OpenPopup("AutoStop Settings");
642642
}
643643

644-
if (ImGui::BeginPopup("SnapTap Settings")) {
645-
if (ImGui::BeginTable("SnapTap Settings Table", 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_NoPadInnerX)) {
644+
if (ImGui::BeginPopup("AutoStop Settings")) {
645+
if (ImGui::BeginTable("AutoStop Settings Table", 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_NoPadInnerX)) {
646646
ImGui::TableNextRow();
647647
ImGui::TableSetColumnIndex(0);
648648
ImGui::Text("Hotkey ");
649649
ImGui::TableSetColumnIndex(1);
650-
snapTapKeyName = GetKeyName(cfg->snapTapBind);
651-
if (ImGui::Button(std::format("{}##PixelTrigger", snapTapKeyName).c_str(), ImVec2(80.0f, 22.0f))) {
652-
snapTapButtonState = !snapTapButtonState;
650+
autoStopKeyName = GetKeyName(cfg->autoStopBind);
651+
if (ImGui::Button(std::format("{}##PixelTrigger", autoStopKeyName).c_str(), ImVec2(80.0f, 22.0f))) {
652+
autoStopButtonState = !autoStopButtonState;
653653
}
654-
Hotkey(&snapTapButtonState, &snapTapKeyName, &cfg->snapTapBind);
654+
Hotkey(&autoStopButtonState, &autoStopKeyName, &cfg->autoStopBind);
655+
656+
ImGui::TableNextRow();
657+
ImGui::TableSetColumnIndex(0);
658+
ImGui::Text("Toggle ");
659+
ImGui::TableSetColumnIndex(1);
660+
ImGui::Checkbox("##AutoStopToggle", &cfg->autoStopToggleState);
655661

656662
ImGui::EndTable();
657663
}

ErScripts/Overlay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Overlay {
6666
void KillSayMenu() noexcept;
6767
void KillSoundMenu() noexcept;
6868
void RoundStartAlertMenu() noexcept;
69-
void SnapTapMenu() noexcept;
69+
void AutoStopMenu() noexcept;
7070
void GradientManagerMenu() noexcept;
7171
void WatermarkMenu() noexcept;
7272
void FPSLimitMenu() noexcept;

ErScripts/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
int main() {
88
if (!IsDebuggerPresent()) {
99
/* Auto updater */
10-
Updater updater("1.1.0", "emp0ry", "cs2-ErScripts", "ErScripts");
10+
Updater updater("1.1.1", "emp0ry", "cs2-ErScripts", "ErScripts");
1111
if (updater.checkAndUpdate())
1212
return 0;
1313

@@ -62,7 +62,7 @@ int main() {
6262
es.KillSay();
6363
es.KillSound();
6464
es.RoundStartAlert();
65-
es.SnapTap();
65+
es.AutoStop();
6666

6767
while (!globals::finish) {
6868
if (GetAsyncKeyState(VK_END) & 0x8000) globals::finish = true;

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Here’s what *ErScripts* offers:
4949
| **Kill Say** | Sends a custom chat message after kills. |
5050
| **Kill Sound** | Plays a sound on kills for extra flair. |
5151
| **Round Start Alert** | Sounds an alert if a round begins while you’re tabbed out. |
52-
| **Snap Tap** | Press the opposite key for a faster stop. |
52+
| **Auto Stop** | Press the opposite key for a auto stop. |
5353
| **Watermark** | Shows ping, time, and game info as an overlay. |
5454
| **Capture Bypass** | Hides the overlay from recordings/streams. |
5555
| **FPS Limiter** | Caps overlay FPS for smoother performance. |
@@ -99,6 +99,9 @@ Tailor *ErScripts* to your liking:
9999
- You can use a subfolder like `sounds` (e.g., `sounds/audio.wav` or `sounds/audio`).
100100
- If the file is missing or invalid, it defaults to the built-in sound.
101101

102+
### Auto Stop
103+
- **Toggle**: Enables hotkey to toggle auto-stop on/off (true) or activates it only while held (false).
104+
102105
### Watermark
103106
- **Gradient**: Toggle gradient text.
104107
- **Transparency**: Background opacity.

0 commit comments

Comments
 (0)