Danger111 Posted April 14, 2013 Share Posted April 14, 2013 Hello For example i have a script like this: While 1 Mousemove(0,0, 10) Mousemove(10,10,10) Wend What i want to do is, to make the script break this While loop and Mousemove(20,20,10) every X amount of time, (Let's say every 60 seconds). I mean even if the while loop is not ended so, the script has just moved the mouse to 0,0 coordinates (Mousemove(0,0,10) but (60 seconds) has passed so script won't move mouse to 10,10 coordinates (Mousemove(10,10,10) and will move mouse to 20,20 coordinates and the start the while loop from the begginning. Thanks! Link to comment Share on other sites More sharing options...
FireFox Posted April 14, 2013 Share Posted April 14, 2013 Hi, Take a look at the Sleep function. Br, FireFox. Link to comment Share on other sites More sharing options...
TheSaint Posted April 14, 2013 Share Posted April 14, 2013 (edited) You may need to look at the Sleep command and maybe using addition with coordinates as variables. i.e. Similar to the following perhaps $a = 0 $b = 0 $c = 0 While 1 Sleep(1000) MouseMove($a, $b, $c) $a = $a + 10 $b = $b + 10 $c = $c + 10 If $c = 500 Then ExitLoop Wend Edited April 14, 2013 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
water Posted April 14, 2013 Share Posted April 14, 2013 Can you please tell us the purpose of this script? Do you just want to learn AutoIt or do you need to solve a real problem? If we know what you want to achive we might suggest an easier and even more reliable way. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki  Link to comment Share on other sites More sharing options...
Danger111 Posted April 14, 2013 Author Share Posted April 14, 2013 (edited) Okay, you understood my problem differently guys. I brought that mousemove while loop as an example. I will expalin what i want to know better For Example i have a script whith main while loop: While 1 ; a whole bunch of script here with If statements, for loops, and so on Wend I want the script to stop the while loop and for example Msgbox(0, 'Title', "Text"), every 60 seconds and then start the while loop again. Okay, if it's still confusing let me introduce another example (it seems Mousemove have lost you): Script: While 1 Msgbox(0, "Box1", "Box2") Sleep(1000) Msgbox(0, "Box2", "Box2") Wend Here we have a script, which makes first a Msgbox appear wth title and text: Box1 and after that a Msgbox with title and text: Box2 I want every 60 seconds the script to make a Msgbox with title and Text: Box3 (Msgbox(0, "Box3", "Box3")) And finally why i am asking this question: I have a script that does something continuously with While 1 Loop (I don't want to upload a whole script), and i wan't to make my script to break the This while loop every 60 seconds then do something for example move mouse and start the while loop all over again. Sorry for my bad english and if i was not able to explain my problem clearly Thanks! Edited April 14, 2013 by Danger111 Link to comment Share on other sites More sharing options...
JohnOne Posted April 14, 2013 Share Posted April 14, 2013 No-one is lost except yourself. You gave mousemove as example, people replied using your example. use sleep and perhaps a function AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FireFox Posted April 14, 2013 Share Posted April 14, 2013 While 1 Mousemove(0,0, 10) Mousemove(10,10,10) Sleep(60000) MsgBox(0, "", "That was so hard.") Wend Link to comment Share on other sites More sharing options...
JohnOne Posted April 14, 2013 Share Posted April 14, 2013 While 1 Mousemove(0,0, 10) Mousemove(10,10,10) ;Sleep(60000) MsgBox(0, "wait 60 seconds", "Or click ok to do again", 60) Wend AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FireFox Posted April 14, 2013 Share Posted April 14, 2013 I thought about that option too, but I was too lazy as the OP is to add it. Link to comment Share on other sites More sharing options...
Danger111 Posted April 15, 2013 Author Share Posted April 15, 2013 (edited) Is it so hard to understand what i am asking? The script FireFox replied:While 1 Mousemove(0,0, 10) Mousemove(10,10,10) Sleep(60000) MsgBox(0, "", "That was so hard.") WendThis script moves mouse to 0,0 then to 10,10 and waits 60seconds i could do that myself too. What i want to do is, that when i have a While loop, ok let's say that Mousemove loop:While 1 Mousemove(0,0, 10) Mousemove(10,10,10) WendI want every 60 seconds script to STOP/BREAK (call whatever you like) this WHILE LOOP then do something else (For example move mouse on random coordinates Say X, Y only once) and START the WHILE LOOP again.Thanks! Edited April 15, 2013 by Danger111 Link to comment Share on other sites More sharing options...
Danger111 Posted April 15, 2013 Author Share Posted April 15, 2013 (edited) Okay, I solved the half of my Problem: It seems i had to use AdlibRegister function here is my script:HotKeySet("E", "_Exit") AdlibRegister("_Break", 6000) while 1 MouseMove(0,0,10) sleep(1000) MouseMove(1887, 977,10) WEnd Func _Break() Mousemove(889, 471,10) EndFunc Func _Exit() Exit EndFunc But the problem is when the Adlib uses _Break function the While loop continues from where he stopped, i want after the Break function while loop to start from the beginning. Is it possible? Thanks! Edited April 15, 2013 by Danger111 Link to comment Share on other sites More sharing options...
Clark Posted April 15, 2013 Share Posted April 15, 2013 Put the while loop in a function. Leave the function when you wish, then call the function again. Link to comment Share on other sites More sharing options...
Danger111 Posted April 15, 2013 Author Share Posted April 15, 2013 (edited) Hmm i have tried it like this: HotKeySet("E", "_Exit") AdlibRegister("_Break", 6000) _start() Func _Start() while 1 MsgBox(0, "Box1", "Box1") MsgBox(0, "Box2", "Box2") MsgBox(0, "Box3", "Box3") WEnd EndFunc Func _Break() MsgBox(0, "Box4", "Box4") _start() EndFunc Func _Exit() Exit EndFunc Resut: After first 6 seconds Box4 appears and then the while loop starts from begginging (From Box1), but after first 6 seconds Box4 never appears it's like AdlibRegister stopped working, any ideas? Thanks! Edited April 15, 2013 by Danger111 Link to comment Share on other sites More sharing options...
FireFox Posted April 15, 2013 Share Posted April 15, 2013 Is it so hard to understand what i am asking?I would say yes if I was not the only one to answer wrongly but it's not the case.I doubt the script purpose is legit (to the forum rules)... Link to comment Share on other sites More sharing options...
water Posted April 15, 2013 Share Posted April 15, 2013 That's what I asked for in post #4. But the OP refused to answer my question. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki  Link to comment Share on other sites More sharing options...
Danger111 Posted April 15, 2013 Author Share Posted April 15, 2013 (edited) Whats not legit in asking how to break a Loop every X amount of time and then start it again? Or because i don't want to upload my script you decided that i am writing some hacking program or virus? Anyway from my #13 post i think my question is clear and if you got a solution please reply me. Thanks! Edited April 15, 2013 by Danger111 Link to comment Share on other sites More sharing options...
Bert Posted April 15, 2013 Share Posted April 15, 2013 Whats not legit in asking how to break a Loop every X amount of time and then start it again?Or because i don't want to upload my script you decided that i am writing some hacking program or virus?Anyway from my #13 post i think my question is clear and if you got a solution please reply me.Thanks!No, you refuse to say what you are automating. I too think you are doing something we do not allow here. The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
JohnOne Posted April 15, 2013 Share Posted April 15, 2013 I think adlibregister will interrupt your start function, and cause recursion. You can code your script with different logic, or add a global flag to set in _Break() and reset in _start() and have _start() return to control the recursion. AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Malkey Posted April 15, 2013 Share Posted April 15, 2013 @Danger111 If the replies to this topic has frustrated you, try testing this example for an extended length of time when your a little tired. It should cure you. ; The chance of the AdlibRegister's function returning ; to the loop after any of the If statements to execute ; the following command line is possible, but unlikely. Global $Flag = 1 HotKeySet("E", "_Exit") AdlibRegister("_Break", 6000) _start() Func _Start() While 1 $Flag = 1 MouseMove(0, 0, 10) If $Flag = 0 Then ContinueLoop Sleep(1000) If $Flag = 0 Then ContinueLoop MouseMove(587, 377, 10) If $Flag = 0 Then ContinueLoop MsgBox(0, "Box1", "Box1", 1) If $Flag = 0 Then ContinueLoop MsgBox(0, "Box2", "Box2", 1) If $Flag = 0 Then ContinueLoop MsgBox(0, "Box3", "Box3", 1) WEnd EndFunc ;==>_Start Func _Break() MouseMove(20, 350) MsgBox(0, "Box4", "Box4") $Flag = 0 EndFunc ;==>_Break Func _Exit() Exit 0 EndFunc ;==>_Exit Danger111 1 Link to comment Share on other sites More sharing options...
Danger111 Posted April 15, 2013 Author Share Posted April 15, 2013 (edited) @Malkey Yep, that works exactly as i wanted. Thank you so much. Thanks a lot all of you for spending your time helping me and special thanks to Malkey for solving my problem:) Thanks! Edited April 15, 2013 by Danger111 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