LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modern ActiveX Browser Options

Solved!
Go to solution

Hey all.  So I've always struggled with getting an ActiveX browser to work in my actual programs.  Generally I run the NI provided example and sure enough it works on NI's site, but then I go to use it on the site I want and things break all the time for various reasons.  The most recent issue is that I get script errors, and am unable to render Google's Captcha page.  Here is what I mean:

 

ActiveX Crap Out.png

 

But beyond this I've had other issues with the ActiveX browser.  I have VLC setup to broadcast the current playlist to a URL.  But for this to be turned on VLC requires a password.  So I setup the URL in the form of "http://:password@localhost:8081/requests/playlist.xml" This embeds the password "password" and the blank user in the URL.  It is less secure but normal browsers as far as I can tell support it.  But when I go to this URL with the IWebBrowser2 using ActiveX I usually get some kind of not authorized page.  Sometimes a random popup asks my user name and password, at which point I can type it in and click Save, but as soon as I restart LabVIEW it is forgotten.

 

So my question isn't really how do I fix these two situations, and is more.  What other better, more modern browser options are there which support ActiveX?  It appears Edge is dropping ActiveX support by the way.  NXG seems to likely work around this by including a full dedicated browser in the IDE which likely is useful for things like documentation, and WebVIs.

0 Kudos
Message 1 of 16
(7,060 Views)

"Modern" and ActiveX? Seems to be a paradox...

 

Have you tried the .net WebBrowser container? Not sure if it's better, but there are others that succeeded with the password problem:

 

https://social.msdn.microsoft.com/Forums/en-US/95070e0a-5972-4b27-bbf0-0d5f3795f28c/webbrowser-and-c...

Message 2 of 16
(7,013 Views)

I wasn't aware of a .Net WebBrowser, do you have an examples?  My quick search of the NI forums found one that doesn't have a .net container for the FP but may solve my password problem, I'll need to try it when I get home.

 

Also for anyone else with the ActiveX issue (not that I need to stay with ActiveX, it was just convenient)  Apparently the browser defaults to IE7 unless you change some registry settings.

0 Kudos
Message 3 of 16
(6,997 Views)
Solution
Accepted by topic author Hooovahh

Okay found some good stuff and finally got a .Net browser working on the front panel, and am able to use credentials to get the playlist of VLC.  First if you are looking to do this in VLC there are some settings to make.

 

Go to Tools >> Preferences, and pick the Show Settings - All radio button.  Then under Input / Codecs set the HTTP server port to what you want in my example it is 8081.  Then go to Interface >> Main interfaces and check Web, then Interfaces >> Main Interfaces >> Lua and set the Lua HTTP Password to "password" (without quotes). Then save, close, and reopen VLC.

 

Then run the attached VI.  It will navigate to http://localhost:8081/requests/playlist.xml, and use the user name "" and password "password" these credentials are a Base64 encoding and can be done online here, or can be calculated with the code posted here.  It then navigates to that URL, and waits for the body to have content (or 5 second timeout) then returns the text which should be the current VLC play list.  I then have a stop button waiting just so the .Net Container page can be viewed.  Stop the VI with the control, add songs to the playlist and run it again to see the text and the page displayed.

 

One thing I did find odd is that I couldn't navigate to a page, without seeing it on the container.  If I used the Constructor Node to create the WebBrowser object, and then ran the VI the constructor would generate a .NET Exception "cannot be instantiated because the current thread is not in a single-threaded apartment.)"  I guess I don't care since my FP doesn't have to be seen but looking into how to fix this issue went down a long rabbit whole too.  Thanks again.

Message 4 of 16
(6,987 Views)

And thanks for posting the solution (don't forget to mark it as solutionSmiley Very Happy)! Might need it myself someday.

0 Kudos
Message 5 of 16
(6,982 Views)

Thanks for the reminder, I tend to not accept my own post as a solution.  Try to not make people think I'm gaming the system by answering my own question, but your help certainly pointed me down the right direction.

0 Kudos
Message 6 of 16
(6,972 Views)

Another likely useless update but maybe someone will find it useful.  So I took the code I posted earlier and ran it on another machine and it failed, throwing an exception when returning the HTML Element InnerText. 

 

System.ArgumentNullException: Value cannot be null.
Parameter name: key

 

The .Net container still displayed the page right, but I couldn't get the body.  I did some searching and I think (think) this is a known bug on an older version.  I went through the steps to fix it and it never worked.  So I went back to the drawing board now armed with the knowledge about authorization.  I ended up with this:

 

Example_VI_BD.png

This works as expected and in native G.  Again this has the hard coded user name and password which can be updated.

0 Kudos
Message 7 of 16
(6,930 Views)

Hello Brian;

Can you please post your solution in LabVIEW 2016?

Thanks!

Gordon

0 Kudos
Message 8 of 16
(6,352 Views)

@Exile wrote:

Can you please post your solution in LabVIEW 2016? 


This one's 2013...

0 Kudos
Message 9 of 16
(6,330 Views)

Thank you for posting the example. I have inserted the .NET WebBrowser into a resizable pane inside an Actor Framework project but at run time LabVIEW crashes the instant we run. I replaced the .NET WebBrowser with a simple .NET string control and get the same crash behavior.

Does anyone have any insight into what may be happening? Are we forbidden from utilizing .NET controls inside an AF application?

Thanks!

0 Kudos
Message 10 of 16
(6,295 Views)