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
+19
View File
@@ -1,3 +1,22 @@
pub mod consts;
pub mod countdown;
pub mod elevation;
use windows::Win32::UI::{
Input::KeyboardAndMouse::GetAsyncKeyState,
WindowsAndMessaging::{GetForegroundWindow, GetWindowTextW},
};
pub fn is_window_focused(target_title: &str) -> bool {
unsafe {
let hwnd = GetForegroundWindow();
let mut buffer: [u16; 512] = [0; 512];
let length = GetWindowTextW(hwnd, &mut buffer);
let current_title = String::from_utf16_lossy(&buffer[..length as usize]);
current_title == target_title
}
}
pub fn is_key_pressed(key: i32) -> bool {
unsafe { (GetAsyncKeyState(key) as i32 & 0x8000) != 0 }
}