|
-
Dec 11th, 2000, 05:48 AM
#1
Thread Starter
New Member
I want to try to send some keys to a program and then get a return of any text that is there for example in word. can anyone help me? please help me
-
Dec 11th, 2000, 10:57 AM
#2
Frenzied Member
You should use SendMessage for both
I wrote a quick example for use with notepad, fire it up and test the code 
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 Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Private Const WM_GETTEXTLENGTH = &HE
Private Const WM_GETTEXT = &HD
Private Const WM_SETTEXT = &HC
Private Sub Form_Load()
Dim lNoteP&, edit&
lNoteP = FindWindow("Notepad", vbNullString)
edit = FindWindowEx(lNoteP, 0&, "Edit", "")
MsgBox GetText(edit)
SetText edit, "HEYYY IK BEN JOP"
MsgBox GetText(edit)
End Sub
Private Sub SetText(Wnd As Long, Text As String)
SendMessage Wnd, WM_SETTEXT, ByVal CLng(0), ByVal Text
End Sub
Private Function GetText(Wnd As Long)
Dim l%, Wintext$, retval&
l = SendMessage(Wnd, WM_GETTEXTLENGTH, ByVal CLng(0), ByVal CLng(0)) + 1
Wintext = Space(l)
retval = SendMessage(Wnd, WM_GETTEXT, ByVal l, ByVal Wintext)
GetText = Left(Wintext, retval)
End Function
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Dec 11th, 2000, 04:04 PM
#3
You don't need the declaration of FindWindow and FindWindowEx. Just use FindWindowEx for both.
-
Dec 12th, 2000, 05:09 AM
#4
Thread Starter
New Member
thanx
Thanx for the help. it works fine
-
Dec 21st, 2000, 05:33 AM
#5
Thread Starter
New Member
can you help me jop
i ot your e-mail and i dont mind if it takes you a while to reply. thanx for the help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|