does anyone know how I can send a listbox item to a textbox in another application with API? Im trying to do this without using SendKeys, and the other application is not mine so I cant make the textbox receive or wait for anything specific. Thanks!
Printable View
does anyone know how I can send a listbox item to a textbox in another application with API? Im trying to do this without using SendKeys, and the other application is not mine so I cant make the textbox receive or wait for anything specific. Thanks!
You get the text of a ListBox item like this:The rest is an API question, suitable for the API forum. I'm sure that instructions on how to place text in fiels in other programs have been given multiple times before. The last step will be SendMessage, but I don't know the specifics of finding the window. Searching for SendMessage would be a good place to start.Code:myListBox.GetItemText(myItem)
FindWindow and FindWindowEx are the other two APIs that you will need. You basically find the window handle to the main app. Then drill down the window structure to get to your desired Textbox window with FindWindowEx. Then perform the SendMessage to send the listbox text to the textbox.
Im familiar with SendMessage, Im just not sure how to put the listbox item as a parameter of it, since in SendMessage there is class name, caption, lParam, and wParam. can the item be a int as well or does it have to be a string?
Here is the definition and description of SendMessage. There is a code example at the bottom of the page.