reorganize some consts
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::cast_possible_truncation)]
|
||||
|
||||
use crate::util::{self, consts::GTA_WINDOW_TITLE};
|
||||
use crate::util::{self, consts::game::WINDOW_TITLE};
|
||||
use std::time::{Duration, Instant};
|
||||
use windows::Win32::UI::Input::KeyboardAndMouse::{
|
||||
KEYBD_EVENT_FLAGS, MAP_VIRTUAL_KEY_TYPE, MapVirtualKeyW, VK_NUMPAD4, VK_NUMPAD6, keybd_event,
|
||||
@@ -35,7 +35,7 @@ impl AntiAfk {
|
||||
|
||||
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()
|
||||
is_window_focused(WINDOW_TITLE) && !is_any_key_pressed(&PRESS_KEYS) && !is_cursor_visible()
|
||||
}
|
||||
|
||||
pub fn send(vk_codes: &[u8]) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::util::{
|
||||
consts::{ENHANCED, LEGACY},
|
||||
consts::game::{EXE_ENHANCED, EXE_LEGACY},
|
||||
countdown::Countdown,
|
||||
};
|
||||
use std::time::{Duration, Instant};
|
||||
@@ -39,7 +39,7 @@ fn get_gta_pid(sysinfo: &mut System) -> u32 {
|
||||
if let Some((pid, _)) = sysinfo
|
||||
.processes()
|
||||
.iter()
|
||||
.find(|(_, p)| p.name() == ENHANCED || p.name() == LEGACY)
|
||||
.find(|(_, p)| p.name() == EXE_ENHANCED || p.name() == EXE_LEGACY)
|
||||
{
|
||||
return pid.as_u32();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::util::consts::{ENHANCED, LEGACY};
|
||||
use crate::util::consts::game::{EXE_ENHANCED, EXE_LEGACY};
|
||||
use std::time::Instant;
|
||||
use sysinfo::System;
|
||||
|
||||
@@ -32,7 +32,7 @@ pub fn activate(sysinfo: &mut System) {
|
||||
sysinfo
|
||||
.processes()
|
||||
.iter()
|
||||
.filter(|(_, p)| p.name() == ENHANCED || p.name() == LEGACY)
|
||||
.filter(|(_, p)| p.name() == EXE_ENHANCED || p.name() == EXE_LEGACY)
|
||||
.for_each(|(_, p)| {
|
||||
p.kill();
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::zombie_processes)]
|
||||
|
||||
use crate::util::consts::{ENHANCED, LEGACY};
|
||||
use crate::util::consts::game::{EXE_ENHANCED, EXE_LEGACY};
|
||||
use std::{os::windows::process::CommandExt, path::Path, process::Command};
|
||||
use sysinfo::System;
|
||||
use windows::Win32::System::Threading::CREATE_NO_WINDOW;
|
||||
@@ -12,7 +12,7 @@ fn get_game_exe_path(sysinfo: &mut System) -> Option<&Path> {
|
||||
if let Some((_, process)) = sysinfo
|
||||
.processes()
|
||||
.iter()
|
||||
.find(|(_, p)| p.name() == ENHANCED || p.name() == LEGACY)
|
||||
.find(|(_, p)| p.name() == EXE_ENHANCED || p.name() == EXE_LEGACY)
|
||||
{
|
||||
process.exe()
|
||||
} else {
|
||||
|
||||
+6
-3
@@ -9,7 +9,10 @@ use crate::{
|
||||
},
|
||||
util::{
|
||||
self,
|
||||
consts::{APP_STORAGE_PATH, ENHANCED, GTA_WINDOW_TITLE, LEGACY},
|
||||
consts::{
|
||||
APP_STORAGE_PATH,
|
||||
game::{EXE_ENHANCED, EXE_LEGACY, WINDOW_TITLE},
|
||||
},
|
||||
meta::Meta,
|
||||
persistent_state::PersistentState,
|
||||
},
|
||||
@@ -202,7 +205,7 @@ impl App {
|
||||
if self.anti_afk.enabled {
|
||||
ui.add_space(8.0);
|
||||
ui.add_enabled_ui(false, |ui| {
|
||||
ui.label(if util::win::is_window_focused(GTA_WINDOW_TITLE) {
|
||||
ui.label(if util::win::is_window_focused(WINDOW_TITLE) {
|
||||
"GTA is focused."
|
||||
} else {
|
||||
"GTA is not focused!"
|
||||
@@ -313,7 +316,7 @@ impl App {
|
||||
.sysinfo
|
||||
.processes()
|
||||
.iter()
|
||||
.find(|(_, p)| p.name() == ENHANCED || p.name() == LEGACY)
|
||||
.find(|(_, p)| p.name() == EXE_ENHANCED || p.name() == EXE_LEGACY)
|
||||
.map_or_else(
|
||||
|| "no pid found!".to_owned(),
|
||||
|(pid, _)| pid.as_u32().to_string(),
|
||||
|
||||
+6
-5
@@ -1,9 +1,10 @@
|
||||
use std::{path::PathBuf, sync::LazyLock};
|
||||
|
||||
pub const ENHANCED: &str = "GTA5_Enhanced.exe";
|
||||
pub const LEGACY: &str = "GTA5.exe";
|
||||
|
||||
pub const GTA_WINDOW_TITLE: &str = "Grand Theft Auto V";
|
||||
|
||||
pub static APP_STORAGE_PATH: LazyLock<PathBuf> =
|
||||
LazyLock::new(|| dirs::config_local_dir().unwrap().join("GTA Tools"));
|
||||
|
||||
pub mod game {
|
||||
pub const EXE_ENHANCED: &str = "GTA5_Enhanced.exe";
|
||||
pub const EXE_LEGACY: &str = "GTA5.exe";
|
||||
pub const WINDOW_TITLE: &str = "Grand Theft Auto V";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user