Sur » 16.08.2004 (Пн) 22:09
найдено в инете:
на форму кнопку, в IE - страницу, - html в файле с:\CurrPageSource.htm
Option Explicit
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 SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Private Sub Command1_Click()
Dim pHwnd As Long
Dim wHwnd As Long
Dim rHwnd As Long
Dim cHwnd As Long
Dim txtBuff As String ' receives the copied text from the target window
Dim txtLength As Long ' length of the window text
Dim retVal As Long
pHwnd = FindWindowEx(0, 0, "IEFrame", vbNullString)
wHwnd = FindWindowEx(pHwnd, 0, "WorkerW", vbNullString)
rHwnd = FindWindowEx(wHwnd, 0, "ReBarWindow32", vbNullString)
cHwnd = FindWindowEx(rHwnd, 0, "ComboBoxEx32", vbNullString)
txtLength = SendMessage(cHwnd, WM_GETTEXTLENGTH, ByVal CLng(0), ByVal CLng(0)) + 1
txtBuff = Space(txtLength)
retVal = SendMessage(cHwnd, WM_GETTEXT, ByVal txtLength, ByVal txtBuff)
' Remove the terminating null and extra space from the buffer.
txtBuff = Left(txtBuff, retVal)
DoEvents
'Source will be saved as a text file in the c:\ directory
retVal = URLDownloadToFile(0, txtBuff, "C:\CurrPageSource.htm", 0, 0)
End Sub