I have figured out how to use sendkey to send key presses to other apps, but how would you go about sending a key press and hold to other apps?
IE: press and hold W for 10 seconds.
Printable View
I have figured out how to use sendkey to send key presses to other apps, but how would you go about sending a key press and hold to other apps?
IE: press and hold W for 10 seconds.
Code:Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Debug.Print KeyCode
'Place your sendkey code here, it will repeatedly send the code
End Sub
What is your end goal with this?Quote:
Originally Posted by Tontow
I was playing around with sendkeys and was just wondering if it could be done without it sending tens of thoushands of repeating keypresses.
Place a timer on the form and perform the sendkeys in there?
Code:Dim lngCount As Long
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Timer1.Enabled = True
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Timer1.Enabled = False
lngCount = 0
End Sub
Private Sub Timer1_Timer()
If lngCount = 10 Then
''sendkeys here
MsgBox "Key sent"
End If
lngCount = lngCount + 1
End Sub
You missunderstood, I want to send the keydown and keyup events to another app.