is there a way to get vb to get the source out of an open IE page, i dont want to do it via winsock-directly from ie? -thanks :wave:
Printable View
is there a way to get vb to get the source out of an open IE page, i dont want to do it via winsock-directly from ie? -thanks :wave:
try this:
http://www.thevbzone.com/modHtmlSource.bas
to get the URL from IE use this:
VB Code:
Public Function EnumProc(ByVal app_hwnd As Long, ByVal _ lParam As Long) As Boolean Dim buf As String * 1024 Dim title As String Dim length As Long ' Get the window's title. length = GetWindowText(app_hwnd, buf, Len(buf)) title = Left$(buf, length) ' See if the title ends with " - Netscape". If Right$(title, 30) = " - Microsoft Internet Explorer" _ Then ' This is it. Find the ComboBox information. frmWindowList.lblAddress = EditInfo(app_hwnd) ' Stop searching. EnumProc = 0 Else ' Continue searching til find it. EnumProc = 1 End If End Function ' If this window is of the Edit class, return ' its contents. Otherwise search its children ' for an Edit object. Public Function EditInfo(window_hwnd As Long) As String Dim txt As String Dim buf As String Dim buflen As Long Dim child_hwnd As Long Dim children() As Long Dim num_children As Integer Dim i As Integer ' Get the class name. buflen = 256 buf = Space$(buflen - 1) buflen = GetClassName(window_hwnd, buf, buflen) buf = Left$(buf, buflen) ' See if we found an Edit object. If buf = "Edit" Then EditInfo = WindowText(window_hwnd) Exit Function End If ' It's not an Edit object. Search the children. ' Make a list of the child windows. num_children = 0 child_hwnd = GetWindow(window_hwnd, GW_CHILD) Do While child_hwnd <> 0 num_children = num_children + 1 ReDim Preserve children(1 To num_children) children(num_children) = child_hwnd child_hwnd = GetWindow(child_hwnd, GW_HWNDNEXT) Loop ' Get information on the child windows. For i = 1 To num_children txt = EditInfo(children(i)) If txt <> "" Then Exit For Next i EditInfo = txt End Function ' Return the text associated with the window. Public Function WindowText(window_hwnd As Long) As String Dim txtlen As Long Dim txt As String WindowText = "" If window_hwnd = 0 Then Exit Function txtlen = SendMessage(window_hwnd, WM_GETTEXTLENGTH, 0, _ 0) If txtlen = 0 Then Exit Function txtlen = txtlen + 1 txt = Space$(txtlen) txtlen = SendMessage(window_hwnd, WM_GETTEXT, txtlen, _ ByVal txt) WindowText = Left$(txt, txtlen) End Function
uh by looking at that it looks like all it does is get the url-this is much easier to do that, and thats not what im looking for :D-more liek the page source as in right click, view source :P - tell me if im wrong though, i only glanced at it
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Private Sub Command1_Click()
Dim ieframe As Long
Dim workerw As Long
Dim rebarwindow As Long
Dim comboboxex As Long
Dim combobox As Long
Dim edit As Long
ieframe& = FindWindow("ieframe", vbNullString)
workerw& = FindWindowEx(ieframe&, 0&, "workerw", vbNullString)
rebarwindow& = FindWindowEx(workerw&, 0&, "rebarwindow32", vbNullString)
comboboxex& = FindWindowEx(rebarwindow&, 0&, "comboboxex32", vbNullString)
combobox& = FindWindowEx(comboboxex&, 0&, "combobox", vbNullString)
edit& = FindWindowEx(combobox&, 0&, "edit", vbNullString)
Dim Text As String
Dim TextLen As Long
TextLen& = SendMessageLong(edit&, WM_GETTEXTLENGTH, 0&, 0&)
Text$ = String(TextLen& + 1, Chr(0))
Call SendMessageByString(edit&, WM_GETTEXT, TextLen& + 1, Text$)
Text$ = Left(Text$, TextLen&)
Text1.Text = Text$
End Sub
anyone
Once you have the URL, just use the Inet control (Ctrl T, check Microsoft Internet Control 6.0), and here's your code:
VB Code:
Dim pageHTML as String pageHTML = Inet.OpenURL (WindowText) MsgBox "Here's your source: " & pageHTML