
05-06-2009, 05:06 PM
|
|
Newcomer
|
|
Join Date: May 2009
Location: UK
Posts: 1
|
|
SendMessage/PostMessage not populating ComboBox
|
Hi everyone - I'm a long time lurker first time poster. I've tried every thread relating to my problem in the seach function but had no sucess so I wonder if you could help me out?
I am trying to pass a text string to a combo box in another application. I have definetly found the correct window handle for the box in question and I have checked this in ManagedSpy/Spy++.
"hWndControl3" is the exact handle ID of the combobox I wish to pass the "romtext" string to yet my script does nothing. I have checked that the PostMessage returns a value and it does (A large number). I have also tried SendMessage to no avail.
Could someone please advise me or alter this script so it will sucessfully pass the romtext value to the combobox
Many Thanks
Tom
Code:
Module Wrapper
Private Const WM_SETTEXT = &HC
Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" ( _
ByVal hWnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As String _
) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As String _
) As Long
Private Declare Auto Function FindWindow Lib "user32.dll" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) As IntPtr
Private Declare Auto Function FindWindowEx Lib "user32.dll" ( _
ByVal hwndParent As IntPtr, _
ByVal hwndChildAfter As IntPtr, _
ByVal lpszClass As String, _
ByVal lpszWindow As String _
) As IntPtr
Sub Main()
Dim hWnd As IntPtr = FindWindow(vbNullString, "Open ROM File")
Dim hWndControl1 As IntPtr = FindWindowEx(hWnd, IntPtr.Zero, "ComboBoxEx32", vbNullString)
Dim hWndControl2 As IntPtr = FindWindowEx(hWndControl1, IntPtr.Zero, "ComboBox", vbNullString)
Dim hWndControl3 As IntPtr = FindWindowEx(hWndControl2, IntPtr.Zero, "Edit", vbNullString)
Dim romtext As String
romtext = "Test"
PostMessage(hWndControl3, WM_SETTEXT, 0&, romtext)
End Sub
End Module
|
|