Hold down keys

D

Daniel N

Is there a way to hold down keys in vb.net?

In the program I am writing I can simulate a MOUSE button hold down:



Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx
As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As
Long)

Public Const MOUSEEVENTF_LEFTDOWN As Object = &H2

Public Const MOUSEEVENTF_LEFTUP As Object = &H4



Public Sub LeftDown()

mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)

End Sub

Public Sub LeftUp()

mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)

End Sub



Public Sub LeftClick()

LeftDown()

LeftUp()

End Sub



So I am Sure I can do this with a keyboard key (Specifically ALT, and the
SHIFT keys). Sendkeys does not work (Its much like a click by sending a down
AND an UP). As you can see I googled and found that using the hex &H2 to
simulate a mouse button click worked I am sure there is a way to do it for
the keyboard. Thanks if you can provide help.
 
C

Cor Ligthert [MVP]

Daniel,

I am almost sure that at least Herfried and I have given you a solution in
the newsgroup public.dotnet.languages.vb

Did you have a look at that?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top