Visual Basic Server

CapsLock einschalten (Tastatur auf permanente Großschreibung umstellen)

GetVersionEx, GetKeyboardState, SetKeyboardState
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan _
As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 Maintenance string for PSS usage
End Type
Const VK_CAPITAL = &H14
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
Const VER_PLATFORM_WIN32_NT = 2
Const VER_PLATFORM_WIN32_WINDOWS = 1
Dim Keys(0 To 255) As Byte
Sub SetCapsOn()
Dim o As OSVERSIONINFO
Dim NumLockState As Boolean
Dim ScrollLockState As Boolean
Dim CapsLockState As Boolean  CapsLock handling.
o.dwOSVersionInfoSize = Len(o)
GetVersionEx o
CapsLockState = Keys(VK_CAPITAL)
 If CapsLockState <> True Then  Turn capslock on.
   If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then  Win9x
     Keys(VK_CAPITAL) = 1
     SetKeyboardState Keys(0)
   ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then  WinNT
     keybd_event VK_CAPITAL, &H45, _ Simulate Key Press.
       KEYEVENTF_EXTENDEDKEY Or 0, 0
     keybd_event VK_CAPITAL, &H45, _ Simulate Key Release.
       KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
   End If
 End If
End Sub

 Ranking-Hits zurück Sitemap
Designed by www.wbrnet.info