Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27329

VS 2010 SendKeys - Hold Down a Key

$
0
0
Hey guys! It's been awhile. I've Googl(ed?) this for a few hours and can't seem to find a straight forward answer. I'm working on a program and I can't seem to figure out how to make SendKeys actually Hold Down a key.

If I do this-

Code:

SendKeys.Send(W)
Loop

Then it literally spams the key as fast as possible. I just need it to hold down the key. I found this bit of code but I don't really understand how to utilize it-

Code:

Private Sub LetKeyGo(ByVal key As Byte)

        Dim kb_delay As Integer
        Dim kb_speed As Integer


        SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, kb_delay, 0)
        SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, kb_speed, 0)



        keybd_event(key, MapVirtualKey(key, 0), 2, 0)

    End Sub
    Private Sub HoldKeyDown(ByVal key As Byte)

        Dim kb_delay As Integer
        Dim kb_speed As Integer


        SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, kb_delay, 0)
        SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, kb_speed, 0)



        keybd_event(key, MapVirtualKey(key, 0), 0, 0)
    End Sub

Any help would be great! Thanks.

Viewing all articles
Browse latest Browse all 27329

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>