pikablue Posted June 30, 2009 Share Posted June 30, 2009 (edited) Hello, I am very new to the autoit, I always wants to create some kind of scrip to automatically operate my computer without me being on it. Like moving mouse on its own, click, send keys etc. I've searched through the forum and looked into while, do, and for Loop functions. But I don't understand it at all. I know that with While Loop, You need a condition for it to keep looping, how do I set the condition to be every 40 minutes? I want it to loop a set of mouse movements on its own every 40 minutes. Also is it possible for me to disable this loop with a hotkey? AutoItSetOption("MouseClickDelay", 100) AutoItSetOption("MouseClickDownDelay", 100) MouseClick("Left", 300, 790, 2) MouseClick("Left", 400, 650, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 790, 350, 2) Edited June 30, 2009 by pikablue Link to comment Share on other sites More sharing options...
Authenticity Posted June 30, 2009 Share Posted June 30, 2009 Use AdlibEnable instead or better schedule your compiled AutoIt script to execute every 40 minutes (daily, monthly, forever, etc..). If you just want to use it in a loop just make an inner loop to sleep and increase a counter stating the minutes passed since it's began running and terminate it if the counter is 40 and you'll fall back to the outer loop. Something As followed: Global $iCounter Global $fLoop = True HotKeySet{'{ESC}', 'Close') While $fLoop ; Do Stuff here $iCounter = 0 While $fLoop $iCounter += 1 Sleep(1000) If $iCounter = 40 Then ExitLoop WEnd WEnd Func Close() $fLoop = False ; Or Exit EndFunc Link to comment Share on other sites More sharing options...
pikablue Posted June 30, 2009 Author Share Posted June 30, 2009 (edited) Thank you so much for the quick reply, but would you please explain more detail in how this loop works? and what is AdlibEnable you just mentioned? Like break down of each small sections and put them in english lol sorry expandcollapse popupGlobal $iCounter Global $fLoop = True HotKeySet{'{ESC}', 'Close') While $fLoop AutoItSetOption("MouseClickDelay", 100) AutoItSetOption("MouseClickDownDelay", 100) MouseClick("Left", 300, 790, 2) MouseClick("Left", 400, 650, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 790, 350, 2) $iCounter = 0 While $fLoop $iCounter += 1 Sleep(1000) If $iCounter = 40 Then ExitLoop WEnd WEnd Func Close() $fLoop = False ; Or Exit EndFunc So is it like this? but I'm getting an error says HotKeySet{'{ESC}', 'Close') is missing separator character after keyword Edited June 30, 2009 by pikablue Link to comment Share on other sites More sharing options...
Authenticity Posted June 30, 2009 Share Posted June 30, 2009 (edited) Read the help file, it's better and faster with a few grate example in almost every documented function in the bottom of it's description.While <expression> statements ... WEndThe <expression> clause is get checked and interpreted to either false or true before each iteration.Edit: Sorry, my mistake. It's HotKeySet('{ESC}', 'Close') with an opening round parentheses. Edited June 30, 2009 by Authenticity Link to comment Share on other sites More sharing options...
pikablue Posted June 30, 2009 Author Share Posted June 30, 2009 (edited) thanks a bunch, i figure some stuff out. here's what i got: expandcollapse popupGlobal $iCounter Global $fLoop = True HotkeySet("{Esc}", "Close") While $fLoop AutoItSetOption("MouseClickDelay", 100) MouseClick("Left", 300, 790, 2) MouseClick("Left", 400, 650, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) MouseClick("left", 450, 475, 2) MouseClick("left", 475, 350, 2) AutoItSetOption("MouseClickDownDelay", 100) MouseClick("left", 790, 350, 2) $iCounter = 40 While $fLoop $iCounter -= 1 MsgBox(0, "", "Minutes left: " & $iCounter, 1) Sleep(1000*59) If $iCounter = 0 Then ExitLoop WEnd WEnd Func Close() $fLoop = False ; Or Exit EndFunc Hows that ^^. BTW the Esc key works great, except I need to wait til the auto it finishes it's current job, is there anyway for it to terminate autoit forcefully? Edited June 30, 2009 by pikablue Link to comment Share on other sites More sharing options...
bo8ster Posted June 30, 2009 Share Posted June 30, 2009 Use Exit.I use: Func MyExit() ConsoleWrite("Script Stoppted by user") Exit EndFunc ;==>MyExit Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] 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