R
Roger McFadden
Hello
I want to simulate up/down/left/right-keys.
I have this code:
Public Const KEYEVENTF_UP As Integer = &H2
Public Const KEYEVENTF_EXTENDKEY As Integer = &H1
Public Const KEYEVENTF_SILENT As Integer = &H4
<DllImport("coredll.dll")> _
Public Shared Sub keybd_event( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Integer, _
ByVal dwExtraInfo As Integer)
End Sub
Public Sub PressKey(ByVal key As Keys)
Dim code As Byte = CType(key, Byte)
Dim up As Integer = KEYEVENTF_UP
Try
keybd_event(code, 0, 0, 0) 'keydown
keybd_event(code, 0, up, 0) 'keyup
Catch ex As Exception
End Try
End Sub
Now if I use PressKey(Keys.A), then I get an "a", globally
If I use PressKey(Keys.Up) (or down/left/right), it does nothing, but my PPC slows down ..
Whats wrong?
I want to simulate up/down/left/right-keys.
I have this code:
Public Const KEYEVENTF_UP As Integer = &H2
Public Const KEYEVENTF_EXTENDKEY As Integer = &H1
Public Const KEYEVENTF_SILENT As Integer = &H4
<DllImport("coredll.dll")> _
Public Shared Sub keybd_event( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Integer, _
ByVal dwExtraInfo As Integer)
End Sub
Public Sub PressKey(ByVal key As Keys)
Dim code As Byte = CType(key, Byte)
Dim up As Integer = KEYEVENTF_UP
Try
keybd_event(code, 0, 0, 0) 'keydown
keybd_event(code, 0, up, 0) 'keyup
Catch ex As Exception
End Try
End Sub
Now if I use PressKey(Keys.A), then I get an "a", globally
If I use PressKey(Keys.Up) (or down/left/right), it does nothing, but my PPC slows down ..
Whats wrong?