|
-
Jun 3rd, 2001, 12:49 PM
#1
Thread Starter
New Member
List active windows - select a window - send keys to it
How can I list all the active windows, select one of them and then send some text to it?
For example MSN messenger. Making it periodically send a set message.
Please help me
Matt
-
Jun 3rd, 2001, 07:44 PM
#2
Registered User
Try findwindow api call then enumerate through the child windows of the application to locate the hwnd of the textbox, then send text the hwnd of the control using :
Code:
Option Explicit
Private Const WM_SETTEXT = &HC
Private Declare Function SendMessageByStr& Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal _
lParam As String)
Private Sub cmdSetText_Click()
Dim t$
Dim c&
t = "Hello World"
c& = SendMessageByStr(txt1.hWnd, WM_SETTEXT, 0, t)
End Sub
Then find the hwnd of the "submit" button, and click it :
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 Const BM_CLICK = &HF5
Code:
SendMessage hWnd_Btn, BM_CLICK, 0, 0
Wrap the code in a timer to do it periodically and you are done. Easy in theory, but getting the correct hwnd is the hardest part.
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
|