LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mouse event in embedded internet explorer

Solved!
Go to solution
Dear,

I have posted some related questions and then was trying to find similar examples on the forum.
However, I got to know there are fee examples with ActiveX (IWebbroswer2, IHTML) of embedded internet explorer of Labview.

Therefore, I need to explain more detail for my trouble.
I want to collect and arrange some data from web page hosted by 3rd party using LabVIEW (ver.13) automatically.

The page has adopted JAVA so I couldn't identify the id of control (Tab) and detail of source code.
The problem is that the page was launched with information of Tab#1 but I need the information of Tab#2.
The page of Tab#2 cannot be reached by any URL techniques.

So, I implement IWebbrowser2 on the front panel of LabVIEW.
then, I want to make an mouse event (just one cliking on the Tab#2)) on IWebbrowser2 container.
But I have no idea how to fire and handle the event though I was searching MSDN page.

Although I am not an user of ActiveX with LabVIEW, I believe, this kind of work will be popular in case that we can't ask some formatted data to the data provider (host of webpage).


Best,

Labmaster.

*)The following is the java script on the source of (data) html.
I don't know if this is helpful to understand my situation.

JaVa
====================================================================================
<script type="text/javascript" src="/js_n/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/js_n/code.js"></script>
<script type="text/javascript">
<!--
function onSelectTab(num){
var obj = document.gubunTab;
obj.gubuncode.value = num;
obj.submit();
}

function onSelectTab2(num) {
var obj = document.gubunTab2;
obj.gubuncode.value = num;
obj.submit();
}

var tcount =1;

function onsubTab(val) {
// var subcount = 0;
var subcount1 = 0;
var subcount2 = 0;
var subcount3 = 0;
var obj1 ;
var obj2 ;
var obj3 ;

obj1 = document.getElementsByName("divTmp1");
subcount1 = obj1.length;
obj2 = document.getElementsByName("divTmp2");
subcount2 = obj2.length;
obj3 = document.getElementsByName("divTmp4");
subcount3 = obj3.length;

//alert(subcount1+"/"+subcount2+"/"+subcount3);

if (val == 2) {

for(var i = 0; i < subcount1; i++) {
obj1[i].style.display = "none";
}

for(var j = 0 ; j < subcount2 ; j++) {
obj2[j].style.display = "block";
}

for(var k = 0 ; k < subcount3 ; k++) {
obj3[k].style.display = "none";
}

document.getElementById("subtitle1").style.display = "block";
document.getElementById("subtitle2").style.display = "none";

} else if(val == 3) {

for(var i = 0 ; i < subcount1 ; i++) {
obj1[i].style.display = "none";
}

for(var j = 0 ; j < subcount2 ; j++) {
obj2[j].style.display = "none";
}

for(var k = 0 ; k < subcount3 ; k++) {
obj3[k].style.display = "block";
}

document.getElementById("subtitle1").style.display = "none";
document.getElementById("subtitle2").style.display = "block";

} else {

for(var i = 0 ; i < subcount1 ; i++) {
obj1[i].style.display = "block";
}

for(var j = 0 ; j < subcount2 ; j++) {
obj2[j].style.display = "none";
}

for(var k = 0 ; k < subcount3 ; k++) {
obj3[k].style.display = "none";
}

document.getElementById("subtitle1").style.display = "none";
document.getElementById("subtitle2").style.display = "none";
}

tcount = val;
}
//-->
&lt;/script&gt;
0 Kudos
Message 1 of 11
(7,765 Views)

It's not entirely clear from your post whether you know this or not, but you can do something like this, which will perform a click on a specific element:

 

Click IE.png

 

 

Of course, for that you do need to know the ID, and it seems that you do not. I don't know if the Javascript you posted is everything on the page, but I would expect that the tab itself would be an element and have an ID. I know that I have done things like this with Javascript elements before. That said, I'm not exactly a Javascript expert, so it's possible that elements don't always have an ID.

 

Hopefully, this code helps you in understanding how you can interact with elements in the browser. You should be able to find the other options for what you can do online.

 

Also, don't start multiple threads. It just wastes people's time.


___________________
Try to take over the world!
0 Kudos
Message 2 of 11
(7,724 Views)
Thanks tst, I remember you.

Long time no see. You are right. I found the similar posting in a site of script programming, for example, http://www.codingtiger.com/questions/c/trying-to-login-to-web-form-in-code..html
How did you find the Webbrowser not IWebbrowser2? Can you post your code on this page because it is difficult to find the right property of class?
I will try further and then share the example later.
0 Kudos
Message 3 of 11
(7,716 Views)

In this example I actually used a .NET control, because it's more modern than ActiveX and the type system is generally easier to work with. The web browser control can be found under System.Windows.Forms.

 

Also, the image is a snippet. The icon on the top means you can save the image to your HD and then drag it into a BD and it will be dropped as code you can edit and run.


___________________
Try to take over the world!
0 Kudos
Message 4 of 11
(7,704 Views)
tst,

Thanks and I checked the class, system.windows.forms of .NET before your reply.
I couldn't find the property of HtmlElementCollection you mentioned. In my case, I could do select only "count".

As a beginner, I am very confused for realization of the solution.
Can you post simple example vi (right property of class)?

Wow, how can I navigate the web address in .NET webbrowser? I can't find the "navigate property".
0 Kudos
Message 5 of 11
(7,697 Views)
Solution
Accepted by topic author labmaster

There's a .NET web browser control (where I said) and it has all the relevant properties and methods:

 

Example_VI_BD.png


___________________
Try to take over the world!
0 Kudos
Message 6 of 11
(7,694 Views)
Thanks.

I need to get more information or technique for the case of without control id. Here the tab control.
I couldn't manage to click the specific tab page by incorrect id though I found the similar case in other langauge like http://stackoverflow.com/questions/236624/how-to-access-html-element-without-id.
I can search the possible id and find some clue of well operation of tst's code but not reliable in my case.
However, is there any technique to find all information (such as list of id or list of type) of controls on the webpage in .NET?
0 Kudos
Message 7 of 11
(7,675 Views)
Dear tst,

Thanks for your hint in my trouble.
However, I would like to know more about callback event with .NET to check if the page is loading completely.
Can you tell me more hint for this? I have no any experience .NET and callback event.

Thanks again.
0 Kudos
Message 8 of 11
(7,662 Views)

Read the help for the function and look at the shipping examples. Basically, .NET events and LV events don't really fit, so you set up a VI which gets called whenever the event occures. You can use that VI to trigger a separate LV event. The details of each specific event are yours for the finding (since it's MS, it's on the MSDN).


___________________
Try to take over the world!
0 Kudos
Message 9 of 11
(7,644 Views)
tst,

Sorry for further question on basic stuff.
I am not in the field of ActiveX or .NET and my application doesn't require the complicated routine for the event.
According to the manual, I have to register event callback in using .NET or ActiveX.
I just want to know the extreme case if there is no register callback like systematical error such as leakage of memroy.
Can you explain me the case a little bit if there is no event callback in .NET application?

For example, I found the shipped example tiltled with "ActiveX event callback for IE".
I have no idea how to set up like BeforeNavigate2 event callback.vi.
Can you recommend some material for this topic?

labmaster.
0 Kudos
Message 10 of 11
(7,631 Views)