How do you send an "ENTER" to an external's (another app) textbox without using SendKeys?. TIA,
Printable View
How do you send an "ENTER" to an external's (another app) textbox without using SendKeys?. TIA,
VB Code:
SendMessage hWndTextbox, WM_CHAR, (vbKeyReturn), 0
try the keybd_event Function
http://msdn.microsoft.com/library/de...eybd_event.asp
I could not make it work.Quote:
Originally Posted by |2eM!x
Try WM_KEYDOWN, followed by WM_KEYUP, using VK_RETURN (vbKeyReturn).
so
VB Code:
Const WM_KEYDOWN = &H100 Const WM_KEYUP = &H101 '-------- SendMessage hWnd, WM_KEYDOWN, 13, 0 SendMessage hWnd WM_KEYUP, 13, 0
Didn't work either. Besides... I'm having problems finding the handles automatically. Any ideas what could I be doing wrong?
Even harder if we can't see what you are trying to do.
It won't work if you use the wrong handle. :)
keybd_event is the same as a SendKeys since they both require the receiving app to have focus.
Try using PostMessage maybe.
Since I cannot get the handle (the last step is the problem) I'm inputboxing it. I can write some text to the textbox... so the handle is inputted (manually) correctly, but the ENTER is not working. This is my code:Quote:
Originally Posted by dglienna
The message (sMsg) is written correctly, but the ENTER does not work.VB Code:
tWindow = FindWindowEx(lhWnd, 0&, "AfxControlBar42s", "Watches") tWindow = FindWindowEx(tWindow, 0&, "AfxWnd42s", "Output Window") tWindow = FindWindowEx(tWindow, 0&, "Afx:400000:8", vbNullString) hWndTextbox = FindWindowEx(tWindow, 0&, "Edit", vbNullString) 'hWndTextbox remains equals to 0. SendMessage hWndTextbox, WM_SETTEXT, -1, ByVal sMsg SendMessage hWndTextbox, WM_KEYDOWN, 13, 0 SendMessage hWndTextbox, WM_KEYUP, 13, 0
I cannot use SendKeys because when this other app is activate, the focus is not on the textbox it should.Quote:
Originally Posted by RobDog888
Oh its a textbox control. Then it doesnt accept an enter as a valid character unless you have a multiline textbox. What control is supposed to receive the enter keypress?
Correct, thats why I mentioned that keybd_event will NOT work because of its similarities with SendKeys. ;)Quote:
Originally Posted by Mc Brain
Can't you just click on a button instead of pressing Enter?
The Edit class of window is a Textbox control and not a command button. ;) I am wondering myself where the enter keypress fits into this?Quote:
Originally Posted by dglienna
Im sorry, mine works for RTB's