Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

lecture touche clavier ?

1 réponse
Avatar
prieur
dans un tableau XL,suite =E0 une action sur une touche,une=20
macro est d=E9clench=E9e(worksheet_change)par enter ou appui=20
sur une touche fl=E8che. Comment conna=EEtre la touche Enter=20
ou fl=E8che qui a =E9t=E9 appuy=E9e?

1 réponse

Avatar
Hervé
Salut Prieur,
Dur Jacquouille hein ? mais il a tout à fait raison avec un bonjour, un SVP
et un merci on passe partout. Bon pour ta question regarde si cela te
convient, avec fonction API sur Worksheet_SelectionChange, adapte :

Private Declare Function GetKeyState _
Lib "user32" (ByVal nVirtKey As Long) As Integer

Private Const VK_RETURN = &HD
Private Const VK_DOWN = &H28
Private Const VK_UP = &H26
Private Const VK_LEFT = &H25
Private Const VK_RIGHT = &H27
Private Const VK_TAB = &H9
Private Const VK_LBUTTON = &H1
Private Const VK_RBUTTON = &H2

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If GetKeyState(VK_RETURN) < 0 Then
MsgBox "Touche Entrée"
ElseIf GetKeyState(VK_DOWN) < 0 Then
MsgBox "Flèche vers le bas"
ElseIf GetKeyState(VK_UP) < 0 Then
MsgBox "Flèche vers le haut"
ElseIf GetKeyState(VK_LEFT) < 0 Then
MsgBox "Flèche vers la gauche"
ElseIf GetKeyState(VK_RIGHT) < 0 Then
MsgBox "Flèche vers la droite"
ElseIf GetKeyState(VK_TAB) < 0 Then
MsgBox "Touche tabulation"
ElseIf GetKeyState(VK_LBUTTON) = 1 Then
MsgBox "bouton gauche souris"
ElseIf GetKeyState(VK_RBUTTON) < 0 Then
MsgBox "bouton droit souris"
End If
End Sub

Salutations.
Hervé.

"prieur" a écrit dans le message news:
00be01c33ffb$fec720f0$
dans un tableau XL,suite à une action sur une touche,une
macro est déclenchée(worksheet_change)par enter ou appui
sur une touche flèche. Comment connaître la touche Enter
ou flèche qui a été appuyée?