А проблема вот в чём, хук должен ловить нажатия во всем Windows, а у меня это получается только в окне... Что делать???
Код:
- Код: Выделить всё
Public Function KeyboardProc(ByVal idHook As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim u As Long, t As Long
Dim check As String
'On Error Resume Next
'if idHook is less than zero, no further processing is required
If idHook < 0 Then
'call the next hook
KeyboardProc = CallNextHookEx(hHook, idHook, wParam, ByVal lParam)
Else
If GetAsyncKeyState(wParam) = 0 Then IsPressed = False: KeyPressed = 0 Else IsPressed = True: KeyPressed = wParam
If Not GetKL.Language = "Русская раскладка" Then FrmMain.SetSvet 2: GoTo TheEnd
If GetKL.Language = "Русская раскладка" And FrmMain.Svet = 2 Then FrmMain.SetSvet 0
If FrmMain.lblmain.Caption = "Запись словаря..." Or FrmMain.lblmain.Caption = "Открытие словаря..." Or Left(FrmMain.lblmain.Caption, 11) = "Загрузка..." Then GoTo TheEnd
If KeyPressed = LastKey Then
If IsPressed Then
Do
q = q + KeyDelay / 10
Sleep KeyDelay / 10
DoEvents
If KeyDelay <= q Then Exit Do
Loop Until GetAsyncKeyState(wParam) = 0
If GetAsyncKeyState(wParam) = 0 Then GoTo TheEnd
Do
Sleep KeySpeed
virGetKey = GetLit(wParam)
If virGetKey = "8" Then
If Not sStr = "" Then sStr = Left(sStr, Len(sStr) - 1)
FrmMain.lblmain.Caption = sStr
ElseIf Not virGetKey = " " Then
If FrmMain.Svet = 1 And Not sStr = "" Then
sStr = ""
End If
sStr = sStr & virGetKey
If Not sStr = "" Then FrmMain.lblmain.Caption = sStr: FrmMain.SetSvet 0
End If
DoEvents
Loop Until GetAsyncKeyState(wParam) = 0
End If
virGetKey = ""
End If
'On Error Resume Next
If KeyPressed = LastKey Then GoTo TheEnd
virGetKey = GetKey(KeyPressed)
If virGetKey = "8" Then
If Not sStr = "" Then sStr = Left(sStr, Len(sStr) - 1)
FrmMain.lblmain.Caption = sStr
ElseIf Not virGetKey = "" And Not virGetKey = "2" Then
If FrmMain.Svet = 1 And Not sStr = "" Then
sStr = ""
End If
sStr = sStr & virGetKey
'lastLit = Right(sStr, 1)
'If Not virGetKey = Right(sStr, 1) Then FrmMain.lblmain.Caption = "ошибка"
If Not sStr = "" Then FrmMain.lblmain.Caption = sStr: FrmMain.SetSvet 0
ElseIf virGetKey = "2" Then
If Not sStr = "" Then
check = DicCompare(sStr)
If check = "ошибок нет" Or sStr = "-" Then
sStr = ""
FrmMain.SetSvet 3
FrmMain.lblmain.Caption = sStr
AllWords = AllWords + 1
Status.stRefresh
Else
u = 0
For t = 0 To Status.LstErr.ListCount Step 1
If Status.LstErr.List(t) = sStr Then u = 1
Next t
If u = 0 Then
Status.LstErr.AddItem sStr
AllWords = AllWords + 1
ErrWords = ErrWords + 1
Status.stRefresh
If check = "Ошибка" Then FrmMain.ShowToolTip check & " в слове: " & FrmMain.lblmain.Caption Else FrmMain.ShowToolTip check
sndPlaySound App.Path & "\error.wav", SND_ASYNC
FrmMain.SetSvet 1
Else
FrmMain.SetSvet 1
End If
End If
End If
End If
TheEnd:
IsPressed = False: LastKey = KeyPressed: KeyPressed = 0
KeyboardProc = CallNextHookEx(hHook, idHook, wParam, ByVal lParam)
End If
End Function
Помогите пожалуйста...