1 1 1 1 1 1 1 1 1 1 Rating 4.00 (4 Votes)

Problemstellung:

Wie kann ich mittels VBA die NumLock-Taste ein- bzw. ausschalten?
Für MS-Access00-07

Code in ein neues öffentliches Modul kopieren:

Private Const VK_NUMLOCK = &H90
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
 
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
 
Function SetNumLock(bStatus As Boolean) As Boolean
   Dim R As Variant
   Dim NumLockOn As Boolean
   Dim KeyTable(0 To 255) As Byte
 
  R = GetKeyboardState(KeyTable(0))
   NumLockOn = (KeyTable(VK_NUMLOCK) <> 0)
 
  If (bStatus And Not NumLockOn) Or _
               (Not bStatus And NumLockOn) Then
       keybd_event VK_NUMLOCK, _
       &H45, _
       KEYEVENTF_EXTENDEDKEY Or 0, 0
       keybd_event VK_NUMLOCK, _
       &H45, _
       KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
   End If
End Function

Aufruf:

SetNumLock False

würde die NumLock-Taste ausschalten

SetNumLock True

würde die NumLock-Taste einschalten

Ähnliche Artikel

Kommentar schreiben

Sicherheitscode
Aktualisieren

Login Form

1.png1.png9.png3.png2.png6.png1.png
Heute77
Gestern57
Diese Woche190
Dieser Monat1320
Total1193261

  • IP: 54.80.183.100
  • Browser: Unknown
  • Version:
  • OS: Unknown

Online

1
Online

23. Mai 2018