Why not use the Clipboard? Next example will get the selected text from Notepad.
Code: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 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 FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Const WM_COPY = &H301 Const WM_PASTE = &H302 Private Sub Command1_Click() Dim hParent As Long Dim hChild As Long Dim strTemp As String hParent = FindWindow("Notepad", vbNullString) hChild = FindWindowEx(hParent, 0&, "Edit", vbNullString) SendMessage hChild, WM_COPY, 0, 0 SendMessage Text1.hwnd, WM_PASTE, 0, 0 End Sub




Reply With Quote