LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Auto login to sites like yahoo, gmail...intranet sites..etc etc without user intervention

Andy,
Thanks for the VI....I think lot of people woudl have benefited..!!
 
In my case login.htm is a frame in the main page.So what happenes is when i use login.html it is redirected to the main page..
so i thought that i should go to the particular fram i want and then look for a form in that page and then submit the form..
is it possible in labview? If so how?
 
i have put below my actual implementation ...
 
Below is the main page html code.So this page does not contain any form. There are three frames in this PAGE. We need main_screen frame where the form is residing!!
so i need to know how should we go to a particular frame in a html page and access a form amd submit it??
 
NOTE: Main page url is http://169.254.3.1/main_frame_nologin.htm(it is an intranet site)
when i try login.htm then i am redirected to the above page.
 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">

<!-- saved from url=(0041)http://169.254.3.1/main_frame_nologin.htm -->

<HTML><HEAD><TITLE>3Com - OfficeConnect 11Mbps Wireless Access Point</TITLE>

<META http-equiv=Content-Type content="text/html; charset=windows-1252">

<META content="MSHTML 6.00.2800.1491" name=GENERATOR></HEAD><FRAMESET border=0

frameSpacing=0 frameBorder=0 cols=150,*><FRAME name=menu_screen marginWidth=0

marginHeight=0

src="3Com - OfficeConnect 11Mbps Wireless Access Point_files/menu_nologin.htm"

frameBorder=0 noResize scrolling=no><FRAMESET border=0 rows=*,30

frameBorder=0><FRAME name=main_screen marginWidth=0 marginHeight=0

src="3Com - OfficeConnect 11Mbps Wireless Access Point_files/login.htm"

frameBorder=0 noResize><FRAME name=statusLine marginWidth=0 marginHeight=0

src="3Com - OfficeConnect 11Mbps Wireless Access Point_files/stbar_waiting.htm"

frameBorder=0 scrolling=no></FRAMESET></FRAMESET></HTML>

Regards

Vevek

0 Kudos
Message 11 of 29
(3,370 Views)
Vevek,

There is a frame selection that is available using the Document ActiveX reference, so instead of forms you would select frames.  Basically you would want to drill down until you have selected the form of interest.  In your case it sounds like you need to select the frame, then the form, then the actual area that you are entering the information.  There is a lot of information on MSDN about the web browser methods and properties. I have linked the IHTMLDocument2 page, which is the reference created by the Document property node.

IHTMLDocument2 Interface

I believe all that you would need to do is add an additional property node and invoke node, one to select the frames reference and the other to select the frame.  Once you have that selected you should be able to then select the form and continue like the VI I posted previously.  This may take a little tweaking to get it to work, but I do think it's possible.  One tip though, judging from the MSDN page above, I think that the frame is referenced by an index (zero-indexed) that is generated from the order in the HTML code. 

Hope this helps!
Andy F.
-----------------------------------------------------------------
National Instruments
0 Kudos
Message 12 of 29
(3,356 Views)
Hi Andy,

have you actually used that successfully before? If yes could you maybe attach an example? I have tried to use IHTMLDocument2.frames in LabView before but always got an Error -2147467262 (Interface not supported) and just gave up after some time.
0 Kudos
Message 13 of 29
(3,345 Views)

Andy,

i ahve tried out a looooooooooot...with the frames..not able to get the exact implmentation...

i ahve attached the vi but it shows error..as given by ravis

if you coudl share an example vi ..it would be very useful

0 Kudos
Message 14 of 29
(3,333 Views)

Hi Ravis,

i aslo tried using IHTMLdocument2.frames...i get the refrence from IWebbrowser.document..

i guess that the reference is wrong...but i am not knowing how to use the IHTMLdocument2.frames..

the squence is as follows:

1. go to web browser

2. get the document in web browser

3. get the frame

4. collect the frame elements

5. go to a particular frame

6. read the frame and if any form is there login to the form and press submit!!

i have got a pseudo code in c# .i tried the same in labview and i am getting errors ..lots 😞

please help me with an eg vi if possible in labview!!!
using System;

namespace ConsoleApplication7
{
/// <summary>
/// Summary description for Class1.
/// </summary>
using System;
using mshtml;
using SHDocVw;
using System.Collections;
using System.Threading;

namespace ConsoleApplication1
{
class Class1
{
static InternetExplorer ie = null;

[STAThread]
static void Main(string[] args)
{
Class1 class1 = new Class1();
class1.Test();
Console.Read();
}

AutoResetEvent firstDocumentCompleted;
AutoResetEvent lastDocumentCompleted;
int completedDocuments;
int expectedDocuments;

public void Test()
{
Console.WriteLine("Starting:" + Thread.CurrentThread.ApartmentState.ToString());

ie = new SHDocVw.InternetExplorer();
ie.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(DocumentComplete);
ie.Visible = true;
firstDocumentCompleted = new AutoResetEvent(false);
lastDocumentCompleted = new AutoResetEvent(false);


completedDocuments = 0;
expectedDocuments = 4;
object o = null;
ie.Navigate("http://www.htmq.com/html/sample/frame.htm", ref o, ref o, ref o, ref o);
firstDocumentCompleted.WaitOne(30000, false);

IHTMLDocument2 document = (IHTMLDocument2)ie.Document;
lastDocumentCompleted.WaitOne(30000, false);

IHTMLFramesCollection2 frames = (IHTMLFramesCollection2)document.frames;
for (int index = 0; index < frames.length; index++)
{
object i = index;
frames.item(ref i);

IHTMLWindow2 window = (IHTMLWindow2)frames.item(ref i);
IHTMLDocument2 frameDocument = (IHTMLDocument2)window.document;

Console.WriteLine(frameDocument.body.innerHTML);
}

Console.WriteLine();
}

public void DocumentComplete(object pDisp, ref object URL)
{
Console.WriteLine("DocumentComplete:" + Thread.CurrentThread.ApartmentState.ToString());

if (completedDocuments == 0)
{
firstDocumentCompleted.Set();
}

Interlocked.Increment(ref completedDocuments);

if (completedDocuments == expectedDocuments)
{
lastDocumentCompleted.Set();
}

}
}
}
}

0 Kudos
Message 15 of 29
(3,328 Views)

Hi Andy/Ravis

Attached is a eg vi for the reading a frame. But i get error..

0 Kudos
Message 16 of 29
(3,322 Views)
pondy and ravis,

I attempted to recreate the errors that you guys were seeing and found that it wasn't very difficult at all!  It seems that there are some properties and methods that LabVIEW doesn't like, notably frames in this case.  I was however able to get the same code to work in CVI (the code in this case being just querying the number of frames on the page.  That site in the C# code (http://www.htmq.com/html/sample/frame.htm) is a great reference!  In any case, this looks like something I need to investigate further.  An alternative would be to generate key strokes (tab, actual password, etc) using the windows system DLLs to get access to the forms on the page of interest.  There are many examples of people doing this in the forums.  That may work as an alternative to the frames activeX programming for now, which I will post about if I make any progress. 

Good programming guys!
Andy F.
-----------------------------------------------------------------
National Instruments
0 Kudos
Message 17 of 29
(3,301 Views)

Hi Andy,

Your solution was great!!

But will it be possible to use the reference of the the activeX reference with the window's handler??

i mean is it possible to log to a site(eg yahoo....) through the key strokes ...and get into the page in back ground??without the active window?

i tried with the user32.dll and got to know that a "windows handler" reference should be passed..but how to pass from the IHTMLWebbrowser functions???

is there any other way of doing it in background??

i have attached the vi's for selecting the tab and writing a value to an application...

(note:i am not possible to integrate with the activeX eg(google eg) which you shared to us)

Please reply me ...

regards

vevek

Download All
0 Kudos
Message 18 of 29
(3,289 Views)

Hi Andy,

I tried your approach of using key strokes (tabs) to login to a website..but i was not able to do the process in the back groud using the user32.dll interface with labview..(SINCE IT DOES FOR ONLY ACTIVE WINDOW!!)

i tried tried ...and tried...

is there any other way of doing the same task(login to a website or search google) by using key strokes..but should be done in back ground..?? or is it possible by using activex??

You stated in your mail that you were able to use the application of accessing a frame in CVI enviroment?? is that the c# code that i shared to you??

Is it possible to go to a particular frame and go to a form in that frame and login/search something in CVI??

i haven't worked in CVI enviornment.,...Could you suggest me a better approach with a example either in Labview or LabviewCVI so that it may be useful for me...(and also for many others!!!)

regards

vevek

 

0 Kudos
Message 19 of 29
(3,285 Views)
Vevek,
 
Performing those tasks will be very hard in the background for all the reasons that you mentioned.  The active window handle is necessary, meaning that the window will need to be active.  One option, although ugly, would be to login and then minimize or close the window.  I know that would work to log you in to the site.  As for the example I am using basically the code that you posted in C# to determine what calls and references that I need.  One other thing, that I personally am not very familiar with would be to use .NET to make the calls instead of ActiveX from LabVIEW.  I will file a corrective action request for the error using the ActiveX calls, and do my best to look into a .NET implementation as well.  As always I will keep everyone updated.
 
Andy F.
-----------------------------------------------------------------
National Instruments
0 Kudos
Message 20 of 29
(3,278 Views)