f0xh4x0r Posted July 5, 2009 Share Posted July 5, 2009 Heres my code Global $loop2 = 1 Global $loop = 1 $GameTitle = "MyGame" WinWaitActive($GameTitle) Call("Gameloop") Call("Gameloop2") if $loop = 1 Then Gameloop() EndIf Func Gameloop() $loop = $loop + 1 ControlSend($GameTitle, "", "", "{SPACE}" ) Sleep(10) Call("Gameloop") EndFunc if $loop2 = 100 Then Gameloop2() EndIf Func Gameloop2() $loop2 = $loop2 - 1 ControlSend($GameTitle, "", "", "{SPACE}" ) Sleep(10) Call("Gameloop2") EndFunc Autoit does not like infinite loops. It gives an error and crashes after about 1 minute of this script running. So I tried to get it to go back and forth between two functions to no avail. Can anyone help me out here im sure its something simple. Thanks for the help! Link to comment Share on other sites More sharing options...
monoceres Posted July 5, 2009 Share Posted July 5, 2009 That's not an infinite loop, that's an infinite recursion which makes every language error out sooner or later. Try 'While' instead. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
f0xh4x0r Posted July 5, 2009 Author Share Posted July 5, 2009 (edited) Recursion level exceeded still not working. Any other ideas? Edited July 5, 2009 by f0xh4x0r Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 5, 2009 Share Posted July 5, 2009 Yes. Use a while loop like monoceres said. Link to comment Share on other sites More sharing options...
f0xh4x0r Posted July 5, 2009 Author Share Posted July 5, 2009 Global $loop2 = 1 Global $loop = 1 $GameTitle = "Game" WinWaitActive($GameTitle) Call("Gameloop") Call("Gameloop2") While $loop = 1 Then Gameloop() Wend Func Gameloop() $loop = 1 ControlSend($GameTitle, "", "", "{SPACE}" ) Sleep(10) Call("Gameloop") EndFunc Like I said, still not working, any one else? Thanks for the help so far guys Link to comment Share on other sites More sharing options...
crashdemons Posted July 5, 2009 Share Posted July 5, 2009 (edited) You syntax is truly odd.Perhaps these will do something similar to what you may want.A conditional while loop (infinite here) that performs operations on each loopGlobal $loop=True Global $GameTitle = "Game" Global $ControlID = "Edit1"; change this! WinWaitActive($GameTitle) While $loop ControlSend($GameTitle, "", $ControlID, "{SPACE}" ) Sleep(10) ;... WEndorA conditional while loop (infinite here) that executes a function on each loopGlobal $loop=True Global $GameTitle = "Game" Global $ControlID = "Edit1"; change this! WinWaitActive($GameTitle) While $loop Function1() ;... WEnd Func Function1() ControlSend($GameTitle, "", $ControlID, "{SPACE}" ) Sleep(10) EndFuncorA while loop that completes a function before each loop and uses it's return value as the condition. (infinite here)Global $loop=True Global $GameTitle = "Game" Global $ControlID = "Edit1"; change this! WinWaitActive($GameTitle) While Function1() ;do something else! :D WEnd Func Function1() Global $loop If Not $loop Then Return False ControlSend($GameTitle, "", $ControlID, "{SPACE}" ) Sleep(10) Return True EndFuncAll of which *should* be valid, but are useful under different conditions and each have their advantages depending on the situation.I would probably suggest starting with the first example.The last example is more useful for actually checking the outcome of a function for a condition - it doesn't really apply here.Note 1: I didn't include anything to change $loop to false - and since you didn't indicate what your practical stopping conditions are, you'll be completing that part yourself.Note 2: This also assumes you want to send to an actual control.If you just want to send to a window without controls (like a game) you might consider Send(...)If you want to set the text of a control (like an edit box), try ControlSetText(...).Note 3: There's no condition in these examples that checks whether the windows is STILL active- you may find this necessary to add. Edited July 5, 2009 by crashdemons My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.) Link to comment Share on other sites More sharing options...
f0xh4x0r Posted July 5, 2009 Author Share Posted July 5, 2009 Thank you so much for that, when I get home I will test those scripts and let you know what happens! Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 5, 2009 Share Posted July 5, 2009 (edited) Well test this too.. just another variation of the examples posted here.. $GameTitle = "MyGame" $ControlID = "Edit1"; change this! WinWaitActive($GameTitle) While 1 ControlSend($GameTitle, "", $ControlID, "{SPACE}" ) Sleep(10) WEnd Edited July 5, 2009 by snowmaker - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. 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