matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: hWnd of IMWindowClass chat input box
quote: Originally posted by Stigmata
quote: Originally posted by eSouL
is there a method to set the text of the textbox
yep, using active accessibility
http://forums.msnfanatic.com/index.php?showtopic=11778
quote: Originally posted by eSouL
Matty, is there a method to set the text of the textbox or perhaps sendkeys to it?
In a Module
code: Public 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
Public Declare Function GetForegroundWindow Lib "user32" () As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) _
As Long
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) _
As Long
Public Const WM_CHAR = &H102
Public Const VK_RETURN = &HD
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const INFINITE = &HFFFF
Public lngPrevWnd As Long
Public ConversationWnd_Obj As Object
Public Sub SendText(hwnd As Long, _
sText As String, _
Optional bSend As Boolean = False, _
Optional bKeepFocus As Boolean = True)
Dim RetVal As Long
RetVal = SetForegroundWindow(hwnd)
WaitForSingleObject RetVal, INFINITE
For i = 1 To Len(sText)
Call PostMessage(hwnd, WM_CHAR, Asc(Mid(sText, i, 1)), 0)
Next i
If bSend Then
Call PostMessage(hwnd, WM_KEYDOWN, VK_RETURN, 0&)
Call PostMessage(hwnd, WM_KEYUP, VK_RETURN, 0&)
End If
If Not bKeepFocus Then
Call SetForegroundWindow(lngPrevWnd)
End If
End Sub
In your Class Module
code: Public Function ParseCommand(ByVal sCommand As String, _
ByVal sCommandArg As String, _
ByVal oConversationWnd As Object, _
ByRef sResult As String) _
As Boolean
Set ConversationWnd_Obj = oConversationWnd
Select Case LCase(sCommand)
Case Is = "/xtest"
lngPrevWnd = GetForegoundWindow()
SendText FindWindowEx(ConversationWnd_Obj.hWnd, _
0&, _
"DirectUIHWND", _
vbNullString), _
"this text will be sent", _
True, _
True
sResult = ""
ParseCommand = True
Exit Function
End Select
ParseCommand = False
End Function
This post was edited on 10-10-2005 at 11:24 PM by matty.
|
|