XpownX 8 Posted June 15, 2014 Report Share Posted June 15, 2014 Hi I'm trying to learn multithreading , i'm making a bot for making accounts in ubot studio playground , after it has maked the accounts , it save them on a .txt , but it save only one . Could you please check out my code and see what is wrong with it? Thanks ui text box("How many threads to open:", #Threads)ui stat monitor("Account Created:", #created)set(#created, 0, "Global")define List { thread { in new browser { set(#Username, $account data("Username"), "Local") set(#Password, $account data("Password"), "Local") reset account("Any") add item to list(%List, #Username, "Delete", "Global") add item to list(%Password, #Password, "Delete", "Global") set(#Username, $next list item(%List), "Global") set(#Password, $next list item(%Password), "Global") wait(1) navigate("http://www.ubotstudio.com/playground/simple-form", "Wait") wait(1) type text(<username field>, #Username, "Standard") wait(1) type text(<password field>, #Password, "Standard") wait(1) type text(<first name field>, $account data("First Name"), "Standard") wait(1) type text(<last name field>, $account data("Last Name"), "Standard") wait(1) click(<value="Submit">, "Left Click", "No") wait(2) if($exists(<innertext="Account Created">)) { then { increment(#created) } else { } } save to file("C:\\Users\\TheSgtLuca\\Desktop\\username.txt", "{#Username}:{#Password}") } }}loop(#Threads) { List()} Quote Link to post Share on other sites
Team_LX 3 Posted June 15, 2014 Report Share Posted June 15, 2014 instead of Save command use the Append to file command when saving the items Quote Link to post Share on other sites
HaHaItsJake 25 Posted June 15, 2014 Report Share Posted June 15, 2014 Append to file command if for ADDING MORE to a file. If you wish to save the list at once without adding more to a file, then you want to do the followingset(#account information, "{#Username}:{#Password}", "Global")add item to list(%Account information, #account information, "Delete", "Global") I personally like the UI Button to save the file; ui save file("Save Account Information to:", #saveaccountinfo)ui button("Save Account Information") { save to file(#saveaccountinfo, %Account information) alert("Account Saved!Location: {#saveaccountinfo}")} Also, When multithreading with varset(#Username, $next list item(%List), "Global")set(#Password, $next list item(%Password), "Global")Need them to set to Local instead of Global. Global will set the var for ALL threads. Local will do it just for the SINGLE thread.Hope that helps remember when threading with var's need to set it to Local instead of Global if it's needed ONLY on that thread. If the var is used threw out all, then global. Quote Link to post Share on other sites
Marton 48 Posted June 15, 2014 Report Share Posted June 15, 2014 But watch out with setting global variables in the thread. If two threads try to write the same global variable at the same time (or almost at the same time), only one of them will get written. Obviously same goes for incrementing/decrementing variables. That's why it's recommended to use UbotDev's thread counter plugin. All the best,Marton 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.