darkjoscha Posted November 21, 2006 Share Posted November 21, 2006 okay first of all, i like to say "hi", and greetings to the creater of autoit, its a really cool programno to my script i planing to make.its a gaming script so i need to start it with a hotkey, than it needs to perform an action every 180sec (more/less)and during this time it needs to just send a few "keycommands".okay this is what i have so farGlobal $keyHotkeySet ("{F9}", "Start")HotkeySet ("{F8}", "Stop");HotkeySet ("{F7}", "Def")$x = 0While 1 Sleep (100)WEndFunc Start() If WinExists ("Do") Then WinActivate ("Do") Def() EndifEndFuncFunc Def() ; this function needs to be performed every 180sec WinActivate ("Do") send ("2") Atk()EndFuncFunc Atk() ; and this function every 10sec WinActivate ("Do") send ("t") sleep (1000) send ("a") sleep ("10000") send ("1") send ("1")EndFuncFunc Stop() MsgBox(4096, "Stop", "Script stopped!", 2) ExitEndFuncso i need some kind of a loop that just performs def() every 180sec and atk() every 10sec, time started from the first perform of def().my problem is the "time" i have no clou how to count in realtime, i know that i can count with variables like $x = 1$x + 1 = 2 ... so onso it would be kind if somebody could help me with this thanx a lot Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 21, 2006 Moderators Share Posted November 21, 2006 For time options you can look at TimerInit()/TimerDiff() ... It's calculated in Milliseconds, so to get the difference in seconds it would be TimerDiff($var) / 1000. You can also take a look at AdlibEnable(), as that will break from the current function at a set millisecond time, and do whatever function you sent it to. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
darkjoscha Posted November 21, 2006 Author Share Posted November 21, 2006 thx now it works, but now i have another problemthats the script:Global $keyHotkeySet ("{F9}", "Start")HotkeySet ("{F8}", "Stop");HotkeySet ("{F7}", "pause")$x = 0$begin = 0$def = 0While 1 Sleep (100)WEndFunc Start() If WinExists ("Do") Then WinActivate ("Do") def() EndifEndFuncFunc def() WinActivate ("Do") send ("22") sleep (5000) $begin = TimerInit() send ("1") atk()EndFuncFunc atk() WinActivate ("Do") send ("t") sleep (2000) send ("aaa") sleep (6000) send ("111") sleep (1000) send ("111") wait()EndFuncFunc wait() $dif = TimerDiff($begin) if $dif > 95000 Then def()Elseif $dif < 95000 Then atk()EndifEndFuncFunc Stop() send ("{Enter}") sleep ("1000") send (".") ;MsgBox(4096, "Stop", "Script gestoppt!", 2) ExitEndFuncthe problem is, that when the program runs for a certain time i get a error msg "that the limit of recursion has been exeded" or something like this... any idea how i can get rid of this? so that the programm will runs dan runs and runs ^^ Link to comment Share on other sites More sharing options...
Developers Jos Posted November 21, 2006 Developers Share Posted November 21, 2006 (edited) You are not letting Func(s) end., Start() calls Def() Def() calls atk() atk() calls wait() wait(0 calls def() or atk() <== start of the recursion Edited November 21, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
darkjoscha Posted November 21, 2006 Author Share Posted November 21, 2006 so what do i have to do excatly?here is the errormsg again:C:\.....au3 (46) : ==> Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.: atk() Link to comment Share on other sites More sharing options...
Developers Jos Posted November 21, 2006 Developers Share Posted November 21, 2006 (edited) so what do i have to do excatly?Learn how to program ?... Rethink your logic and let a FUNC...ENDFUNC finish in stead of always calling another FUNC. When a FUNC ends it will return to the spot it was called from. Edited November 21, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
darkjoscha Posted November 21, 2006 Author Share Posted November 21, 2006 oh man... can i have another clou ... i testet this but not working Func atk() WinActivate ("Do") send ("t") sleep (2000) send ("aaa") sleep (6000) send ("111") sleep (1000) send ("111") wait() EndFunc Func wait() $dif = TimerDiff($begin) if $dif > 95000 Then def() ;Elseif $dif < 95000 Then ; atk() Endif EndFunc than in wait() it should return to atk() right? but thats not the case... dont know where it goes... but not to atk()... Link to comment Share on other sites More sharing options...
Developers Jos Posted November 21, 2006 Developers Share Posted November 21, 2006 oh man... can i have another clou ... Isn't this really what you want ? expandcollapse popupGlobal $key HotKeySet("{F9}", "Start") HotKeySet("{F8}", "Stop") ;HotkeySet ("{F7}", "pause") $x = 0 $begin = 0 $def = 0 While 1 Sleep(100) WEnd Func Start() If WinExists("Do") Then WinActivate("Do") Send("22") Sleep(5000) $begin = TimerInit() Send("1") While 1 WinActivate("Do") Send("t") Sleep(2000) Send("aaa") Sleep(6000) Send("111") Sleep(1000) Send("111") $dif = TimerDiff($begin) If $dif > 95000 Then Return WEnd EndIf EndFunc ;==>Start Func Stop() Send("{Enter}") Sleep("1000") Send(".") ;MsgBox(4096, "Stop", "Script gestoppt!", 2) Exit EndFunc ;==>Stop SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
darkjoscha Posted November 22, 2006 Author Share Posted November 22, 2006 (edited) thx a lot, a few questions this line "If $dif > 95000 Then Return" the return points to where? the problem is that the while loop doesn seems to work right, well i try a bit okay i tested this Func Start() If WinExists("Do") Then WinActivate("Do") Send("22") Sleep(5000) $begin = TimerInit() Send("1") $dif = TimerDiff($begin) While $dif < 95000;1 WinActivate("Do") Send("t") Sleep(2000) Send("aaa") Sleep(6000) Send("111") Sleep(1000) Send("111") $dif = TimerDiff($begin) ;If $dif > 95000 Then Return WEnd EndIf EndFunc this works a few times, but after a few loops the script does nothing Edited November 22, 2006 by darkjoscha Link to comment Share on other sites More sharing options...
darkjoscha Posted November 22, 2006 Author Share Posted November 22, 2006 okay the prolbem was, that after $dif < 95000 is right the script wont go again to func start() so i added the start() again at the end of the func start(). so it works, but the question now ist for how long... next task for me is to build a pause hotkey into it i give my best^^ 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