Hi, i'm having some trouble with the following code i used from an example and then ammended could someone help me please?
VB Code:
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 SendMessageSTRING Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam 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 Const WM_GETTEXT = &HD Private Const WM_SETTEXT = &HC Private Const EM_GETLINECOUNT = &HBA Private Sub CMDGETEDIT_Click() Dim lNotepadHwnd As Long Dim lNotepadEdit As Long Dim sCaption As String * 256 '// YES A BUFFER lNotepadHwnd = FindWindow("POPUP_INT_DLG_WINDOW", vbNullString) lNotepadEdit = FindWindowEx(lNotepadHwnd, 0&, "RichEdit20A", vbNullString) SendMessageSTRING lNotepadEdit, WM_GETTEXT, 256, sCaption txtNotepad.Text = sCaption End Sub
The trouble i'm having is that it works fine for a short while (probably about 5-10 secs) then it just returns nothing i.e the txtnotepad textbox is empty.
EDIT - Sorry forgot to add that it returns blank until i close the external application's window and then reopen it again then the problem repeats -
Any ideas?
Chris




Reply With Quote