improve anti afk with added checks and different keys

This commit is contained in:
2025-04-09 16:34:30 +01:00
parent 1aebc6b17c
commit 4bb0f151a9
4 changed files with 60 additions and 10 deletions
+16 -5
View File
@@ -1,10 +1,12 @@
use crate::util::{self, consts::GTA_WINDOW_TITLE};
use std::time::{Duration, Instant};
use windows::Win32::UI::Input::KeyboardAndMouse::{
KEYBD_EVENT_FLAGS, MAP_VIRTUAL_KEY_TYPE, MapVirtualKeyW, keybd_event,
};
pub const INTERVAL: Duration = Duration::from_secs(60);
const VK_SHIFT: u8 = 16;
const VK_NUMPAD4: u8 = 0x64;
const VK_NUMPAD6: u8 = 0x66;
#[derive(Debug)]
pub struct AntiAfk {
@@ -21,6 +23,19 @@ impl Default for AntiAfk {
}
}
impl AntiAfk {
pub fn activate(&mut self) {
if util::is_window_focused(GTA_WINDOW_TITLE)
&& !util::is_key_pressed(VK_NUMPAD4 as i32)
&& !util::is_key_pressed(VK_NUMPAD6 as i32)
{
send(VK_NUMPAD4);
send(VK_NUMPAD6);
}
self.interval = Instant::now();
}
}
pub fn send(vk_code: u8) {
unsafe {
keybd_event(
@@ -37,7 +52,3 @@ pub fn send(vk_code: u8) {
);
}
}
pub fn activate() {
send(VK_SHIFT);
}