illmill 87 Posted January 29, 2013 Report Share Posted January 29, 2013 It seems like it should be a simple thing, but I have never gotten these commands to work in ubot. I always put everything inside define commands and then I use the tutorial that TJ created for multithreading. Everything goes inside loops. My bots are a never ending cycle of loops inside other loops and I'm just guessing that these commands wait for a loop to finish or maybe for a command to finish (which also doesn't help me since everything is inside define commands, even the loops. Sooo..... How can I create a button that will either stop or pause my bot? It's annoying that I have to close and reopen everytime I want to stop it. Imagine how my customers will feel. Thanks.... Quote Link to post Share on other sites
AutomationNinja 194 Posted January 29, 2013 Report Share Posted January 29, 2013 Your loops should end after the conditions have been met, such as number of loops or after element appears. The stop command stops the entire script. Quote Link to post Share on other sites
illmill 87 Posted January 29, 2013 Author Report Share Posted January 29, 2013 Your loops should end after the conditions have been met, such as number of loops or after element appears. The stop command stops the entire script.Yeah, that's not really going to work for me. My bots loop thousands of times. And I'm not going to change that because it will defeat the purpose of having a bot. Quote Link to post Share on other sites
VaultBoss 310 Posted January 29, 2013 Report Share Posted January 29, 2013 Yeah, that's not really going to work for me. My bots loop thousands of times. And I'm not going to change that because it will defeat the purpose of having a bot. Switch your LOOPs to LOOP WHILEs and have an comparison within the LOOP against whatever you think may trigger the need to stop the bot.Once such a condition is met, SET the counter index variable of the LOOP WHILE to MAX (or MIN depending on your WHILE condition) and the LOOP will end gracefully... Also, STOP SCRIPT will not work properly if you test the bot and press RUN from the Code View, only from Node View << this is a known bug! Quote Link to post Share on other sites
blumi40 222 Posted January 29, 2013 Report Share Posted January 29, 2013 Try this should work i thing comment("how to use if u push the startbutton trigger the define runaggregate_start if u push the pausebutton trigger the define runaggregate_pause if u push the stopbutton trigger the define runaggregate_stop the define runaggregate_start got two values the value 0 means if your script is running and in pausemode and u push the playbutton the script starts exact there where u was bring it before in to pausemode ->no initialscript place your check_aggregates behind every buttonklick or navigate function") define check_aggregates { if(#runvar = 2) { then { runaggregate_pause() } else if(#runvar = 3) { runaggregate_stop() } else if(#runvar = 1) { runaggregate_start() } } } divider define runaggregate_start { if(#runvar = 2) { then { set(#runvar, 0, "Global") } else { comment("your initialdefnie here") set(#runvar, 0, "Global") } } } define runaggregate_pause { set(#runvar, 2, "Global") runvar() } define runaggregate_stop { set(#runvar, 3, "Global") runvar() } define runvar { loop while(#runvar = 2) { wait(1) } if(#runvar = 3) { then { stop script } } } 1 Quote Link to post Share on other sites
AutomationNinja 194 Posted January 29, 2013 Report Share Posted January 29, 2013 Exactly! Quote Link to post Share on other sites
zenos 13 Posted February 12, 2013 Report Share Posted February 12, 2013 I'm sorry but i don't understand how to pause or stop script.... My button play works like this in ui html panel : ui html panel ("<!DOCTYPE html><html> <input type=\"image\" onclick=\"ubot.runScript(\'Load project()\')\" src=\"http://tdiv.free.fr/commente.png\"> <input type=\"image\" onclick=\"ubot.runScript(\'Stop project()\')\" src=\"http://tdiv.free.fr/stop.png\"> </body> </html>", 500) Define Load project { if(#plateforme = "wp1") { then { loop($list total(%Clean List)) { navigate($next list item(%Clean List), "Wait") wait for browser event("Everything Loaded", "") } } define Stop project { stop script } The two buttons work correctly but it restart the loop after 3 seconds when i clic the stop buttonstop. So i know that you know that, but how can i do with your method in my script ? I cannot understand... And how can i integrate the pause button two in my script. It's been three days i try to fix it... Sorry and thanks for your answer Quote Link to post Share on other sites
zenos 13 Posted February 13, 2013 Report Share Posted February 13, 2013 If you use STOP script then when you PLAY the script again, it runs from the beginning of the script flow but if you use PAUSE then it continues from the flow where it left off. So, if it PAUSED at command line 50, then it will continue from there when you click PLAY. Thank you but i know that. My question is : how can i make a play, pause and stop button to integrate in my ui html panel here ? ui html panel ("<!DOCTYPE html><html> <input type=\"image\" onclick=\"ubot.runScript(\'Load project()\')\" src=\"http://tdiv.free.fr/commente.png\"> <input type=\"image\" onclick=\"ubot.runScript(\'Stop project()\')\" src=\"http://tdiv.free.fr/stop.png\"> </body> </html>", 500) Define Load project { if(#plateforme = "wp1") { then { loop($list total(%Clean List)) { navigate($next list item(%Clean List), "Wait") wait for browser event("Everything Loaded", "") } } define Stop project { stop script } Quote Link to post Share on other sites
magoo 31 Posted February 13, 2013 Report Share Posted February 13, 2013 Within a define create a variable named pause set true and then within another define create another variable named pause set false call these from a pause and an unpause buttons from the ui panel. Now create another define and call it pause and place a pause command in a loop while with the condition being " pause true". Now place you pause command throughout your script any wear a navigate action or the top of any loop, basically anyplace the script does something. Quote Link to post Share on other sites
zenos 13 Posted February 13, 2013 Report Share Posted February 13, 2013 Hi magoo and thanks for your answer,I'm sorry but i don't understand, I'm a real noob in ubot and I'm french... I did this but it doesn't work... ui button("pause") { define true(#pause) { } } ui button("unpause") { define false(#pause) { } } define pause { loop while("pause true") { } loop($list total(%Clean Url List)) { navigate($next list item(%Clean Url List), "Wait") wait for browser event("Everything Loaded", "") } am i in the right way ? It doesn't seem to work... That makes me crasy... Quote Link to post Share on other sites
magoo 31 Posted February 13, 2013 Report Share Posted February 13, 2013 Hi zenos, I'm away from my computer, just have my phone with me. When I get back I will post what you need here. 1 Quote Link to post Share on other sites
zenos 13 Posted February 14, 2013 Report Share Posted February 14, 2013 (edited) Hi zenos, I'm away from my computer, just have my phone with me. When I get back I will post what you need here. in french i say : Je te kiffe mec ! (you rock dude) Edited February 14, 2013 by zenos Quote Link to post Share on other sites
magoo 31 Posted February 14, 2013 Report Share Posted February 14, 2013 Sorry about my previous post it was wrong, here is a stop pause script that should do what you're after. Paste this in ubot anf hit the start button and you will see how it works. ui html panel("<button onclick=\"ubot.runScript(\'run_bot()\')\">Start</button> <button onclick=\"ubot.runScript(\'stopbot()\')\">Stop</button> <button onclick=\"ubot.runScript(\'pausebot()\')\">Pause</button> <button onclick=\"ubot.runScript(\'un_pausebot()\')\">Un-Pause</button>", 300) define run_bot { load html("Hey") wait(1) Stop Pause Check() load html("I") wait(1) Stop Pause Check() load html("Hope") wait(1) Stop Pause Check() load html("This") wait(1) Stop Pause Check() load html("Helps") wait(1) Stop Pause Check() load html("You") wait(1) Stop Pause Check() load html("Understand") Stop Pause Check() load html("How") Stop Pause Check() load html("To") Stop Pause Check() load html("Pause") Stop Pause Check() load html("and Un Pause") Stop Pause Check() load html("Your Bot") } define Check Stop { if($comparison(#stopnow, "=", $true)) { then { set(#stopnow, $false, "Global") stop script } else { } } } define Check Pause { if($comparison(#pause, "=", $true)) { then { wait(1) Check Pause() } else { } } } define Stop Pause Check { Check Stop() Check Pause() } define pausebot { set(#pause, $true, "Global") } define un_pausebot { set(#pause, $false, "Global") } define stopbot { set(#stopnow, $true, "Global") } 12 Quote Link to post Share on other sites
zenos 13 Posted February 14, 2013 Report Share Posted February 14, 2013 Thank you man, you're the best. It works (i have clik on your "like this" button) Quote Link to post Share on other sites
magoo 31 Posted February 15, 2013 Report Share Posted February 15, 2013 No worries, glad it got you sorted out. Quote Link to post Share on other sites
illmill 87 Posted February 18, 2013 Author Report Share Posted February 18, 2013 and I'm french...LOL... Sorry, I don't know why, but I literally laughed out loud when I read this. 1 Quote Link to post Share on other sites
julius 5 Posted March 21, 2013 Report Share Posted March 21, 2013 Thanks Magoo for posting this.. Just what Im looking for... Quote Link to post Share on other sites
Security 17 Posted March 21, 2013 Report Share Posted March 21, 2013 LOL... Sorry, I don't know why, but I literally laughed out loud when I read this. lololol so did i.. 1 Quote Link to post Share on other sites
Evernano 2 Posted February 21, 2016 Report Share Posted February 21, 2016 Thanks Mangoo it works great dude... just what i need for all my defines it works great... tested on a very big bot I have... CheersJust to let guys know it works great with the UI editor too... :-) Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.