473,471 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Auto-Login on a WebBrowser?

1 New Member
I'm trying to create a program to automatically log me in to Myspace. Yes, I am too lazy to login myself!

And sorry, but I'm not exactly using a WebBrowser, but something that's name is "SHDocVw" that I got by adding a reference to something for my project... And I have also added a reference to "Microsoft HTML Object Library".

I wrote the following code to edit the text in the "username" box on the Myspace home page.

Expand|Select|Wrap|Line Numbers
  1. Private Sub SetTextboxText(ByVal Text As String)
  2.         DirectCast(GetCurrentWebForm.item("namehere"), mshtml.HTMLInputElement).value = "myemail"
  3.     End Sub
Then I wrote the following code, this time using a new project with a WebBrowser, to provide the names of the elements I would need to use from the Myspace home page.

Expand|Select|Wrap|Line Numbers
  1. Dim hdoc As HtmlDocument = Me.WebBrowser1.Document
  2.         Dim elemcoll As HtmlElementCollection = hdoc.GetElementsByTagName("input")
  3.         For Each helement As HtmlElement In elemcoll
  4.         If Not helement.GetAttribute("Type") = "hidden" Then
  5.         Me.TextBox1.Text = TextBox1.Text & Environment.NewLine & helement.Name
  6.         End If
  7.         Next
It provided the names of the username and password box that I would need to fill out.

So I modified the first code to fill the Username box with my email, but when I tested it out, the project became unresponsive for a couple seconds and then came with an error that "vshost.exe has encountered an error and needs to close....blah blah blah".

Can anyone help me out with this problem? I have been stumped on it for many days!!! If you can also help me figure out how to click the "Login" button on the homepage that would be helpful too! I'm using Visual Basic 2005 & Visual Basic 2008.

Personally, I believe that the problem is that the login form on the Myspace homepage may not be composed of a typical textbox or button. I think this because I tried my code out on the Google Homepage (to enter text and click "Search" button) and it worked like a charm. Or perhaps I need to provide an index in the code? Any help?

Oh, and I am using a computer running Windows XP.

Here is some more source code from my project to help explain some of the above:

Expand|Select|Wrap|Line Numbers
  1. Private Function GetCurrentWebDoc() As mshtml.HTMLDocument
  2.         Try
  3.             Return DirectCast(wb.Document, mshtml.HTMLDocument)
  4.         Catch ex As Exception
  5.             Return Nothing
  6.         End Try
  7.     End Function
  8.  
Expand|Select|Wrap|Line Numbers
  1.     Private Function GetCurrentWebForm() As mshtml.HTMLFormElement
  2.         Try
  3.             If GetCurrentWebDoc.forms.length > 0 Then
  4.                 Return DirectCast(GetCurrentWebDoc.forms.item(0), mshtml.HTMLFormElement)
  5.             Else
  6.                 Return Nothing
  7.             End If
  8.         Catch ex As Exception
  9.             Return Nothing
  10.         End Try
  11.     End Function
Jun 24 '08 #1
0 1845

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Manlio Perillo | last post by:
Hi. This post follows "does python have useless destructors". I'm not an expert, so I hope what I will write is meaningfull and clear. Actually in Python there is no possibility to write code...
1
by: Glabbeek | last post by:
I'm changing the layout of my site. Instead of using tables, I will use DIVs. It's working fine, except for 1 thing: In IE6 some DIVs are not the correct width. Mozilla and Opera are showing the...
5
by: Robert Downes | last post by:
I'm using the following in a page that I'm testing in Mozilla: p.actionLinkBlock {border: 1px #000000 dashed; padding: 0.2cm; width: auto} But the dashed border is extending to the right-edge...
20
by: Vijay Kumar R. Zanvar | last post by:
Hello, Unlike register, auto keyword can not be used to declare formal parameter(s). Is there any specific reason for this? Kind regards, Vijay Kumar R. Zanvar
6
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I...
5
by: Samuel | last post by:
Hi, I am running into a problem of mixing UICulture = auto and allowing users to select culture using a dropdown list. I am detecting a querystring, "setlang", and when found, setting the...
5
by: maya | last post by:
at work they decided to center divs thus: body {text-align:center} #content {width: 612px; text-align:left; margin: 0 auto 0 auto; } this works fine in IE & FF, EXCEPT in FF it doesn't work if...
22
by: nospam_news | last post by:
I currently get asked about my usage of "auto". What is it for? The keyword is clearly superflous here. In contrast to the huge majority of C/C++ developers I write definitions very explicitly...
2
by: Piotr K | last post by:
Hi, I've encountered a strange problem with Firefox which I don't have any idea how to resolve. To the point: I've <divelement with a style "height: auto" and I want to retrieve this value...
21
by: JOYCE | last post by:
Look the subject,that's my problem! I hope someone can help me, thanks
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.