Je cherche un moyen de r=E9cup=E9rer dans un fichier texte les=20
caract=E8res qui ont =E9t=E9 saisis au clavier. J'ai essay=E9 avec=20
Private Sub Form_KeyPress(KeyAscii As Integer) mais seul=20
le premier =E9v=E8nement est pris en compte donc seulement le=20
premier caractere tapp=E9.
J'aurai besoin de votre aide si qqn en connais la r=E9ponse
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
ng
Salut,
Voici un exemple de l'API-Guide nommé Key spy (je pense que c'est ce que tu veux faire non ;-)?)
'In a module Public Const DT_CENTER = &H1 Public Const DT_WORDBREAK = &H10 Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Declare Function DrawTextEx Lib "user32" Alias "DrawTextExA" (ByVal hDC As Long, ByVal lpsz As String, ByVal n As Long, lpRect As RECT, ByVal un As Long, ByVal lpDrawTextParams As Any) As Long Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long Global Cnt As Long, sSave As String, sOld As String, Ret As String Dim Tel As Long Function GetPressedKey() As String For Cnt = 32 To 128 'Get the keystate of a specified key If GetAsyncKeyState(Cnt) <> 0 Then GetPressedKey = Chr$(Cnt) Exit For End If Next Cnt End Function Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) Ret = GetPressedKey If Ret <> sOld Then sOld = Ret sSave = sSave + sOld End If End Sub
'In a form Private Sub Form_Load() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: Me.Caption = "Key Spy" 'Create an API-timer SetTimer Me.hwnd, 0, 1, AddressOf TimerProc End Sub Private Sub Form_Paint() Dim R As RECT Const mStr = "Start this project, go to another application, type something, switch back to this application and unload the form. If you unload the form, a messagebox with all the typed keys will be shown." 'Clear the form Me.Cls 'API uses pixels Me.ScaleMode = vbPixels 'Set the rectangle's values SetRect R, 0, 0, Me.ScaleWidth, Me.ScaleHeight 'Draw the text on the form DrawTextEx Me.hDC, mStr, Len(mStr), R, DT_WORDBREAK Or DT_CENTER, ByVal 0& End Sub Private Sub Form_Resize() Form_Paint End Sub Private Sub Form_Unload(Cancel As Integer) 'Kill our API-timer KillTimer Me.hwnd, 0 'Show all the typed keys MsgBox sSave End Sub
Nicolas. "Cindy" a écrit dans le message de news: 06a701c3a6db$cca5c350$ Bonsoir,
Je cherche un moyen de récupérer dans un fichier texte les caractères qui ont été saisis au clavier. J'ai essayé avec Private Sub Form_KeyPress(KeyAscii As Integer) mais seul le premier évènement est pris en compte donc seulement le premier caractere tappé.
J'aurai besoin de votre aide si qqn en connais la réponse
Merci d'avance.
Salut,
Voici un exemple de l'API-Guide nommé Key spy (je pense que c'est ce que tu
veux faire non ;-)?)
'In a module
Public Const DT_CENTER = &H1
Public Const DT_WORDBREAK = &H10
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Declare Function DrawTextEx Lib "user32" Alias "DrawTextExA" (ByVal hDC As
Long, ByVal lpsz As String, ByVal n As Long, lpRect As RECT, ByVal un As
Long, ByVal lpDrawTextParams As Any) As Long
Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent
As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent
As Long) As Long
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As
Integer
Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long,
ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Global Cnt As Long, sSave As String, sOld As String, Ret As String
Dim Tel As Long
Function GetPressedKey() As String
For Cnt = 32 To 128
'Get the keystate of a specified key
If GetAsyncKeyState(Cnt) <> 0 Then
GetPressedKey = Chr$(Cnt)
Exit For
End If
Next Cnt
End Function
Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As
Long, ByVal lpTimerFunc As Long)
Ret = GetPressedKey
If Ret <> sOld Then
sOld = Ret
sSave = sSave + sOld
End If
End Sub
'In a form
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Me.Caption = "Key Spy"
'Create an API-timer
SetTimer Me.hwnd, 0, 1, AddressOf TimerProc
End Sub
Private Sub Form_Paint()
Dim R As RECT
Const mStr = "Start this project, go to another application, type
something, switch back to this application and unload the form. If you
unload the form, a messagebox with all the typed keys will be shown."
'Clear the form
Me.Cls
'API uses pixels
Me.ScaleMode = vbPixels
'Set the rectangle's values
SetRect R, 0, 0, Me.ScaleWidth, Me.ScaleHeight
'Draw the text on the form
DrawTextEx Me.hDC, mStr, Len(mStr), R, DT_WORDBREAK Or DT_CENTER, ByVal
0&
End Sub
Private Sub Form_Resize()
Form_Paint
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Kill our API-timer
KillTimer Me.hwnd, 0
'Show all the typed keys
MsgBox sSave
End Sub
Nicolas.
"Cindy" <anonymous@discussions.microsoft.com> a écrit dans le message de
news: 06a701c3a6db$cca5c350$a501280a@phx.gbl...
Bonsoir,
Je cherche un moyen de récupérer dans un fichier texte les
caractères qui ont été saisis au clavier. J'ai essayé avec
Private Sub Form_KeyPress(KeyAscii As Integer) mais seul
le premier évènement est pris en compte donc seulement le
premier caractere tappé.
J'aurai besoin de votre aide si qqn en connais la réponse
Voici un exemple de l'API-Guide nommé Key spy (je pense que c'est ce que tu veux faire non ;-)?)
'In a module Public Const DT_CENTER = &H1 Public Const DT_WORDBREAK = &H10 Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Declare Function DrawTextEx Lib "user32" Alias "DrawTextExA" (ByVal hDC As Long, ByVal lpsz As String, ByVal n As Long, lpRect As RECT, ByVal un As Long, ByVal lpDrawTextParams As Any) As Long Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long Global Cnt As Long, sSave As String, sOld As String, Ret As String Dim Tel As Long Function GetPressedKey() As String For Cnt = 32 To 128 'Get the keystate of a specified key If GetAsyncKeyState(Cnt) <> 0 Then GetPressedKey = Chr$(Cnt) Exit For End If Next Cnt End Function Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) Ret = GetPressedKey If Ret <> sOld Then sOld = Ret sSave = sSave + sOld End If End Sub
'In a form Private Sub Form_Load() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: Me.Caption = "Key Spy" 'Create an API-timer SetTimer Me.hwnd, 0, 1, AddressOf TimerProc End Sub Private Sub Form_Paint() Dim R As RECT Const mStr = "Start this project, go to another application, type something, switch back to this application and unload the form. If you unload the form, a messagebox with all the typed keys will be shown." 'Clear the form Me.Cls 'API uses pixels Me.ScaleMode = vbPixels 'Set the rectangle's values SetRect R, 0, 0, Me.ScaleWidth, Me.ScaleHeight 'Draw the text on the form DrawTextEx Me.hDC, mStr, Len(mStr), R, DT_WORDBREAK Or DT_CENTER, ByVal 0& End Sub Private Sub Form_Resize() Form_Paint End Sub Private Sub Form_Unload(Cancel As Integer) 'Kill our API-timer KillTimer Me.hwnd, 0 'Show all the typed keys MsgBox sSave End Sub
Nicolas. "Cindy" a écrit dans le message de news: 06a701c3a6db$cca5c350$ Bonsoir,
Je cherche un moyen de récupérer dans un fichier texte les caractères qui ont été saisis au clavier. J'ai essayé avec Private Sub Form_KeyPress(KeyAscii As Integer) mais seul le premier évènement est pris en compte donc seulement le premier caractere tappé.
J'aurai besoin de votre aide si qqn en connais la réponse
Merci d'avance.
surfeur75
Bonjour,
He ça marche ton truc! Tous les signes sont pris en compte, voici ce que j'ai fait:
Sub List1_KeyPress(KeyAscii As Integer) List1.AddItem KeyAscii End Sub
Donc une liste (list1) en objet, mais tu peux faire à ta guise, voici ce que ça donne dans la lsite (tout y est): 98 111 110 106 111 117 114 = bonjour -- @+, bye, Joe. Pour m'écrire ng75AROBASEnoosPOINTfr Il l'a fait car il ne savait pas que c'était impossible, alea jacta est!
"Cindy" a écrit dans le message de news: 06a701c3a6db$cca5c350$ Bonsoir,
Je cherche un moyen de récupérer dans un fichier texte les caractères qui ont été saisis au clavier. J'ai essayé avec Private Sub Form_KeyPress(KeyAscii As Integer) mais seul le premier évènement est pris en compte donc seulement le premier caractere tappé.
J'aurai besoin de votre aide si qqn en connais la réponse
Merci d'avance.
Bonjour,
He ça marche ton truc! Tous les signes sont pris en compte, voici ce que
j'ai fait:
Sub List1_KeyPress(KeyAscii As Integer)
List1.AddItem KeyAscii
End Sub
Donc une liste (list1) en objet, mais tu peux faire à ta guise, voici ce que
ça donne dans la lsite (tout y est):
98
111
110
106
111
117
114 = bonjour
--
@+, bye, Joe.
Pour m'écrire ng75AROBASEnoosPOINTfr
Il l'a fait car il ne savait pas que c'était impossible, alea jacta est!
"Cindy" <anonymous@discussions.microsoft.com> a écrit dans le message de
news: 06a701c3a6db$cca5c350$a501280a@phx.gbl...
Bonsoir,
Je cherche un moyen de récupérer dans un fichier texte les
caractères qui ont été saisis au clavier. J'ai essayé avec
Private Sub Form_KeyPress(KeyAscii As Integer) mais seul
le premier évènement est pris en compte donc seulement le
premier caractere tappé.
J'aurai besoin de votre aide si qqn en connais la réponse
He ça marche ton truc! Tous les signes sont pris en compte, voici ce que j'ai fait:
Sub List1_KeyPress(KeyAscii As Integer) List1.AddItem KeyAscii End Sub
Donc une liste (list1) en objet, mais tu peux faire à ta guise, voici ce que ça donne dans la lsite (tout y est): 98 111 110 106 111 117 114 = bonjour -- @+, bye, Joe. Pour m'écrire ng75AROBASEnoosPOINTfr Il l'a fait car il ne savait pas que c'était impossible, alea jacta est!
"Cindy" a écrit dans le message de news: 06a701c3a6db$cca5c350$ Bonsoir,
Je cherche un moyen de récupérer dans un fichier texte les caractères qui ont été saisis au clavier. J'ai essayé avec Private Sub Form_KeyPress(KeyAscii As Integer) mais seul le premier évènement est pris en compte donc seulement le premier caractere tappé.
J'aurai besoin de votre aide si qqn en connais la réponse