Link to home
Start Free TrialLog in
Avatar of sarg_man
sarg_man

asked on

Use IE object to Navigate to URL, then click link - using VB.NET

I found the code below posted by an expert.  It works to open a browser to the specified URL.  I would like to be able to click on an HREF link after the page loads.  Can this be done?  Once I visit the URL, the link I want to click looks like this <a href='javascript:audit(this);'> audit this asset. </a>

I'm fairly new to .NET... so let me know if there are any references or declarations needed
'go to Project -> REFERENCES and select Microsoft Internet Controls
'Private WithEvents IE As SHDocVw.InternetExplorer
    Try
      IE = New SHDocVw.InternetExplorer
      IE.Navigate("www.google.com")
      IE.Visible = True
 
    Catch ex As Exception
     'System.Windows.Forms.MessageBox.Show(ex.ToString)
    End Try

Open in new window

Avatar of William Elliott
William Elliott
Flag of United States of America image

if you know what the link is, then why not just go to the link directly?
i'm not sure you could do this w/out some tricky mouse event work.

do you have the page you are referring to? or is this an internal app?
Avatar of sarg_man
sarg_man

ASKER

It is an internal application.  The first link sends a person to a URL that authenticates (pass-through) and redirects them to the main page (a helpdesk end-user portal).  The javascript link to audit a persons workstation in on that page, but doesn't work if you go directly to the hyperlink page.
it doesn't work, because you have to pass additinal paremeters in order to get it to work, the designer of the application should be able to add a way to do this directly. unless it is some out of the box software, then you'll have to go to the vender,.. yadda yadda,...

anywho,. let's see what we can do.

personally i'd find the .js file that contains the code for the "audit" function.
then i would extract the information from that function we could directly pull out thedata we need or setup a new page that will have just the data you want.


or you can simply
file - saveas- saveas type = webpage complete
zip this and upload it here (in doing this it shouldn't have any 'personal' data in it)
and i'll try to extract a link that will get you what you need out of it.
another option is to
maximize the browser window,
get the exact position(x,y) of the link you want to click
and send a mouseclick event to that location

downside of thisis if you change the resolution of your monitor, then you will have to change the code.
Sending the mouse-click would be pretty tough since we have a number of different machines and resolution sizes.  The software is Numara Track-It 8.1 (http://www.numarasoftware.com/demo.asp).  Since we have a large remote workforce that only connects via the VPN, I'm writing a Windows Service that will "check in" every so often.  Since the audit feature ports the data over http, I was hoping to be able to silently run the asset audit every week or so when they connect to the VPN.  It just doesn't appear that they intended to have a single URL kick off the audit. :(  You can see the link and code for your self if you want to download the demo...  thanks for your interest.
Here is the function that the link I posted calls:
<script language="VBScript">
	function audit(obj)
		if vbOK = msgbox("Audit results are displayed after Technicians perform an audit merge.", vbOKCancel, "Web Audit") then
			top.workSpace.location.replace "../audit.asp?mode=wizard"
		end if
	end function
</script>

Open in new window

convenient.. the website download portion is giving internal errors.
i'll try to download later unless you can upload a copy for me to look at
I tried manually navigating to the main page, then from that page navigating to ../audit.asp?mode=wizard
Didn't work.  I tried looking through the audit.asp page to see if there was a silent mode or something that I could find, no luck...

That's why I was hoping that VB.Net had some way to execute or click a hyperlink on a page.
it is most likely buried in a series of .js files that you don't see
do this.
file - saveas- saveas type = webpage complete
then look to see if their are any .js files
<script language="VBScript">
this is an audit function, but a vbscript one, they put this there to confuse you.
ASKER CERTIFIED SOLUTION
Avatar of sarg_man
sarg_man

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial