VB钩子问题
由于用条形码编程,想实时监控看是否有输入,如果有输入就触发其他事件并将截取信息保存到文本文件
可是每次截取的内容都重复了4次,不明白为什么??
Public Function MyKBHook(ByVal ncode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim i
Dim strtemp
If ncode >= 0 Then
If (wParam >= 48 And wParam <= 58) Then
idstr = Trim(idstr) + Trim(Str(wParam - 48))
Open "C:\Keyfile.txt" For Append As #1
Write #1, "=============================================================="
Write #1, wParam - 48, lParam, Date, Time
Close #1
End If
If wParam = 13 Then
For i = 1 To Len(idstr)
strtemp = strtemp + Trim(Mid(idstr, i, 1))
i = i + 3
Next i
Form1.Text2.Text = ""
Form1.Text2.Text = Trim(strtemp)
strtemp = ""
End If
End If
Call CallNextHookEx(hHook, ncode, wParam, lParam) '½«ÏûÏ¢´«¸øÏÂÒ»¸ö¹³×Ó
End Function