|
-
Aug 5th, 2000, 11:16 AM
#1
Thread Starter
New Member
Accessing Internet Explorer using VB
Hello there,
I am in serious trouble. Ive got a project to do which involves creating an interface agent for the internet explorer. This agent must in some way record all the user events. Im assuming that this can be done by activating a macro recorder. However, having only a tiny smattering of programming knowledge this is proving to be quite a difficult thing to do. Basicaly I dont have a clue and will shortly die because of this.
Any help/ideas would be greatly appreciated.
------------------------------------------------------------
Cheers to gwdash -I think it should do the trick
[Edited by the_hardmeister on 08-08-2000 at 01:35 PM]
-
Aug 5th, 2000, 01:42 PM
#2
Fanatic Member
Are you trying to get the URL from IE or what. If so, you can use DDE to get the URL and window title?
If this is what you need, you can use code similar to this:
Code:
Option Explicit
Private NewURL As String
Private WindowTitle As String
Private DefaultBrowser
Private ValidBrowser As Boolean
Private Enum imDefaultBrowser
imDefaultIE
imDefaultNetscape
imDefaultUnknown
End Enum
Private Declare Function FindExecutable Lib "shell32.dll" _
Alias "FindExecutableA" _
(ByVal lpFile As String, _
ByVal lpDirectory As String, _
ByVal sResult As String) As Long
Private Declare Function GetTempPath Lib "kernel32" _
Alias "GetTempPathA" _
(ByVal nSize As Long, _
ByVal lpBuffer As String) As Long
Private Const MAX_PATH As Long = 260
Private Const ERROR_FILE_NO_ASSOCIATION As Long = 31
Private Const ERROR_FILE_NOT_FOUND As Long = 2
Private Const ERROR_PATH_NOT_FOUND As Long = 3
Private Const ERROR_FILE_SUCCESS As Long = 32 'my constant
Private Const ERROR_BAD_FORMAT As Long = 11
Private Sub GetIEURL()
On Error GoTo IEError
If DetermineDefaultBrowser = "Other" Then
MsgBox "No Valid Browser Avalible" & vbNewLine & vbNewLine & _
"Please get Internet Explorer, Netscape, or AOL", _
vbExclamation + vbOKOnly, _
"Internet URL Monitor"
Unload Me
End If
Debug.Print DetermineDefaultBrowser
txtURL.LinkTopic = DetermineDefaultBrowser & "|www_GetWindowInfo"
txtURL.LinkItem = "0xFFFFFFFF"
txtURL.LinkMode = 2
txtURL.LinkRequest
DecodeURL
Exit Sub
IEError:
If Err.Number = 282 Then
txtIEURL.Text = "Web Browser not open"
End If
End Sub
Private Sub DecodeURL()
Dim OldURL As String
Dim pos As Integer
OldURL = txtURL.Text 'set old url
pos = InStr(1, OldURL, ",") 'find url/window title seporator (",")
NewURL = Mid(OldURL, 2, pos - 3) 'extract URL
WindowTitle = Mid(OldURL, pos + 2, (Len(OldURL) - (Len(NewURL) + 3)) - 2)
End Sub
Private Function GetBrowserName(dwFlagReturned As Long) As String
Dim hFile As Long
Dim sResult As String
Dim sTempFolder As String
'get the user's temp folder
sTempFolder = GetTempDir()
'create a dummy html file in the temp dir
hFile = FreeFile
Open sTempFolder & "dummy.html" For Output As #hFile
Close #hFile
'get the file path & name associated with the file
sResult = Space$(MAX_PATH)
dwFlagReturned = FindExecutable("dummy.html", sTempFolder, sResult)
'clean up
Kill sTempFolder & "dummy.html"
'return result
GetBrowserName = TrimNull(sResult)
End Function
Private Function TrimNull(item As String)
Dim pos As Integer
pos = InStr(item, Chr$(0))
If pos Then
TrimNull = Left$(item, pos - 1)
Else: TrimNull = item
End If
End Function
Public Function GetTempDir() As String
Dim nSize As Long
Dim tmp As String
tmp = Space$(256)
nSize = Len(tmp)
Call GetTempPath(nSize, tmp)
GetTempDir = TrimNull(tmp)
End Function
'--end block--'
Private Function DetermineDefaultBrowser() As String
Dim BrowserPath
Dim Success As Long
BrowserPath = GetBrowserName(Success)
If InStr(1, BrowserPath, "iexplore") Then
DetermineDefaultBrowser = "IExplore"
ElseIf InStr(1, BrowserPath, "netscape") Then
DetermineDefaultBrowser = "Netscape"
Else
DetermineDefaultBrowser = "Other"
End If
End Function
The variable WindowTitle will be set to the Title in the Title bar and the variable NewURL will become the current URL.
-
Apr 1st, 2008, 01:31 AM
#3
Lively Member
Re: Accessing Internet Explorer using VB
hi
i put your code in vb class
but its says that in
txtURL.LinkTopic = DetermineDefaultBrowser & "|www_GetWindowInfo"
txtURL is not declare.
can you tell me how to solve this?
i am not too advance in vb,.net
-
Apr 1st, 2008, 07:07 AM
#4
Re: Accessing Internet Explorer using VB
 Originally Posted by bhavin12300
i am not too advance in vb,.net
Moved to VB.NET
 Originally Posted by bhavin12300
txtURL is not declare.
can you tell me how to solve this?
It means you are referencing a textbox that does not exist on the form from which you are running the code.
However, because your thread was in the wrong section, the suggested code, which is VB6, might not work anyway.
-
Apr 1st, 2008, 11:13 AM
#5
Lively Member
Re: Accessing Internet Explorer using VB
oh
i am really sorry
thanks for your support.
than you so much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|