Option Explicit
Declare Function PostMessage Lib "user32" _
Alias "PostMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Declare Function EnumChildWindows Lib "user32" _
(ByVal hWndParent As Long, ByVal lpEnumFunc As Long, _
ByVal lParam As Long) As Long
Declare Function GetWindowText Lib "user32" Alias _
"GetWindowTextA" (ByVal hwnd As Long, _
ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" _
Alias "GetWindowTextLengthA" _
(ByVal hwnd As Long) As Long
Declare Function FindWindow Lib "user32.dll" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Const WM_SETTEXT = 12
Const WM_CHAR = &H102
Private X As String
Sub Main()
'Add a reference to Microsoft Internet Controls
'to your project
Dim SHDocVw As New ShellWindows
Dim IE As InternetExplorer
Dim h As Long
For Each IE In SHDocVw
If IE.LocationURL = _
"[URL unfurl="true"]http://www.tek-tips.com/viewthread.cfm?qid=946898&page=1"[/URL] Then
X = IE.Document.body.innertext
End If
Next
Clipboard.SetText X
h = FindWindow(vbNullString, "Untitled - Notepad")
EnumChildWindows h, AddressOf EnumChildProc, 1
End Sub
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sSave As String
Dim i As Long, g$, X As String
sSave = Space$(GetWindowTextLength(hwnd) + 1)
GetWindowText hwnd, sSave, Len(sSave)
sSave = Left$(sSave, Len(sSave) - 1)
X = Clipboard.GetText
For i = 1 To Len(X)
g = Asc(Mid(X, i, 1))
PostMessage hwnd, WM_CHAR, ByVal g, 393217
Next
Exit Function
'continue enumeration
EnumChildProc = 1
End Function