Bot-Factory 602 Posted May 16, 2014 Report Share Posted May 16, 2014 Hello. I want to share a small script with you. That's something I'm using in almost all my bots. Goals:Prevent users from hitting start button multiple times.Wait and repeat a command until stop button is pressed.Stop everything with Stop button. Challenge: In the past I was using "stop script()" for this task. But Ubot V5 has changed the behavior of the Stop script command. So this is not longer usable because it will stop other threads as well. So I changed my default code a little bit. I also implemented a method so that the status code is not longer updated after the STOP button has been pressed. ui stat monitor("Status", #status)on load("Bot Loaded") { set(#running, "false", "Global") set(#stop, "true", "Global")}ui button("Start") { if($comparison(#running, "=", "true")) { then { alert("Task is already running. Please wait.") } else { set(#running, "true", "Global") set(#stop, "false", "Global") statusupdate("Starting Bot....") loop while($comparison(#stop, "=", "false")) { comment("YOUR COMMAND HERE") set(#waitcounter, 5, "Global") loop(#waitcounter) { statusupdate("Waiting: {#waitcounter}") wait(1) decrement(#waitcounter) } } set(#status, "Bot stopped.", "Global") set(#running, "false", "Global") } }}ui button("Stop") { if($comparison(#stop, "!=", "true")) { then { set(#stop, "true", "Global") set(#status, "Stopping Bot....", "Global") } }}define statusupdate(#text) { if($comparison(#stop, "!=", "true")) { then { set(#status, #text, "Global") } }} I hope this is helpful for some of you. CheersDan 3 Quote Link to post Share on other sites
automaton 2 Posted May 16, 2014 Report Share Posted May 16, 2014 good stuff Thanx Quote Link to post Share on other sites
the_way 52 Posted May 16, 2014 Report Share Posted May 16, 2014 thanks Dan, i had someone using a program i made, and i couldn't believe the amount of times they kept clicking the button. anyway it broke, and this is very handy cheers mate. Quote Link to post Share on other sites
HaHaItsJake 25 Posted June 12, 2014 Report Share Posted June 12, 2014 (edited) Hey Dan, I'll be using your code now in a lot of my bots. LOL I like the UI Stop/start way better then the bot's own Start/stop. I'm new, and might need help. Got a way to Multi thread it by chance? I just injected the threading like so, and it worked.. lol ui drop down("Threads", "1,2,3,4,5,6,7,8,9,10", #Threads) ui stat monitor("Status", #status) on load("Bot Loaded") { set(#running, "false", "Global") set(#stop, "true", "Global") } ui button("Start") { if($comparison(#running, "=", "true")) { then { alert("Task is already running. Please wait.") } else { set(#running, "true", "Global") set(#stop, "false", "Global") statusupdate("Starting Bot....") loop while($comparison(#stop, "=", "false")) { set(#threads to run, #Threads, "Global") set(#used threads, 0, "Global") loop(#Threads) { loop while($comparison(#used threads, ">=", #threads to run)) { wait(1) } comment("Increment Opens a new thread") thread { in new browser { navigate("google.com", "Wait") decrement(#used threads) } } } set(#waitcounter, 5, "Global") loop(#waitcounter) { statusupdate("Waiting: {#waitcounter}") wait(1) decrement(#waitcounter) } } set(#status, "Bot stopped.", "Global") set(#running, "false", "Global") } } } ui button("Stop") { if($comparison(#stop, "!=", "true")) { then { set(#stop, "true", "Global") set(#status, "Stopping Bot....", "Global") } } } define statusupdate(#text) { if($comparison(#stop, "!=", "true")) { then { set(#status, #text, "Global") } } }Anyway to connect the "Start" to a UI HTML panel? (SSUB V6.0 by chance) Having trouble figuring that part out.Thanks, JakeEDITED: I keep answering my own questions after I post them LOL. Thought I would share to anyone who needs this information, The threading works perfect, if you have another way please let me know. I just took the code from Button Start and Button Stop and put them in a define, then made SSUB V6 define start and stop to the define's I made. Now works like that. Just hoping nothing breaks as I keep moving forward. EDIT: The first code was incorrect for threading with the button. It would keep looping out and adding a thread every loop. I had to take out the Loop While, due to it would be 60+ seconds before the threads opened. The correct code is down below, can add in monitor's threw out your code. "Making account, captcha, etc" ui drop down("Threads", "1,2,3,4,5,6,7,8,9,10", #Threads) ui stat monitor("Status", #status) on load("Bot Loaded") { set(#running, "false", "Global") set(#stop, "true", "Global") } ui button("Start") { if($comparison(#running, "=", "true")) { then { alert("Task is already running. Please wait.") } else { set(#running, "true", "Global") set(#stop, "false", "Global") set(#threads to run, #Threads, "Global") set(#used threads, 0, "Global") statusupdate("Starting Bot....") loop(#Threads) { loop while($comparison(#used threads, ">=", #threads to run)) { wait(1) } increment(#used threads) thread { in new browser { navigate("google.com", "Wait") decrement(#used threads) } } } set(#status, "Bot stopped.", "Global") set(#running, "false", "Global") } } } ui button("Stop") { if($comparison(#stop, "!=", "true")) { then { set(#stop, "true", "Global") set(#status, "Stopping Bot....", "Global") } } } define statusupdate(#text) { if($comparison(#stop, "!=", "true")) { then { set(#status, #text, "Global") } } } Edited June 12, 2014 by HaHaItsJake Quote Link to post Share on other sites
solstudioim 4 Posted December 15, 2014 Report Share Posted December 15, 2014 Awesome that I found this tutorial. Thanks Dan for sharing!! Quote Link to post Share on other sites
botsimmer 16 Posted January 18, 2015 Report Share Posted January 18, 2015 Excellent - thanks 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.