API
                    ola gente alguem sabe qual api monitora o evendo keycode do teclado
ps não e o keyascii e sim o keycode
que pode retornar um valor para teclas especiais tipo de teclado multimedia
                
            ps não e o keyascii e sim o keycode
que pode retornar um valor para teclas especiais tipo de teclado multimedia
                    Se não me engano o teclado multimedia devem ser comandos do Rundll
Veja Isso
http://www.vbmania.com.br/vbmania/vbmdetail.php?varID=3054
            Veja Isso
http://www.vbmania.com.br/vbmania/vbmdetail.php?varID=3054
                    tente adptar este fonte.
Option Explicit
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
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 Const VK_NUMLOCK = &H90
Private Const VK_SCROLL = &H91
Private Const VK_CAPITAL = &H14
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Dim o As OSVERSIONINFO
Dim NumLockState As Boolean
Dim ScrollLockState As Boolean
Dim CapsLockState As Boolean
Dim keys(0 To 255) As Byte
                
            Option Explicit
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
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 Const VK_NUMLOCK = &H90
Private Const VK_SCROLL = &H91
Private Const VK_CAPITAL = &H14
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Dim o As OSVERSIONINFO
Dim NumLockState As Boolean
Dim ScrollLockState As Boolean
Dim CapsLockState As Boolean
Dim keys(0 To 255) As Byte
Private Sub Command1_Click()
  
  o.dwOSVersionInfoSize = Len(o)
  GetVersionEx o
    
  GetKeyboardState keys(0)
  
  'NumLock handling:
  NumLockState = keys(VK_NUMLOCK)
  If NumLockState <> True Then    'Turn numlock on
    If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then  '===== Win95
      keys(VK_NUMLOCK) = 1
      SetKeyboardState keys(0)
    ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then   '===== WinNT
      'Simulate Key Press
      keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
      'Simulate Key Release
      keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
    End If
  End If
  
  'CapsLock handling:
  CapsLockState = keys(VK_CAPITAL)
  If CapsLockState <> True Then    'Turn capslock on
    If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then  '===== Win95
      keys(VK_CAPITAL) = 1
      SetKeyboardState keys(0)
    ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then   '===== WinNT
      'Simulate Key Press
      keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
      'Simulate Key Release
      keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
    End If
  End If
  
  'ScrollLock handling:
  ScrollLockState = keys(VK_SCROLL)
  If ScrollLockState <> True Then    'Turn Scroll lock on
    If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then  '===== Win95
      keys(VK_SCROLL) = 1
      SetKeyboardState keys(0)
    ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then   '===== WinNT
      'Simulate Key Press
      keybd_event VK_SCROLL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
      'Simulate Key Release
      keybd_event VK_SCROLL, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
    End If
  End If
End SubPrivate Sub Command2_Click(Index As Integer)
'simular pressionamento de capslock, numlock e scroll lock
  Select Case Index
  Case 0
    'Simulate Key Press
    keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
    'Simulate Key Release
    keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
  Case 1
    'Simulate Key Press
    keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
    'Simulate Key Release
    keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
  Case 2
    'Simulate Key Press
    keybd_event VK_SCROLL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
    'Simulate Key Release
    keybd_event VK_SCROLL, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
  End Select
End SubPrivate Sub Command3_Click()
 'Este é o botão que verifica o status de capslock
 o.dwOSVersionInfoSize = Len(o)
  GetVersionEx o
    
  GetKeyboardState keys(0)
Dim CapsLockState As Boolean
CapsLockState = keys(VK_CAPITAL)
If CapsLockState = True Then
MsgBox "capslock ligado"
Else
MsgBox "capslock DESsligado"
End If
End Sub
                    Const VK_CAPITAL = &H14
Const VK_NUMLOCK = &H90
Const VK_SCROLL = &H91
Const VK_USED = VK_SCROLL
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Long
Private Declare Function GetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Private Declare Function SetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim kbArray As KeyboardBytes, CapsLock As Boolean, kbOld As KeyboardBytes
                
            Const VK_NUMLOCK = &H90
Const VK_SCROLL = &H91
Const VK_USED = VK_SCROLL
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Long
Private Declare Function GetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Private Declare Function SetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim kbArray As KeyboardBytes, CapsLock As Boolean, kbOld As KeyboardBytes
Private Sub Form_Load()
    'KPD-Team 1999
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    'Get the current keyboardstate
    GetKeyboardState kbOld
    'Hide the form
    Me.Hide
    MsgBox "Keep your eyes on the little num-, shift- and scrolllock lights on the keyboard."
    TurnOff VK_CAPITAL
    TurnOff VK_NUMLOCK
    TurnOff VK_SCROLL
    Sleep 1000
    TurnOn VK_NUMLOCK
    Sleep 100
    TurnOn VK_CAPITAL
    Sleep 100
    TurnOn VK_SCROLL
    Sleep 300
    TurnOff VK_NUMLOCK
    Sleep 100
    TurnOff VK_CAPITAL
    Sleep 100
    TurnOff VK_SCROLL
    Sleep 500
    TurnOn VK_NUMLOCK
    TurnOn VK_SCROLL
    Sleep 200
    TurnOff VK_NUMLOCK
    TurnOff VK_SCROLL
    Sleep 200
    TurnOn VK_NUMLOCK
    TurnOn VK_SCROLL
    Sleep 200
    TurnOff VK_NUMLOCK
    TurnOff VK_SCROLL
    Sleep 200
    TurnOn VK_CAPITAL
    Sleep 200
    TurnOff VK_CAPITAL
    Sleep 200
    TurnOn VK_CAPITAL
    Sleep 200
    TurnOff VK_CAPITAL
    Sleep 200
    TurnOn VK_NUMLOCK
    TurnOn VK_SCROLL
    Sleep 200
    TurnOff VK_NUMLOCK
    TurnOff VK_SCROLL
    Sleep 200
    TurnOn VK_NUMLOCK
    TurnOn VK_SCROLL
    Sleep 200
    TurnOff VK_NUMLOCK
    TurnOff VK_SCROLL
    Sleep 200
    TurnOn VK_CAPITAL
    Sleep 400
    TurnOff VK_CAPITAL
    Sleep 200
    TurnOn VK_NUMLOCK
    Sleep 100
    TurnOn VK_CAPITAL
    Sleep 100
    TurnOn VK_SCROLL
    Sleep 300
    TurnOff VK_SCROLL
    Sleep 100
    TurnOff VK_CAPITAL
    Sleep 100
    TurnOff VK_NUMLOCK
    Sleep 1000
    Unload Me
End SubPrivate Sub TurnOn(vkKey As Long)
    'Get the keyboard state
    GetKeyboardState kbArray
    'Change a key
    kbArray.kbByte(vkKey) = 1
    'Set the keyboard state
    SetKeyboardState kbArray
End SubPrivate Sub TurnOff(vkKey As Long)
    'Get the keyboard state
    GetKeyboardState kbArray
    'change a key
    kbArray.kbByte(vkKey) = 0
    'set the keyboard state
    SetKeyboardState kbArray
End SubPrivate Sub Form_Unload(Cancel As Integer)
    'restore the old keyboard state
    SetKeyboardState kbOld
End Sub
                        Tópico encerrado , respostas não são mais permitidas