This commit is contained in:
2025-04-17 01:31:49 +01:00
parent 1c048e6aff
commit 6935b852ce
5 changed files with 19 additions and 18 deletions
+6 -8
View File
@@ -25,21 +25,19 @@ impl Default for AntiAfk {
}
impl AntiAfk {
pub fn can_activate(&self) -> bool {
use util::win::*;
is_window_focused(GTA_WINDOW_TITLE)
&& !is_any_key_pressed(&PRESS_KEYS)
&& !is_cursor_visible()
}
pub fn activate(&mut self) {
if self.can_activate() {
if can_activate() {
send(&PRESS_KEYS);
}
self.interval = Instant::now();
}
}
pub fn can_activate() -> bool {
use util::win::{is_any_key_pressed, is_cursor_visible, is_window_focused};
is_window_focused(GTA_WINDOW_TITLE) && !is_any_key_pressed(&PRESS_KEYS) && !is_cursor_visible()
}
pub fn send(vk_codes: &[u8]) {
vk_codes.iter().for_each(|vk_code: &u8| unsafe {
keybd_event(
+1 -1
View File
@@ -41,7 +41,7 @@ fn get_gta_pid(sysinfo: &mut System) -> u32 {
.find(|(_, p)| p.name() == ENHANCED || p.name() == LEGACY)
{
return pid.as_u32();
};
}
u32::MAX
}
+10 -7
View File
@@ -154,7 +154,7 @@ impl App {
ui.horizontal(|ui| {
if ui.button("Launch").clicked() {
features::launch::launch(&self.launch.selected);
};
}
build_combo_box::<features::launch::Platform>(ui, &mut self.launch.selected, "Launch");
});
let force_close_button = ui.add_sized(
@@ -164,7 +164,7 @@ impl App {
if force_close_button.clicked() && !self.force_close.prompting {
self.force_close.prompting();
self.flags.current_frame = true;
};
}
if self.force_close.prompting
&& self.force_close.interval.elapsed() <= Duration::from_secs(3)
{
@@ -228,13 +228,13 @@ impl App {
.clicked()
{
features::game_networking::block_all(&mut self.sysinfo);
};
}
if ui
.add_sized([button_width, 18.0], egui::Button::new("Unblock"))
.clicked()
{
features::game_networking::unblock_all();
};
}
});
});
response.response.on_disabled_hover_text(
@@ -277,13 +277,16 @@ impl App {
fn show_debug(&mut self, _ctx: &egui::Context, ui: &mut egui::Ui) {
if ui.button("open storage path").clicked() {
open::that_detached(APP_STORAGE_PATH.as_path()).unwrap();
};
}
ui.collapsing("anti afk", |ui| {
ui.label(format!(
"timer: {}",
self.anti_afk.interval.elapsed().as_secs()
));
ui.label(format!("can activate: {}", self.anti_afk.can_activate()));
ui.label(format!(
"can activate: {}",
features::anti_afk::can_activate()
));
});
ui.collapsing("sysinfo", |ui| {
if ui.button("refresh all").clicked() {
@@ -399,7 +402,7 @@ fn app_creator(
if let Some(persistent_state) = PersistentState::get() {
app.launch.selected = persistent_state.launcher;
app.settings = persistent_state.settings;
};
}
let elevated = util::win::is_elevated();
if app.settings.start_elevated && !elevated {
util::win::elevate(util::win::ElevationExitMethod::Forced);
+1 -1
View File
@@ -36,6 +36,6 @@ impl Countdown {
self.i_string = self.i.to_string();
if self.i == 0 {
self.reset();
};
}
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ pub enum ElevationExitMethod<'a> {
pub fn is_cursor_visible() -> bool {
let mut ci = CURSORINFO {
cbSize: std::mem::size_of::<CURSORINFO>() as u32,
cbSize: u32::try_from(std::mem::size_of::<CURSORINFO>()).unwrap(),
..Default::default()
};
unsafe {