Jump to content
UBot Underground

How does "pause script" and "stop script" work?


Recommended Posts

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....

Link to post
Share on other sites
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.

Link to post
Share on other sites
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!

Link to post
Share on other sites

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
        }
    }
}
  • Like 1
Link to post
Share on other sites
  • 2 weeks later...

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 ;)

Link to post
Share on other sites
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
}
Link to post
Share on other sites

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.

Link to post
Share on other sites

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...

Link to post
Share on other sites
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 by zenos
Link to post
Share on other sites

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")
}
  • Like 12
Link to post
Share on other sites
  • 1 month later...
  • 2 years later...

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... Cheers

Just to let guys know it works great with the UI editor too... :-)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...