Bonjour,
Comment faire un hook clavier en vbs ?
Merci.
Version imprimable
Bonjour,
Comment faire un hook clavier en vbs ?
Merci.
InputBox?:mrgreen:
oui mais je voudrais faire un hook sans avoir le focus.
Ex: je lance mon script, je lance word, j'écris dans word, le script ecrit ce que jécris dans word dans un fichier .txt
Voila le code qui sert a récupérer la touche appuyée en VB:
Quelqu'un de très doué en VB et VBS pourrait passer ce bout de code dans une boucle/loop dans un script VBS qui renverrai la touche appuyé dans un fichier txt temps que le sript tourne ?Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 Private Declare Function ToAscii Lib "user32.dll" (ByVal uVirtKey As Long, ByVal uScanCode As Long, ByRef lpbKeyState As Byte, ByRef lpwTransKey As Long, ByVal fuState As Long) As Long Private Declare Function GetKeyboardState Lib "user32.dll" (ByRef pbKeyState As Byte) As Long Private Function GetCharFromKey(ByVal KeyCode As Integer) As String Dim KeyBoardState(255) As Byte Dim Out As Long If GetKeyboardState(KeyBoardState(0)) <> 0 Then If ToAscii(KeyCode, 0, KeyBoardState(0), Out, 0) <> 0 Then If Out <= 255 Then GetCharFromKey = Chr$(Out) Else GetCharFromKey = Left$(StrConv(ChrW$(Out), vbUnicode), 1) End If End If End If End Function