allcapone1912 7 Posted January 29, 2017 Report Share Posted January 29, 2017 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? Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted January 29, 2017 Report Share Posted January 29, 2017 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 Quote Link to post Share on other sites
Macster (UBotter Labs) 112 Posted January 29, 2017 Report Share Posted January 29, 2017 "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] Quote Link to post Share on other sites
allcapone1912 7 Posted January 29, 2017 Author Report Share Posted January 29, 2017 "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 threadscan you take a look at my full code? Quote Link to post Share on other sites
Macster (UBotter Labs) 112 Posted January 29, 2017 Report Share Posted January 29, 2017 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. 1 Quote Link to post Share on other sites
allcapone1912 7 Posted January 29, 2017 Author Report Share Posted January 29, 2017 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 helpyou solve my problem I've test only with one define and yes, its work great 1 Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted January 29, 2017 Report Share Posted January 29, 2017 "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. 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.