d00dness Posted January 21, 2008 Share Posted January 21, 2008 Good day..... just a quick question on Timers and Pausing...... I'm in the middle of rewriting my script I use and I came across a post about using timers using the TimerInit function and the TimerDiff function.... What I'm courious about is while the timer is active, is there a way that I can 'pause' and 'unpause' a portion of the script without having to pause the entire script? Ex: Lets say I'm in a game and my buffs go off every 20 secs..... my timer is setup to fire off the buffs every 20secs, but because of my style of fighting, I don't want my 'combat' portion of the script to be active until I press the F6 key... and once I'm done fighting I want to press the F6 key again to pause it and so on.... without interupting my buffing... can this be done ? Thanks much .... Link to comment Share on other sites More sharing options...
Paulie Posted January 21, 2008 Share Posted January 21, 2008 You may be best able to solve this using multiple scripts. Use a main one to run constantly, and then just have hotkeys set to run other script that do whatever you want. Link to comment Share on other sites More sharing options...
d00dness Posted January 22, 2008 Author Share Posted January 22, 2008 Thanks Paulie .. can you give me an example of how to setup executing another script within a script? This I've never done... Thanks.. Link to comment Share on other sites More sharing options...
Paulie Posted January 22, 2008 Share Posted January 22, 2008 Thanks Paulie .. can you give me an example of how to setup executing another script within a script? This I've never done... Thanks.. This is from http://www.autoitscript.com/autoit3/docs/i...nning.htm" AutoIt specific command Line Switches Form1: AutoIt3.exe [/ErrorStdOut] [/AutoIt3ExecuteScript] file [params ...] Execute an AutoIt3 Script File Link to comment Share on other sites More sharing options...
d00dness Posted January 22, 2008 Author Share Posted January 22, 2008 Tks again... I appreciate the help... Link to comment Share on other sites More sharing options...
d00dness Posted January 22, 2008 Author Share Posted January 22, 2008 -- Update -- I looked at the URL Paulie but could not figure out how to execute a script within a script, so I did some more research and came up with this example from PSaultyDS expandcollapse popupHotKeySet("{ESC}", "_Quit") Global $REDCooldown1 = 1000 Global $REDCooldown1Temp = TimerInit() Global $REDCooldown2 = 2000 Global $REDCooldown2Temp = TimerInit() Global $REDCooldown3 = 3000 Global $REDCooldown3Temp = TimerInit() Global $REDCooldown4 = 4000 Global $REDCooldown4Temp = TimerInit() ; Open notepad to monitor test Run("notepad.exe") WinWait("Untitled - Notepad") $hWin = WinGetHandle("Untitled - Notepad") If Not WinActive($hWin) Then WinActivate($hWin) WinWaitActive($hWin) ; Check timer status every 100ms AdlibEnable("_TimerDispatch", 100) ; Script could be busy doing other things here... While 1 Sleep(20) WEnd ; Function to perform timed operations Func _TimerDispatch() If $REDCooldown4 <= TimerDiff($REDCooldown4Temp) Then ControlSend($hWin, "", "Edit1", "4{ENTER}") $REDCooldown4Temp = TimerInit() EndIf If $REDCooldown3 <= TimerDiff($REDCooldown3Temp) Then ControlSend($hWin, "", "Edit1", "3{ENTER}") $REDCooldown3Temp = TimerInit() EndIf If $REDCooldown2 <= TimerDiff($REDCooldown2Temp) Then ControlSend($hWin, "", "Edit1", "2{ENTER}") $REDCooldown2Temp = TimerInit() EndIf If $REDCooldown1 <= TimerDiff($REDCooldown1Temp) Then ControlSend($hWin, "", "Edit1", "1{ENTER}") $REDCooldown1Temp = TimerInit() EndIf EndFunc ;==>_TimerDispatch ; Function to kill script Func _Quit() Exit EndFunc ;==>_Quit I basically replaced my $functions with the ones listed and so far so good ... the only other addition I did was to add a 'combat' line in where it says above "Script could be doing other things" Func _Attacks1(); 360 Seconds Dim $array[48] = ['8', '7', '6', '5', '4', '3', '8', '9', '8', '7', '6', '5', '4', '3', '8', '9', '8', '7', '6', '5', '4', '3', '8', '9', _ '8', '7', '6', '5', '4', '3', '8', '9', '8', '7', '6', '5', '4', '3', '8', '9', '8', '7', '6', '5', '4', '3', '8', '9' ] For $X = 0 To UBound($array) - 1 ControlSend($hWin, "", "", $array[$X]) Sleep(2000) Next EndFunc ;==>_Attacks1 Everything runs great except that the style of playing I do, I want to be able to 'pause' my attack funtion but still have my buff timer go off..... This way I can gather all the mobs I want before I start attacking.. I'd like to bind this to a 'hotkey' if possible...........The only 'pause' I found, pauses the entire script which will throw off my timer.... suggestions??? Thanks much ... Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 23, 2008 Share Posted January 23, 2008 (edited) Here's a basic addition to the demo timer script. It just adds two flag variables, $StartStop_1 and $StartStop_2, to control the first two timers with F6 and F7 respectively. It also demonstrates using one function to handle more than one HotKey: expandcollapse popupHotKeySet("{ESC}", "_Quit") HotKeySet("{F6}", "_StartStop") HotKeySet("{F7}", "_StartStop") ; Timers Global $REDCooldown1 = 1000 Global $REDCooldown1Temp = TimerInit() Global $REDCooldown2 = 2000 Global $REDCooldown2Temp = TimerInit() Global $REDCooldown3 = 3000 Global $REDCooldown3Temp = TimerInit() Global $REDCooldown4 = 4000 Global $REDCooldown4Temp = TimerInit() ; Timer Start/Stop flags Global $StartStop_1 = False, $StartStop_2 = False ; Open notepad to monitor test Run("notepad.exe") WinWait("Untitled - Notepad") $hWin = WinGetHandle("Untitled - Notepad") If Not WinActive($hWin) Then WinActivate($hWin) WinWaitActive($hWin) ; Check timer status every 100ms AdlibEnable("_TimerDispatch", 100) ; Script could be busy doing other things here... While 1 Sleep(20) WEnd ; Function to perform timed operations Func _TimerDispatch() If $REDCooldown4 <= TimerDiff($REDCooldown4Temp) Then ControlSend($hWin, "", "Edit1", "4{ENTER}") $REDCooldown4Temp = TimerInit() EndIf If $REDCooldown3 <= TimerDiff($REDCooldown3Temp) Then ControlSend($hWin, "", "Edit1", "3{ENTER}") $REDCooldown3Temp = TimerInit() EndIf ; Timer 2 is conditionally controlled by F7 If $StartStop_2 Then If $REDCooldown2 <= TimerDiff($REDCooldown2Temp) Then ControlSend($hWin, "", "Edit1", "2{ENTER}") $REDCooldown2Temp = TimerInit() EndIf EndIf ; Timer 1 is conditionally controlled by F6 If $StartStop_1 Then If $REDCooldown1 <= TimerDiff($REDCooldown1Temp) Then ControlSend($hWin, "", "Edit1", "1{ENTER}") $REDCooldown1Temp = TimerInit() EndIf EndIf EndFunc ;==>_TimerDispatch ; Function to kill script Func _Quit() Exit EndFunc ;==>_Quit ; Start/Stop selected timers Func _StartStop() Switch @HotKeyPressed Case "{F6}" $StartStop_1 = Not $StartStop_1 Case "{F7}" $StartStop_2 = Not $StartStop_2 EndSwitch EndFunc ;==>_StartStop Hope that helps. Edited January 23, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
d00dness Posted January 23, 2008 Author Share Posted January 23, 2008 It does help... thanks much .. I apprecaite the help... 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