Jump to content
UBot Underground

MultiThreading Save


Recommended Posts

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()
}

Link to post
Share on other sites

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 following
set(#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 var

set(#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. 

Link to post
Share on other sites

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

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