Jump to content
UBot Underground

Problem With Local Variable


Recommended Posts

Hi,

have a problem with Local Variable and can't figure out what I am doing wrong.

 

My code:

define RandomOn1stPage(#my_threadId, #proxy) {
    add list to list(%found,$plugin function("ExBrowser.dll", "$ExBrowser Generic Xpath Parser", $plugin function("ExBrowser.dll", "$ExBrowser Document Text"), "//a[contains(@href,\'{#LinkToSearch}\')]", "href", ""),"Delete","Local")
    set(#found,$random list item(%found),"Local")
    alert(#found)
    plugin command("ExBrowser.dll", "ExBrowser Click", "//a[contains(@href, \'{#found}\')]")
}

With Local Variable its alert the correct link to click but not clicking(Screenshot attached)

Also, if I set all variable to Global its work great

 

Not sure what I am missing, any idea?

 

post-20283-0-46788300-1485694687_thumb.png

Link to post
Share on other sites

There is a problem with local scope and ubot list.

 

http://tracker.ubotstudio.com/issues/1166

 

 

Try a variable and "append to file" or large data plugin to add to a list in that or Iron Python.

 

Regards,

Nick

Link to post
Share on other sites

"Local" variables are writen/read only inside "Threads".

 

i.e each thread is a local session which reads the "local" variable that is assigned inside the same thread.

 

To avoid the bug @Code Docta is mentioning your correct code should include a thread inside/outside the define, not vice-versa:

thread {
    add list to list(%found,$plugin function("ExBrowser.dll", "$ExBrowser Generic Xpath Parser", $plugin function("ExBrowser.dll", "$ExBrowser Document Text"), "//a[contains(@href,\'{#LinkToSearch}\')]", "href", ""),"Delete","Local")
    set(#found,$random list item(%found),"Local")
    alert(#found)
    plugin command("ExBrowser.dll", "ExBrowser Click", "//a[contains(@href, \'{#found}\')]")
}
NOTE: keep in mind that ExBrowser must be opened and included in the same tread otherwise the code from above will not be able to look for the browser you want to use, if it is opened outside or in another thread.
thread {
start exbrowser
run local code...
}

[uBotter Labs]

Link to post
Share on other sites

"Local" variables are writen/read only inside "Threads".

 

i.e each thread is a local session which reads the "local" variable that is assigned inside the same thread.

 

To avoid the bug @Code Docta is mentioning your correct code should include a thread inside/outside the define, not vice-versa:

thread {
    add list to list(%found,$plugin function("ExBrowser.dll", "$ExBrowser Generic Xpath Parser", $plugin function("ExBrowser.dll", "$ExBrowser Document Text"), "//a[contains(@href,\'{#LinkToSearch}\')]", "href", ""),"Delete","Local")
    set(#found,$random list item(%found),"Local")
    alert(#found)
    plugin command("ExBrowser.dll", "ExBrowser Click", "//a[contains(@href, \'{#found}\')]")
}
NOTE: keep in mind that ExBrowser must be opened and included in the same tread otherwise the code from above will not be able to look for the browser you want to use, if it is opened outside or in another thread.
thread {
start exbrowser
run local code...
}

[uBotter Labs]

 

my full code

thread spawn(#TotalCycle,#threads) {
    increment(#OpenThread)
    increment(#cycle)
    LaunchBrowserThread(#my_threadId, #proxy)
    increment(#my_threadId)
    set(#proxy,$random list item(%proxy),"Global")
    decrement(#OpenThread)
}
define LaunchBrowserThread(#my_threadId, #proxy) {
    wait($rand(1,3))
    plugin command("ExBrowser.dll", "ExBrowser Launcher", #browser, $plugin function("ExBrowser.dll", "$ExBrowser Set HTTP Proxy", #proxy, "", ""), "")
    plugin command("ExBrowser.dll", "ExBrowser Navigate", $random list item(%link))
    plugin command("ExBrowser.dll", "ExBrowser Wait For Dom Ready", 10)
    wait($rand(1,3))
    RandomOn1stPage(#my_threadId, #proxy)
    plugin command("ExBrowser.dll", "ExBrowser Close")
}
define RandomOn1stPage(#my_threadId, #proxy) {
    add list to list(%found,$plugin function("ExBrowser.dll", "$ExBrowser Generic Xpath Parser", $plugin function("ExBrowser.dll", "$ExBrowser Document Text"), "//a[contains(@href,\'{#LinkToSearch}\')]", "href", ""),"Delete","Local")
    if($comparison($list total(%found),"> Greater than",0)) {
        then {
            set(#found,$random list item(%found),"Local")
            plugin command("ExBrowser.dll", "ExBrowser Click", "//a[contains(@href, \'{#found}\')]")
            plugin command("ExBrowser.dll", "ExBrowser Wait For Dom Ready", 10)
        }
        else {
        }
    }
}

variable are included in threads

can you take a look at my full code?

Link to post
Share on other sites

Unable to test your code right now but i recommend to void using nested defines inside threads, like this (i moved the second define inside the first one):

thread spawn(#TotalCycle,#threads) {
increment(#OpenThread)
increment(#cycle)
LaunchBrowserThread(#my_threadId, #proxy)
increment(#my_threadId)
set(#proxy,$random list item(%proxy),"Global")
decrement(#OpenThread)
}
define LaunchBrowserThread(#my_threadId, #proxy) {
wait($rand(1,3))
plugin command("ExBrowser.dll", "ExBrowser Launcher", #browser, $plugin function("ExBrowser.dll", "$ExBrowser Set HTTP Proxy", #proxy, "", ""), "")
plugin command("ExBrowser.dll", "ExBrowser Navigate", $random list item(%link))
plugin command("ExBrowser.dll", "ExBrowser Wait For Dom Ready", 10)
wait($rand(1,3))

add list to list(%found,$plugin function("ExBrowser.dll", "$ExBrowser Generic Xpath Parser", $plugin function("ExBrowser.dll", "$ExBrowser Document Text"), "//a[contains(@href,\'{#LinkToSearch}\')]", "href", ""),"Delete","Local")
if($comparison($list total(%found),"> Greater than",0)) {
then {
set(#found,$random list item(%found),"Local")
plugin command("ExBrowser.dll", "ExBrowser Click", "//a[contains(@href, \'{#found}\')]")
plugin command("ExBrowser.dll", "ExBrowser Wait For Dom Ready", 10)
}
else {
}
}

plugin command("ExBrowser.dll", "ExBrowser Close")
}

or, if you use threads and possible, remove the defines altogether and put the code inside the thread directly.

 

Sometimes when nested defines are used inside threads it reads the first define OK, but sometimes when the second define is called from the first one, it fails.

  • Like 1
Link to post
Share on other sites

Unable to test your code right now but i recommend to void using nested defines inside threads, like this (i moved the second define inside the first one):

thread spawn(#TotalCycle,#threads) {
increment(#OpenThread)
increment(#cycle)
LaunchBrowserThread(#my_threadId, #proxy)
increment(#my_threadId)
set(#proxy,$random list item(%proxy),"Global")
decrement(#OpenThread)
}
define LaunchBrowserThread(#my_threadId, #proxy) {
wait($rand(1,3))
plugin command("ExBrowser.dll", "ExBrowser Launcher", #browser, $plugin function("ExBrowser.dll", "$ExBrowser Set HTTP Proxy", #proxy, "", ""), "")
plugin command("ExBrowser.dll", "ExBrowser Navigate", $random list item(%link))
plugin command("ExBrowser.dll", "ExBrowser Wait For Dom Ready", 10)
wait($rand(1,3))

add list to list(%found,$plugin function("ExBrowser.dll", "$ExBrowser Generic Xpath Parser", $plugin function("ExBrowser.dll", "$ExBrowser Document Text"), "//a[contains(@href,\'{#LinkToSearch}\')]", "href", ""),"Delete","Local")
if($comparison($list total(%found),"> Greater than",0)) {
then {
set(#found,$random list item(%found),"Local")
plugin command("ExBrowser.dll", "ExBrowser Click", "//a[contains(@href, \'{#found}\')]")
plugin command("ExBrowser.dll", "ExBrowser Wait For Dom Ready", 10)
}
else {
}
}

plugin command("ExBrowser.dll", "ExBrowser Close")
}

or, if you use threads and possible, remove the defines altogether and put the code inside the thread directly.

 

Sometimes when nested defines are used inside threads it reads the first define OK, but sometimes when the second define is called from the first one, it fails.

thanks for your help

you solve my problem

 

 

I've test only with one define and yes, its work great

  • Like 1
Link to post
Share on other sites

"Local" variables are writen/read only inside "Threads".

 

i.e each thread is a local session which reads the "local" variable that is assigned inside the same thread.

 

To avoid the bug @Code Docta is mentioning your correct code should include a thread inside/outside the define, not vice-versa:

thread {
    add list to list(%found,$plugin function("ExBrowser.dll", "$ExBrowser Generic Xpath Parser", $plugin function("ExBrowser.dll", "$ExBrowser Document Text"), "//a[contains(@href,\'{#LinkToSearch}\')]", "href", ""),"Delete","Local")
    set(#found,$random list item(%found),"Local")
    alert(#found)
    plugin command("ExBrowser.dll", "ExBrowser Click", "//a[contains(@href, \'{#found}\')]")
}
NOTE: keep in mind that ExBrowser must be opened and included in the same tread otherwise the code from above will not be able to look for the browser you want to use, if it is opened outside or in another thread.
thread {
start exbrowser
run local code...
}

[uBotter Labs]

The bug in the tracker is using threads.

 

And I have had problems using the same variable names in defines...

 

#my_threadId, #proxy

 

might look like this

 

#LS_my_threadId, #LS_proxy

 

#RP_my_threadId, #RP_proxy

 

To avoid any potential problems like above.

 

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