Jump to content
UBot Underground

How To Trigger The Execution Of A Javascript Function Located Inside A 'ui Html Panel' With Native Ubot Studio Code?


Recommended Posts

TL;DR: Who knows how to make native UBot Studio source code run a JavaScript function that's inside a UI HTML Panel?

 

Dear Forum:

 

To the best of my knowledge, a mechanism exists to trigger the execution of UBot Studio "define" commands/functions as well as other UBot Studio code from within the UI HTML Panel. An example of that can look like this (from within the UI HTML Panel):

 

ui html panel("<html><body>
 
<button onclick=\"ubot.runScript(\'TheNameOfYourDefine()\')\">Click Here To Run UBot Studio Define</button>
 
</body></html>",100)

 

Clicking on the aforementioned button will trigger the execution of the 'TheNameOfYourDefine' "define" command that would exist elsewhere within one's UBot Studio code.

 

Are you following along so far? It basically means that there is a mechanism through which to execute UBot Studio "define" commands/functions (as well as other native UBot Studio code) from within the UI HTML Panel.

 

Okay.

 

So here's the question... is there a mechanism whereby UBot Studio code can be used to "click/trigger" the execution of an HTML button located within the UI HTML Panel? 

 

But, wait.

 

Keep in mind that, yes, if the goal were to trigger the execution of a UBot Studio "define" command/function, that could be done simply by executing the name of the "define" within one's UBot Code. There wouldn't be a need to trigger the execution of a UI HTML Panel button that would then execute the "define" command/function.

 

My ultimate goal is to trigger the execution of a JavaScript function that's embedded within the UI HTML Panel.

 

Is anyone aware of a mechanism that would trigger the execution of the JavaScript function embedded within the UI HTML Panel from within UBot Studio code?

 

Things that don't appear to work include:

 

- the use of the $eval function and the "run javascript" command

- the use of the Windows "click mouse" command

 

I'm wondering if there might be something similar to "ubot.runScript" which can be used to communicate from the UI HTML Panel with the rest of one's UBot Studio code -- but in reverse. Like maybe a "uihtmlpanel.runScript" that can be used within UBot Studio code to communicate/trigger HTML/JavaScript code located within the UI HTML Panel?

 

Thank you.

Link to post
Share on other sites

What's your use case for such a thing?


Here's how to run a define from ui html panel

https://www.youtube.com/watch?v=bkkRiQKX-fM

 

 

 

I know you can run jquery in the browser window using run javascript command then use $eval if you need to return something.

 

Never tried to do it in the ui html panel tho.

 

Nick

Link to post
Share on other sites

Hi Nick, thank you for your reply.

 

You mention:

> I know you can run jquery in the browser window using run javascript command then use $eval if you need to return something.

 

It appears as though there are two browsers. The first browser is generated by the UI HTML Panel, and appears to operate using Chrome 21 (at least as of UBot Studio v5.9.55). The second browser is the one that appears within the UBot Studio development environment, and that can be toggled between Chrome 21 and Chrome XX (XX = whatever the relatively latest version of Chrome happens to have been included in the version of UBot Studio that someone happens to be using.)

 

My testing and experience suggests that the "run javascript" command, as well as the "$eval" function, operate within the ecosystem of the second browser, the one that's often visible within the UBot Studio development environment. These commands/functions do not appear to be able to communicate with the browser that is generated with the UI HTML Panel command.

 

You ask:

What's your use case for such a thing?
 

This is where it gets tricky, and I really want to try to limit my reply to being less than 1,000+ words. (I already have a bit of a reputation for posting overwhelmingly lengthy/detailed messages.) :)  But, in as few words as possible, the rationale for trying to make native UBot Studio source code run a JavaScript function that's inside a UI HTML Panel is so that:

1) I can move the contents of a file that was selected and opened and whose contents were read into a native UBot Studio variable, such as in this example:
 

set(#Contents,$read file("MyFile.txt"),"Global")

2) and then successfully move the contents of the native UBot Studio variable (#Contents, as in the previous code sample) into a JavaScript variable within the UI HTML Panel.
 

 

. . . 

 

One way to successfully get the contents of a native UBot Studio variable (like, #Contents, in the previous code example) into the UI HTML Panel is to have a hidden DIV into which you funnel the data via a "variable" inclusion within the DIV, as well as something like "fillwith=innerHTML" -- and then using something like this (see below) to move the contents of that DIV over into an actual UI HTML Panel JavaScript variable:

MyVariable = document.getElementById("TheHiddenDIVContents").value;

But for reasons that are beyond the scope of a brief reply, my ideal use case would be facilitated if there were simply a way, using UBot Studio code, to pass the contents of a native UBot Studio variable (like #Contents, as mentioned above), into a UI HTML Panel JavaScript variable.

 

Here's a brief theoretical example of what would be useful:

ui run javascript("MyVar = {#Contents}")

It's essentially the *same* functionality as the "run javascript" command, except that the ecosystem being used is the UI HTML Panel, thus the "ui" in front of the "run javascript" portion of the command.

However, even being able to trigger the execution of a JavaScript function that's contained within the UI HTML Panel browser ecosystem would be super helpful.

 

That could theoretically look something like this:

ui run javascript("MyFunction()")

 

Hopefully this makes some sense? If not, I'm happy to answer more questions and/or elaborate further.

Maybe this is something that is hypothetically achievable via a plugin?

  • Like 1
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...