|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Feb 2001
Città: Reggio Emilia
Messaggi: 230
|
Bloc Maiusc E Win 2000
Perchè questa sub di access in windows 2000 non funziona correttamente? praticamente non accende il led sulla tastiera.
Sotto windows 98 tutto ok, all'apertura del form imposta automaticamente il tasto caps lock come inserito e il led relativo acceso. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long Sub SetCapsLock(ByVal bnewValue As Boolean) ' get current state of all 256 virtual keys Dim keystat(0 To 255) As Byte GetKeyboardState keystat(0) ' modify bit 0 of the relevant item, and store back keystat(vbKeyCapital) = (keystat(vbKeyCapital) And &HFE) Or (bnewValue And 1) SetKeyboardState keystat(0) End Sub Private Sub Form_Open(Cancel As Integer) SetCapsLock True End Sub |
|
|
|
|
|
#2 |
|
Member
Iscritto dal: Feb 2001
Città: Reggio Emilia
Messaggi: 230
|
per Cionci
grazie mille!!
P.S. perchè hai cancellato la risposta? |
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Non l'ho cancellata... Il forum ha avuto problemi... Leggi l'annuncio in rilievo in tutte le sezioni...
Postala che potrebbe servire a qualcuno... Io non l'ho salvata... Comunque sei capitato proprio a puntino...stavo facendo esperimenti proprio con keybd_event... |
|
|
|
|
|
#4 |
|
Member
Iscritto dal: Feb 2001
Città: Reggio Emilia
Messaggi: 230
|
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2 Private Declare Sub keybd_event Lib "user32.dll" (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 Sub SetCapsLock(ByVal bnewValue As Boolean) ' get current state of all 256 virtual keys Dim keystat(0 To 255) As Byte GetKeyboardState keystat(0) ' modify bit 0 of the relevant item, and store back If keystat(vbKeyCapital) <> ((keystat(vbKeyCapital) And &HFE) Or (bnewValue And 1)) Then keybd_event 20, vbKeyCapital, KEYEVENTF_EXTENDEDKEY, 0 keybd_event 20, vbKeyCapital, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0 End If End Sub |
|
|
|
|
|
#5 |
|
Member
Iscritto dal: Feb 2001
Città: Reggio Emilia
Messaggi: 230
|
Perchè il mio codice funziona in win 98 e non in win 2000
potresti illustrarmi la tua modifica? |
|
|
|
|
|
#6 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Secondo MSDN :
Because the SetKeyboardState function alters the input state of the calling thread and not the global input state of the system, an application cannot use SetKeyboardState to set the NUM LOCK, CAPS LOCK, or SCROLL LOCK (or the Japanese KANA) indicator lights on the keyboard. These can be set or cleared using SendInput to simulate keystrokes. In teoria non dovrebbe funzionare nemmeno in 98... keybd_event è una alternativa a SendInput per inviare solamente eventi di tastiera... La costante 20 che passo come primo parametro è il Virtual Key corrispondente al CAPS LOCK... |
|
|
|
|
|
#7 |
|
Member
Iscritto dal: Feb 2001
Città: Reggio Emilia
Messaggi: 230
|
Ti assicuro che funziona benissimo
provalo |
|
|
|
|
|
#8 | |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Quote:
|
|
|
|
|
|
|
#9 |
|
Member
Iscritto dal: Feb 2001
Città: Reggio Emilia
Messaggi: 230
|
come posso avere una lista delle costanti virtual key della tastiera?
|
|
|
|
|
|
#10 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
C'è su MSDN alla voce "Virtual Key Codes"...
Se non ce l'hai te lo incollo nel thread... |
|
|
|
|
|
#11 |
|
Member
Iscritto dal: Feb 2001
Città: Reggio Emilia
Messaggi: 230
|
Non le ho trovate, potresti essere più preciso?
|
|
|
|
|
|
#12 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/VirtualKeyCodes.asp
|
|
|
|
|
|
#13 |
|
Member
Iscritto dal: Feb 2001
Città: Reggio Emilia
Messaggi: 230
|
Sei grande
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 12:31.



















