LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting information from activex browser to LabVIEW VI

Hi - I have a LabVIEW VI that uses the Mozilla ActiveX control (see here: http://www.iol.ie/%7Elocka/mozilla/plugin.htm). I have a large amount of javascript code running on the webpage that is being displayed (it is always the same webpage). I communicate from my VI to the webpage by setting the url equal to something like "javascript:alert("hello world");" This works beautifully - I can call all of my functions in this manner. However, I need to be able to read back data from the plug in. Ideally the web page could generate some sort of signal to initiate a read, but if I had to poll it occasionally that would be OK as well.
 
Does anybody have any suggestions as to how to do this? I can't seem to find anything.
 
Thanks!
 
-Michael

Message Edited by mnoone on 05-11-2007 05:32 PM

0 Kudos
Message 1 of 5
(5,231 Views)
Michael,

I have some ideas, but I do want to express some skepticism about why you're making your ActiveX calls through the seemingly superfluous extra layer of an IWebBrowser2 ActiveX control.  Is there a reason you can't just make the ActiveX calls directly in LabVIEW?  I understand that you have some javascript-based wrapper code already available to interact with your underlying component, but things might be easiest if you were to rewrite those calls using LabVIEW's native objects (Property Node, Invoke Node, etc.).

That said, I can think of a way to read back result data from the javascript calls to your plugin.  You can embed some dummy div elements into your HTML code and have your javascript functions update the InnerHTML property of the divs with whatever result data you get from the ActiveX calls.  Then, from LabVIEW, you can read the updated HTML document body (take the Document property of the IWebBrowser2 object, cast it to a IHTML2Document object, then get the body and InnerHTML properties, or something similar) and parse out the div content to read back the result data.

Attached is a sample of the method (LV 8.2) and a screenshot of the block diagram, since I don't know what LabVIEW version you're using.

Hope it helps,
John
Download All
0 Kudos
Message 2 of 5
(5,209 Views)

Hi John - thanks for the reply - I appreciate you taking the time to help me.

First of all - I wasn't exactly sure what I was doing with the iwebbrowser2 ActiveX control. That part of the VI was very confusing for me, and I couldn't find much documentation regarding it. Essentially I hacked at it till I got it working, and left it there. Anyways, If there is a better way to do what I am doing I would love to hear more about it.

The sample project looks like a very interesting way to do get feedback. It's certainly a bit round about, but whatever gets the job done. I'll try implementing it as soon as I have time.

I am using the student version of 8.2, by the way.

I have attached my VI that I am using just in case.

-Michael

Message Edited by mnoone on 05-12-2007 12:07 AM

0 Kudos
Message 3 of 5
(5,205 Views)
Michael,

Based on your initial post, I thought you were embeddding a second ActiveX control inside your Web browser ActiveX control, and that the second control was the one you were talking to with your javascript function calls.  As I look more closely at your code, I see that this is not the case, or at least I don't think it is.  The Google Map object in your Web page is purely javascript- and DOM-based, and has nothing* to do with ActiveX.

I think the situation is that you are using the Mozilla ActiveX Web browser control (http://www.iol.ie/~locka/mozilla/control.htm), but not the ActiveX support plug-in for that control (http://www.iol.ie/~locka/mozilla/plugin.htm) that you initially mentioned.  If you don't have specific reasons (namely, very strong anti-Microsoft sentiment) for avoiding Microsoft's "native" Web browser control, I would suggest abandoning the Mozilla control entirely, because 99% of the users on this forum don't have the Mozilla control installed on their Windows machines and won't be able to run the VI that you attached.  They'll see "Control could not be loaded" red text on the front panel and get an Error 1 if they run the VI.

You can switch over to the Microsoft Web browser control by right-clicking on the browser object, choosing "Insert ActiveX Object...", and scrolling down to get to the "Microsoft Web Browser" item.

With all that said, you're still left with your problem, which is how to get information from the Web browser back to LabVIEW.  The solution I suggested will definitely work, but now I'm wondering exactly what sort of information you need to read back?  Based on the VI you attached, you're calling marker.setPoint() and checkview(), and I don't see where those functions return anything of interest to your VI.

It's probably best if you explain in more detail what sort of information you are hoping to pull back from the browser after you send it various commands.

Take care,
John

* ActiveX may be implicitly involved with Internet Explorer if a DOM object is doing AJAX-type things that use the XMLHttpRequest object.
0 Kudos
Message 4 of 5
(5,188 Views)

Hi - sorry I was unclear in my original post. Yes - the HTML page is pure javascript. None of the functions return anything yet because I haven't written the ones that will return anything. The VI is a control and monitor program for a mobile robot with an onboard GPS. The robot's position is being displayed on Google Maps. I want to be able to click on positions on the Google Maps page and have it tell the VI to send a command to the robot to go to that location. I think your method will work. I will have to check the page periodically (every tenth of a second or so) to check to see if a position has been clicked on, but that seems like it will be just fine.

 

I should mention - the reason I'm using the Mozilla ActiveX control is fairly simple. I started out using the Microsoft control, but for whatever reason it was throwing constant JavaScript errors at me. It was strange - Internet Explorer could display the page just fine, but the ActiveX control could not. Thus I switched to the Mozilla control, and every single problem that I was having went away.

 

Thanks for the help,

-Michael

0 Kudos
Message 5 of 5
(5,182 Views)