i am doing a small project that i would like to send a string from a list box and an option "enter" to the next top window, similar to the program in http://www.vbforums.com/showthread.php?t=316373.
my problems are, when i try to get the hwnd for the target program several have a zreo value, ones that i get a value for do not get the value for the textbox or other control where i want the message to go (i have been using apispy to check the correct value).
if i hard code the hwnd for the control i can send message, but it is not correct
i have an array of list boxes wish to send the listbox text to the control that has focus on the applicaton then return to select another item.
VB Code:
Private Const WM_COPY = &H301 Private Const WM_PASTE = &H302 Private Const WM_SETTEXT As Long = &HC 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 Declare Function GetActiveWindow Lib "user32" () As Long Private Sub List1_Click(index As Integer) Dim newtext As String newtext = List1(index).Text Debug.Print Me.hwnd Me.Hide wind = GetActiveWindow Debug.Print wind Me.Show ' hwind for text box on program i was trying to paste to, detected by apispy 'wind = 329952 SendMessage wind, WM_SETTEXT, 0&, List1(index).Text List1(index).SetFocus End Sub




Reply With Quote