1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
If GetAsyncKeyState(VK_CTRL) Then
Dim GInput(0 To 1) As GENERALINPUT
Dim KInput As KEYBDINPUT
KInput.wVk = VK_SPACE 'the key we're going to press
KInput.dwFlags = 0 'press the key
'copy the structure into the input array's buffer.
GInput(0).dwType = INPUT_KEYBOARD ' keyboard input
CopyMemory(GInput(0).xi(0), KInput, Len(KInput))
'do the same as above, but for releasing the key
'send the input now
Call SendInput(2, GInput(0), Len(GInput(0)))
Sleep(100)
KInput.wVk = VK_SPACE ' the key we're going to realease
KInput.dwFlags = KEYEVENTF_KEYUP ' release the key
GInput(1).dwType = INPUT_KEYBOARD ' keyboard input
CopyMemory(GInput(1).xi(0), KInput, Len(KInput))
Call SendInput(2, GInput(1), Len(GInput(1)))
End If
End Sub |
Partager