Ok i hope i did this right, here is what i have, atleast it builds, but when i hit the button it dosent do anything":
VB Code:
Option Explicit 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 Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Long Public Sub proc() Dim hwnd As Long Dim hwndEx As Long 'gets handle of notepad hwnd = FindWindow("Notepad", vbNullString) 'gets handle of 'edit' area of notepad hwndEx = FindWindowEx(hwnd, vbNullString, "edit", vbNullString) Dim x As Integer x = 1 Dim buffer As String 'buffer will contain the text from notepad buffer = " " 'sends WM_GETTEXT message to 'edit' area of notepad Dim x As Integer x = SendMessage(hwndEx, 13, buffer) buffer = buffer.Substring(0, x) Text1.Text = buffer End Sub




Reply With Quote