Try cutting and pasting the following class:
Public Class Keyboard
Private Declare Function GetKeyboardStat e Lib "user32" (ByRef pbKeyState As
Byte) As Integer
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal
bScan As Byte, ByVal dwflags As Integer, ByVal dwExtraInfo As Integer)
Private Declare Function SendInput Lib "user32.dll " (ByVal nInputs As
Integer, ByRef pInputs As GENERALINPUT, ByVal cbSize As Integer) As Integer
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMem ory" (ByRef
pDst As Byte, ByRef pSrc As KEYBDINPUT, ByVal ByteLen As Integer)
<StructLayout(L ayoutKind.Seque ntial)Friend Structure KEYBDINPUT
Dim wVK As Short
Dim wScan As Short
Dim dwFlags As Integer
Dim time As Integer
Dim dwExtraInfo As Integer
End Structure
<StructLayout(L ayoutKind.Seque ntial)Friend Structure GENERALINPUT
Dim dwType As Integer
Dim wVK As Short
Dim wScan As Short
Dim dwFlags As Integer
Dim time As Integer
Dim dwExtraInfo As Integer
'Dim xi() As Byte 'dim 0 to 23
End Structure
' Constant declarations:
Const VK_NUMLOCK As Byte = &H90, vk_Scroll As Byte = &H91, vk_Capital As
Byte = &H14, vk_Ins As Byte = &H2D, vk_Shift As Byte = &H10
Const KEYEVENTF_EXTEN DEDKEY As Byte = &H1, KEYEVENTF_KEYUP As Byte = &H2,
INPUT_KEYBOARD As Byte = 1
Private Shared keys(255) As Byte
Public Shared Property CapsLockOn() As Boolean
Get
Return GetKeyState(vk_ Capital)
End Get
Set(ByVal Value As Boolean)
SetKeyState(vk_ Capital, Value)
End Set
End Property
Public Shared Property NumLockOn() As Boolean
Get
Return GetKeyState(VK_ NUMLOCK)
End Get
Set(ByVal Value As Boolean)
SetKeyState(VK_ NUMLOCK, Value)
End Set
End Property
Public Shared Property ScrollLockOn() As Boolean
Get
Return GetKeyState(vk_ Scroll)
End Get
Set(ByVal Value As Boolean)
SetKeyState(vk_ Scroll, Value)
End Set
End Property
Public Shared Property InsertModeOn() As Boolean
Get
Return GetKeyState(vk_ Ins)
End Get
Set(ByVal Value As Boolean)
SetKeyState(vk_ Ins, Value)
End Set
End Property
Private Shared Function GetKeyState(ByV al keycode As Short) As Boolean
GetKeyboardStat e(keys(0))
Return (keys(keycode) And 1) 0
End Function
Private Shared Sub SetKeyState(ByV al Keycode As Byte, ByVal Value As Boolean)
GetKeyboardStat e(keys(0))
If Value <((keys(Keycode ) And 1) 0) Then
'Key Press
keybd_event(Key code, &H45, KEYEVENTF_EXTEN DEDKEY Or 0, 0)
'Key Release
keybd_event(Key code, &H45, KEYEVENTF_EXTEN DEDKEY Or KEYEVENTF_KEYUP , 0)
End If
End Sub
End Class
--
Dennis in Houston
"Me" wrote:
>
Trying to get the current status of the insert key. Found
my.computer.key board.capslock, but no such item for insert key. Anyone
have some code to help. Can't figure out getkeystate. compiler chokes on
rslt = getkeystate(key s.insert)
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----