Chris M 55 Posted June 13, 2015 Report Share Posted June 13, 2015 Hey guys,I've never used multi-threading before. Wanted to experiment with it and used another example from TJ here in the forums and just tried to copy over mycode and mix n match and it created a TON of errors so I cleaned up the code again and took out the crap I came up with Can anyone fix this and make it multi-threaded so I have an idea of how to do it? on load("Bot Loaded") { plugin command("Advanced Ubot.dll", "hide menu strip (this app)", "True") clear cookies } set(#currently doing,"idle..","Global") ui text box("Bitly Username",#login) ui text box("Bitly API Key",#apikey) ui text box("Insert URL Here (Only use www.domain.com )",#url) ui button("Start") { plugin command("Advanced Ubot.dll", "main button click", "Run") } ui stat monitor("<b>Status:</b>",#currently doing) set(#currently doing,"Downloading User Agents","Global") download file("http://techpatterns.com/downloads/firefox/useragentswitcher.xml","{$special folder("Application")}\\useragentswitcher.xml") wait(1) clear list(%Useragents) clear list(%linkinjectionsites) add list to list(%Useragents,$list from text($find regular expression($read file("{$special folder("Application")}\\useragentswitcher.xml"),"(?<=useragent=\").*?(?=\")")," "),"Delete","Global") set(#currently doing,"Saving User Agents","Global") save to file("{$special folder("Application")}\\Useragents.txt",%Useragents) set(#currently doing,"Picking Random User Agent","Global") set(#user_agent,$random list item($list from file("{$special folder("Application")}\\Useragents.txt")),"Global") clear list(%newlycreatedbitlys) add list to list(%linkinjectionsites,$list from text("http://sthm.temple.edu/tellafriend.php?url={#url} http://sunsite3.berkeley.edu:9876/help/urlstatusgo.html?col=staff&url={#url} http://ucblibrary3.berkeley.edu:9876/help/urlstatusgo.html?col=library&url={#url} http://bernco.gov:8765/help/urlstatusgo.html?col=myindex&url={#url} http://www.cathedralcity.gov/redirect.aspx?url={#url} http://cherokeecounty-nc.gov/redirect.aspx?url={#url} http://www.evansville.in.gov/redirect.aspx?url={#url} http://transtats.bts.gov/exit.asp?url={#url}",$new line),"Delete","Global") set(#currently doing,"Creating Bitly\'s","Global") loop($list total(%linkinjectionsites)) { set(#returnedbitlylink,$BITLY SHORTEN URL($next list item(%linkinjectionsites)),"Global") add item to list(%newlycreatedbitlys,#returnedbitlylink,"Delete","Global") } set(#currently doing,"Creating TinyURLs","Global") loop($list total(%linkinjectionsites)) { set(#returnedtinyurllink,$TinyURL($next list item(%linkinjectionsites)),"Global") add item to list(%newlycreatedbitlys,#returnedtinyurllink,"Delete","Global") } set(#currently doing,"Creating Is.gd Links","Global") loop($list total(%linkinjectionsites)) { set(#returnedIsgdlink,$Isgd SHORTEN URL($next list item(%linkinjectionsites)),"Global") wait(1) add item to list(%newlycreatedbitlys,#returnedIsgdlink,"Delete","Global") } define $BITLY SHORTEN URL(#DEF URL) { return($trim($read file("http://api.bitly.com/v3/shorten?login={#login}&apiKey={#apikey}&longUrl={$plugin function("SocketCommands.dll", "$url encode", #DEF URL)}&format=txt"))) } define $Isgd SHORTEN URL(#DEF URL) { return($trim($read file("http://is.gd/create.php?format=simple&url={$plugin function("SocketCommands.dll", "$url encode", #DEF URL)}"))) } define $TinyURL(#DEF URL) { return($trim($read file("http://tinyurl.com/api-create.php?url={$plugin function("SocketCommands.dll", "$url encode", #DEF URL)}"))) } set(#currently doing,"Finished","Global") save to file("{$special folder("Desktop")}\\Bitlys.txt",%newlycreatedbitlys) alert("Bitly Links Saved To Desktop (Bitlys.txt)") Quote Link to post Share on other sites
hindu 9 Posted June 13, 2015 Report Share Posted June 13, 2015 Put Startup In loop Quote Link to post Share on other sites
Bot-Factory 602 Posted June 13, 2015 Report Share Posted June 13, 2015 I would start with a simple example first Chris. And after you understand the concept completely, look into your code. Let me know if you need an example.Dan Quote Link to post Share on other sites
Chris M 55 Posted June 13, 2015 Author Report Share Posted June 13, 2015 I had an example by TJ that looked easy enough but after adding it to my bot and moving code around I was left with a tonof errors. :/ Quote Link to post Share on other sites
Bot-Factory 602 Posted June 14, 2015 Report Share Posted June 14, 2015 I had an example by TJ that looked easy enough but after adding it to my bot and moving code around I was left with a tonof errors. :/There are two parts to muiltithreading. 1. The management and control of the threads. Starting the threads and monitoring when threads are closed2. Making your code thread ready. It has to run within defines. Every define has to have all the data within the define to work properly. Reading and wring global variables, lists and tables can be a problem. Dan Quote Link to post Share on other sites
Chris M 55 Posted June 14, 2015 Author Report Share Posted June 14, 2015 Ok. Thank you Dan. Quote Link to post Share on other sites
Bot-Factory 602 Posted June 14, 2015 Report Share Posted June 14, 2015 Ok. Thank you Dan. I will send you an example next week when I have some free time. Dan 1 Quote Link to post Share on other sites
k1lv9h 76 Posted June 16, 2015 Report Share Posted June 16, 2015 Hi, Here is a simple multi thread sample. Threading your program will not be easy. Trying to keep the shortened urls together and in order with the url used to generate them. ui text box("threads", #threads) ui text box("cycles", #cycles) set(#theadcount, 0, "Global") set(#cyclecount, 0, "Global") loop(#cycles) { loop(#threads) { loop while($comparison(#theadcount, ">=", #threads)) { wait(1) } increment(#theadcount) thread { in new browser { navigate("http://www.ubotstudio.com/playground/simple-form", "Wait") wait for browser event("Everything Loaded", "") reset account("Any") type text(<username field>, "{$account data("First Name")}{$account data("Last Name")}", "Standard") type text(<first name field>, $account data("First Name"), "Standard") type text(<password field>, $account data("Password"), "Standard") click(<value="Submit">, "Left Click", "No") wait for browser event("Everything Loaded", "") wait(3) } decrement(#theadcount) } } increment(#cyclecount) } wait(30) stop scriptsample-thread-006.ubot Kevin 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.