1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
Option Explicit
' Déclaration des fonctions de la bibliothèque Windows API
Private Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As LongPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare PtrSafe Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWndParent As LongPtr, ByVal hWndChildAfter As LongPtr, ByVal lpszClass As String, ByVal lpszWindow As String) As LongPtr
' Constantes pour les messages Windows API
Private Const WM_APPCOMMAND As Long = &H319
Private Const FAPPCOMMAND_KEYDOWN As Long = &H1000
Private Const FAPPCOMMAND_KEYUP As Long = &H2000
Private Const VK_VOLUME_UP As Long = &HAF
Private Const VK_VOLUME_DOWN As Long = &HAE
Sub AllumerToucheCouleur(ByVal Couleur As Long)
' Trouver la fenêtre du clavier
Dim hWnd As LongPtr
hWnd = FindWindowEx(0, 0, "IPTip_Main_Window", vbNullString)
' Envoyer un message pour allumer une touche de couleur
SendMessage hWnd, WM_APPCOMMAND, 0, FAPPCOMMAND_KEYDOWN And Couleur
End Sub
Sub EteindreTouche()
' Trouver la fenêtre du clavier
Dim hWnd As LongPtr
hWnd = FindWindowEx(0, 0, "IPTip_Main_Window", vbNullString)
' Envoyer un message pour éteindre la touche
SendMessage hWnd, WM_APPCOMMAND, 0, FAPPCOMMAND_KEYUP
End Sub
Sub TesterAllumerToucheCouleur()
' Allumer une touche de couleur (par exemple, rouge)
AllumerToucheCouleur &HFF0000 ' Rouge
End Sub
Sub TesterEteindreTouche()
' Éteindre la touche
EteindreTouche
End Sub |
Partager