Visual Basic - Ayuda num-lok

Life is soft - evento anual de software empresarial
 
Vista:

Ayuda num-lok

Publicado por Gringo (1 intervención) el 26/09/2005 18:26:46
HOLA A TODOS NECESITO SABER COMO CONTROLAR EL TECLADO, NECESITO DESDE MI PROGRAMA ACTIVAR O DESACTIVAR EL NUM-LOK DEL TECLADO NUMERICO.
DESDE YA MUCHAS GRACIAS
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Ayuda num-lok

Publicado por Juan_K (181 intervenciones) el 26/09/2005 19:52:53
Hola aqui te envio un Ejemplo.
Espero te sea util ..

================================================================

Option Explicit

'==&&== API ==&&===============
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


'==&&==Tipo para verificar sobre q Sistema corre el programa
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type

'==&&==Constantes
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VK_NUMLOCK = &H90
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2

'==================<<< NumLock >>>=========================
'== Para habilitar teclado numerico , Poner Habilitar a true
'== Para deshabilitar , Poner Habilitar a false
'==========================================================
Public Sub NumLock(Habilitar As Boolean)
Dim bytKeys(255) As Byte
Dim NumLock_On As Boolean
'==&&==copiamos el estado de las teclas virtuales(256) a un buffer
GetKeyboardState bytKeys(0)
'==&&==obtenemos el estado de la tecla
NumLock_On = bytKeys(VK_NUMLOCK)
Dim typOS As OSVERSIONINFO
'==&&==Si el estado actual es <> al enviado
If NumLock_On <> Habilitar Then
'==&&==Si tenemos Win95/98/Me
If typOS.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
bytKeys(VK_NUMLOCK) = 1
SetKeyboardState bytKeys(0)
'==&&==Si es WinNT/2000/XP
Else
'==&&==Simulamos un keypress
keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
'==&&==Simulamos un keyRelease
keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY _
Or KEYEVENTF_KEYUP, 0
End If
End If
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar