@@ -20,14 +20,33 @@ fn make_l_param(lo_word: i32, hi_word: i32) -> i32 {
2020 ( hi_word << 16 ) | ( lo_word & 0xffff )
2121}
2222
23- pub fn anti_afk ( game_name : & str , mut run_once_no_game : bool ) -> bool {
23+ pub fn anti_afk ( cfg : & structs :: SeederConfig , game_name : & str , mut run_once_no_game : bool ) -> bool {
2424 let game_info = is_running ( game_name) ;
2525 if game_info. is_running {
2626 unsafe {
2727 let current_forground_window = GetForegroundWindow ( ) ;
28- let l_param = make_l_param ( 20 , 20 ) ;
29- SendMessageW ( game_info. game_process , 0x201 , 0 , l_param as isize ) ;
30- SendMessageW ( game_info. game_process , 0x202 , 0 , l_param as isize ) ;
28+
29+ if cfg. keypress_mode {
30+ ShowWindow ( game_info. game_process , 9 ) ;
31+ SetForegroundWindow ( game_info. game_process ) ;
32+ sleep ( Duration :: from_millis ( 1808 ) ) ;
33+
34+ if cfg. key == "tab" {
35+ send_keys:: key_enter ( 0x0F , cfg. key_hold_time ) ;
36+ } else {
37+ send_keys:: send_key ( & cfg. key , cfg. key_hold_time ) ;
38+ }
39+ sleep ( Duration :: from_secs ( 1 ) ) ;
40+
41+ if cfg. minimize_after_action {
42+ ShowWindow ( game_info. game_process , 6 ) ;
43+ }
44+ } else {
45+ // use mousebutton
46+ let l_param = make_l_param ( 20 , 20 ) ;
47+ SendMessageW ( game_info. game_process , 0x201 , 0 , l_param as isize ) ;
48+ SendMessageW ( game_info. game_process , 0x202 , 0 , l_param as isize ) ;
49+ }
3150 SetForegroundWindow ( current_forground_window) ;
3251 // reset no game check
3352 run_once_no_game = true ;
@@ -188,7 +207,7 @@ pub fn send_message(
188207 structs:: ChatType :: Squad => message_action ( current_message, squad_key) ,
189208 }
190209
191- if cfg. minimize_after_message {
210+ if cfg. minimize_after_action {
192211 ShowWindow ( game_info. game_process , 6 ) ;
193212 }
194213 }
0 commit comments