Ciao Vincenzo,
girando e rigirando su internet
ho trovato questa API per la gestione della tastiera
codice:
' dichiarazione costanti per la gestione della tastiera:
Const VK_NUMLOCK As Integer = &H90
Const VK_SCROLL As Integer = &H91
Const VK_CAPITAL As Integer = &H14
Const KEYEVENTF_EXTENDEDKEY As Integer = &H1
Const KEYEVENTF_KEYUP As Integer = &H2
Const VER_PLATFORM_WIN32_NT As Integer = 2
Const VER_PLATFORM_WIN32_WINDOWS As Integer = 1 '
' dichiarazione API per la gestione della tastiera:
Private Declare Sub keybd_event Lib "user32" _ (ByVal bVk As Byte, ByVal bScan As Byte, _ ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
poi ho messo nell'evento Tick di un controllo Timer questo codice che verifica lo stato del bloc num e se è spento lo riattiva
codice:
Sub CTRLBlockNumTick(ByVal sender As Object, ByVal e As EventArgs)
If My.Computer.Keyboard.NumLock = False Then
'simula la pressione del numlock
keybd_event(VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0)
'simula il rilascio del numlock
keybd_event(VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY _ Or KEYEVENTF_KEYUP, 0)
End If
End Sub
con l'intervallo impostato a 500 ms, si vede proprio che se provi a spegnere il bloc num, lo riattiva subito
Buona giornata, buon fine settimana e (ovviamente
) buon Natale a tutti !!!
Mauro