Results 1 to 14 of 14

Thread: Retrieving Text from an external app?

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    14

    Retrieving Text from an external app?

    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:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    2. 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
    3. 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
    4. 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
    5.  
    6. Private Const WM_GETTEXT = &HD
    7. Private Const WM_SETTEXT = &HC
    8. Private Const EM_GETLINECOUNT = &HBA
    9.  
    10.  
    11.  
    12. Private Sub CMDGETEDIT_Click()
    13. Dim lNotepadHwnd As Long
    14. Dim lNotepadEdit As Long
    15. Dim sCaption As String * 256  '// YES A BUFFER
    16.  
    17.     lNotepadHwnd = FindWindow("POPUP_INT_DLG_WINDOW", vbNullString)
    18.     lNotepadEdit = FindWindowEx(lNotepadHwnd, 0&, "RichEdit20A", vbNullString)
    19.  
    20.    
    21.    
    22.    
    23.     SendMessageSTRING lNotepadEdit, WM_GETTEXT, 256, sCaption
    24.  
    25. txtNotepad.Text = sCaption
    26. 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
    Last edited by cado1982; Apr 25th, 2005 at 10:10 PM. Reason: Addition

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width