Question:
Send key Press Visual Basic 2008 (dot .net)?
kirgy
2009-06-20 07:26:56 UTC
Im trying to send an "enter" key to another application in visual basic 2008.

The problem im having, is the application im sending to requires a "keydown" type of event, rather than just a keypress (by use of "SendKeys") if anyone can help it will be brilliant, thanks.
Four answers:
2009-06-22 10:33:42 UTC
I suggest you start learning the SendMessage function.

You can easily use sendmessage to send the windows message WM_KEYDOWN to an application. Here's an example code



SendMessage(WINDOW HANDLE HERE, WM_KEYDOWN, VK_RETURN, 0);
2016-05-23 06:48:42 UTC
Its actually: If e.KeyChar = "13" Then End If The keychar code must be in the "", that is the Char literal in VB
Player
2009-06-23 04:45:43 UTC
idk whats the diff between keydown and keypress...?



Private Declare Sub keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)



Private sub press_enter()

keybd_event &HD, 0, 0, 0

keybd_event &HD, 0, 2, 0

End sub
Blackened
2009-06-20 10:20:45 UTC
you might have better results using the sendkeys api directly:



http://www.vbaccelerator.com/home/vb/Tips/SendKeys_using_the_API/article.asp


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...