Tobei Posted October 30, 2005 Share Posted October 30, 2005 I'm trying to get my script to stop all execution (especially hotkeys) when the script's target window is not active.I have WinWaitActive("<target window>") just before the first hotkeys are setup and the main loop begins.This works fine for splash screen and other processes that should be run before the main loop beings,but this doesn't seem to pause the script when the user leaves the target window once the main loop starts...---The only workable solution I can think of would be to call a function at the beginning of the main loop that:1) check if the window is active2) if it is not, remove all hotkeys according to current "state" (or menu) the user was in, and set new "state"3) if it is, and the current "state" is the "window not active" "state" then restore "state" user was in, including hotkeys, etc.4) if it is, and the current "state" is not the "window not active" "state" then return.---I could probably write that function without any trouble, but then i'd have to rework my entire menu system throughout my script to facilitate the change...Is there an easier way?Thanks,Tobei. Link to comment Share on other sites More sharing options...
Valuater Posted October 30, 2005 Share Posted October 30, 2005 I'm trying to get my script to stop all execution (especially hotkeys) when the script's target window is not active.I have WinWaitActive("<target window>") just before the first hotkeys are setup and the main loop begins.This works fine for splash screen and other processes that should be run before the main loop beings,but this doesn't seem to pause the script when the user leaves the target window once the main loop starts...---The only workable solution I can think of would be to call a function at the beginning of the main loop that:1) check if the window is active2) if it is not, remove all hotkeys according to current "state" (or menu) the user was in, and set new "state"3) if it is, and the current "state" is the "window not active" "state" then restore "state" user was in, including hotkeys, etc.4) if it is, and the current "state" is not the "window not active" "state" then return.---I could probably write that function without any trouble, but then i'd have to rework my entire menu system throughout my script to facilitate the change...Is there an easier way?Thanks,Tobei.you basically wrote the function...maybe more like thisIf Not WinActivate("win name") Then HotKeySet("{F1}"); nothing ; other keys...etc HotKeySet("{F1}", "new_state"); new state ElseIf WinActive("win name","") Then ;do something Else WinSetState("win name", "", "state") ; do something EndIfneeds your input to work8) Link to comment Share on other sites More sharing options...
Tobei Posted November 2, 2005 Author Share Posted November 2, 2005 Thought I'd share the peice of code that accomplished this.(Extracted from my Dofus Companion Webpage );Main loop. While 1 While WinActive( "Dofus") If getstate () = $state_sleep Then setstate ($state_mainmenu) Sleep(1000) WEnd If getstate () <> $state_sleep Then setstate ($state_sleep) If getstate () = $state_sleep Then Sleep(1000) WEndSo:While "Dofus" is running and in the foreground the script functions normally with the state in mainmenuWhile "Dofus" is not running or is not in the forground the script functions normally with state in sleep.sleep mode: only active hotkey is the one to quit.-----Thought maybe this would help somebody out. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now