|
| Autor |
Nachricht |
pixel-shock Newbie

Anmeldedatum: 15.06.2009 Beiträge: 2
|
ShortCuts auf Desktop anzeigen
Verfasst am: 15.06.2009, 13:38 |
|
|
Hi,
ich bin heute das erste Mal in VB zugange und habe natürlich erstmal ein paar Fragen, von denen ich hoffe, dass ich diese hier beantwortet bekomme oder zumindest Tipps bekomme
Ich möchte mir ein echt kleines Programm schreiben, welches mir in einer TextBox die aktuell gedrückten Tasten anzeigt, nicht mehr und nicht weniger ... also kein riesen Programm oder ähnliches.
Jetzt habe ich mir schon ein paar KeyLogger angeschaut, aber so richtig weitergekommen bin ich damit noch nicht ...
| Code: |
Public Class MainScreen
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
On Error Resume Next
Dim keystate As Integer
Dim scancodes As Integer
Dim keypressed As String
Do
Sleep(10)
For scancodes = 1 To 254
keystate = GetAsyncKeyState(scancodes)
If keystate = -32767 Then
keypressed = Chr(scancodes)
If scancodes = 32 Then
keypressed = " "
End If
If scancodes = 13 Then
keypressed = "[ENTER]"
End If
If scancodes = 46 Then
keypressed = "[DELETE]"
End If
End If
Next
Loop
End Sub
Private Sub ShortCutLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub ShortCutTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShortCutTextBox.TextChanged
End Sub
Private Sub CloseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseButton.Click
End
End Sub
End Class
|
Soweit bin ich bisher ... der Quellcode zum KeyLoggen ist hier aus dem Forum, leider gab es dazu keine weitere Erklärung.
Das 1. Problem was ich jetzt habe ist, dass die Schleife die ganze Zeit läuft und somit das Programm erst garnicht zur "Anzeige kommt" ... sprich der hängt dann an der Stelle fest.
Das 2. Problem ist dann, die gedrückten Tasten einfach nur im Textfeld anzuzeigen
Ich freue mich über jeden Tipp
DANKE & LG |
|
| |
|
 |
pixel-shock Newbie

Anmeldedatum: 15.06.2009 Beiträge: 2
|
Verfasst am: 15.06.2009, 16:51 |
|
|
So ..
habe mich schonmal weiter vorgekämpft ...
| Code: |
Public Class MainScreen
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Long
' GetAsyncKeyState vKey-Konstanten
Private Const VK_LBUTTON = &H1 ' Linker Mausbutton
Private Const VK_RBUTTON = &H2 ' Rechter Mausbutton
Private Const VK_MBUTTON = &H4 ' Mittlerer Mausbutton
Private Const VK_BACK = &H8 ' Backspace Taste
Private Const VK_TAB = &H9 ' Tab Taste
Private Const VK_CLEAR = &HC ' Numpad 5 ohne Numlock
Private Const VK_RETURN = &HD ' Enter Taste
Private Const VK_SHIFT = &H10 ' Shift Taste
Private Const VK_CONTROL = &H11 ' STRG Taste
Private Const VK_MENU = &H12 ' Alt Taste
Private Const VK_PAUSE = &H13 ' Pause/Untbr
Private Const VK_CAPITAL = &H14 ' Caps Lock/Feststelltaste
Private Const VK_ESCAPE = &H1B ' Escape
Private Const VK_SPACE = &H20 ' Space/Leertaste
Private Const VK_PRIOR = &H21 ' PageUp/Bild hoch
Private Const VK_NEXT = &H22 ' PageDown/Bild runter
Private Const VK_END = &H23 ' Ende
Private Const VK_HOME = &H24 ' Home/Pos1
Private Const VK_LEFT = &H25 ' Linke Pfeiltaste
Private Const VK_UP = &H26 ' Obere Pfeiltaste
Private Const VK_RIGHT = &H27 ' Rechte Pfeiltaste
Private Const VK_DOWN = &H28 ' Untere Pfeiltaste
Private Const VK_PRINT = &H2A ' Drucken (Nokia Tastaturen)
Private Const VK_SNAPSHOT = &H2C ' Drucken/S-Abf
Private Const VK_INSERT = &H2D ' Einfügen
Private Const VK_DELETE = &H2E ' Entfernen
Private Const VK_HELP = &H2F ' Hilfe
Private Const VK_0 = &H30 ' Taste 0
Private Const VK_1 = &H31 ' Taste 1
Private Const VK_2 = &H32 ' Taste 2
Private Const VK_3 = &H33 ' Taste 3
Private Const VK_4 = &H34 ' Taste 4
Private Const VK_5 = &H35 ' Taste 5
Private Const VK_6 = &H36 ' Taste 6
Private Const VK_7 = &H37 ' Taste 7
Private Const VK_8 = &H38 ' Taste 8
Private Const VK_9 = &H39 ' Taste 9
Private Const VK_A = &H41 ' Taste A
Private Const VK_B = &H42 ' Taste B
Private Const VK_C = &H43 ' Taste C
Private Const VK_D = &H44 ' Taste D
Private Const VK_E = &H45 ' Taste E
Private Const VK_F = &H46 ' Taste F
Private Const VK_G = &H47 ' Taste G
Private Const VK_H = &H48 ' Taste H
Private Const VK_I = &H49 ' Taste I
Private Const VK_J = &H4A ' Taste J
Private Const VK_K = &H4B ' Taste K
Private Const VK_L = &H4C ' Taste L
Private Const VK_M = &H4D ' Taste M
Private Const VK_N = &H4E ' Taste N
Private Const VK_O = &H4F ' Taste O
Private Const VK_P = &H50 ' Taste P
Private Const VK_Q = &H51 ' Taste Q
Private Const VK_R = &H52 ' Taste R
Private Const VK_S = &H53 ' Taste S
Private Const VK_T = &H54 ' Taste T
Private Const VK_U = &H55 ' Taste U
Private Const VK_V = &H56 ' Taste V
Private Const VK_W = &H57 ' Taste W
Private Const VK_X = &H58 ' Taste X
Private Const VK_Y = &H59 ' Taste Y
Private Const VK_Z = &H5A ' Taste Z
Private Const VK_STARTKEY = &H5B ' Startmenütaste
Private Const VK_CONTEXTKEY = &H5D ' Kentextmenü
Private Const VK_NUMPAD0 = &H60 ' Numpad Taste 0
Private Const VK_NUMPAD1 = &H61 ' Numpad Taste 1
Private Const VK_NUMPAD2 = &H62 ' Numpad Taste 2
Private Const VK_NUMPAD3 = &H63 ' Numpad Taste 3
Private Const VK_NUMPAD4 = &H64 ' Numpad Taste 4
Private Const VK_NUMPAD5 = &H65 ' Numpad Taste 5
Private Const VK_NUMPAD6 = &H66 ' Numpad Taste 6
Private Const VK_NUMPAD7 = &H67 ' Numpad Taste 7
Private Const VK_NUMPAD8 = &H68 ' Numpad Taste 8
Private Const VK_NUMPAD9 = &H69 ' Numpad Taste 9
Private Const VK_MULTIPLY = &H6A ' Numpad Multiplikations Taste (*)
Private Const VK_ADD = &H6B ' Numpad Additions Taste (+)
Private Const VK_SUBTRACT = &H6D ' Numpad Subtrations Taste (-)
Private Const VK_DECIMAL = &H6E ' Numpad Komma Taste (,)
Private Const VK_DIVIDE = &H6F ' Numpad Devidierungs Taste (/)
Private Const VK_F1 = &H70 ' F1 Taste
Private Const VK_F2 = &H71 ' F2 Taste
Private Const VK_F3 = &H72 ' F3 Taste
Private Const VK_F4 = &H73 ' F4 Taste
Private Const VK_F5 = &H74 ' F5 Taste
Private Const VK_F6 = &H75 ' F6 Taste
Private Const VK_F7 = &H76 ' F7 Taste
Private Const VK_F8 = &H77 ' F8 Taste
Private Const VK_F9 = &H78 ' F9 Taste
Private Const VK_F10 = &H79 ' F10 Taste
Private Const VK_F11 = &H7A ' F11 Taste
Private Const VK_F12 = &H7B ' F12 Taste
Private Const VK_F13 = &H7C ' F13 Taste
Private Const VK_F14 = &H7D ' F14 Taste
Private Const VK_F15 = &H7E ' F15 Taste
Private Const VK_F16 = &H7F ' F16 Taste
Private Const VK_F17 = &H80 ' F17 Taste
Private Const VK_F18 = &H81 ' F18 Taste
Private Const VK_F19 = &H82 ' F19 Taste
Private Const VK_F20 = &H83 ' F20 Taste
Private Const VK_F21 = &H84 ' F21 Taste
Private Const VK_F22 = &H85 ' F22 Taste
Private Const VK_F23 = &H86 ' F23 Taste
Private Const VK_F24 = &H87 ' F24 Taste
Private Const VK_NUMLOCK = &H90 ' Numlock Taste
Private Const VK_OEM_SCROLL = &H91 ' Scroll Lock
Private Const VK_LSHIFT = &HA0 ' Linke Shift-Taste
Private Const VK_RSHIFT = &HA1 ' Rechte Shift-Taste
Private Const VK_LCONTROL = &HA2 ' Linke STRG-Taste
Private Const VK_RCONTROL = &HA3 ' Rechte STRG-Taste
Private Const VK_LMENU = &HA4 ' Linke ALT-Taste
Private Const VK_RMENU = &HA5 ' Rechte ALT-Taste
Private Const VK_OEM_1 = &HBA ' ";"-Taste
Private Const VK_OEM_PLUS = &HBB ' "
Private Const VK_OEM_COMMA = &HBC ' ","-Taste
Private Const VK_OEM_MINUS = &HBD ' "-"-Taste
Private Const VK_OEM_PERIOD = &HBE ' "."-taste
Private Const VK_OEM_2 = &HBF ' "/"-Taste
Private Const VK_OEM_3 = &HC0 ' "`"-Taste
Private Const VK_OEM_4 = &HDB ' "["-Taste
Private Const VK_OEM_5 = &HDC ' "\"-Taste
Private Const VK_OEM_6 = &HDD ' "]"-Taste
Private Const VK_OEM_7 = &HDE ' "
Private Const VK_ICO_F17 = &HE0 ' F17 einer Olivette Tastatur (Intern)
Private Const VK_ICO_F18 = &HE1 ' F18 einer Olivette Tastatur (Intern)
Private Const VK_OEM102 = &HE2 ' "<"-Taste oder "|"-Taste einer
' IBM-Kompatiblen 102 Tastatur (Nicht US)
Private Const VK_ICO_HELP = &HE3 ' Hilfetaste einer Olivetti Tastatur (Intern)
Private Const VK_ICO_00 = &HE4 ' 00-Taste einer Olivetti Tastatur (Intern)
Private Const VK_ICO_CLEAR = &HE6 ' Löschen Taste einer Olivetti Tastatur (Intern)
Private Const VK_OEM_RESET = &HE9 ' Reset Taste (Nokia)
Private Const VK_OEM_JUMP = &HEA ' Springen Taste (Nokia)
Private Const VK_OEM_PA1 = &HEB ' PA1 Taste (Nokia)
Private Const VK_OEM_PA2 = &HEC ' PA2 Taste (Nokia)
Private Const VK_OEM_PA3 = &HED ' PA3 Taste (Nokia)
Private Const VK_OEM_WSCTRL = &HEE ' WSCTRL Taste (Nokia)
Private Const VK_OEM_CUSEL = &HEF ' WSCTRL Taste (Nokia)
Private Const VK_OEM_ATTN = &HF0 ' ATTN Taste (Nokia)
Private Const VK_OEM_FINNISH = &HF1 ' Fertig Taste (Nokia)
Private Const VK_OEM_COPY = &HF2 ' Kopieren Taste (Nokia)
Private Const VK_OEM_AUTO = &HF3 ' Auto Taste (Nokia)
Private Const VK_OEM_ENLW = &HF4 ' ENLW Taste (Nokia)
Private Const VK_OEM_BACKTAB = &HF5 ' BackTab Taste (Nokia)
Private Const VK_ATTN = &HF6 ' ATTN-Taste
Private Const VK_CRSEL = &HF7 ' CRSEL-Taste
Private Const VK_EXSEL = &HF8 ' EXSEL-Taste
Private Const VK_EREOF = &HF9 ' EREOF-Taste
Private Const VK_PLAY = &HFA ' PLAY-Taste
Private Const VK_ZOOM = &HFB ' ZOOM-Taste
Private Const VK_NONAME = &HFC ' NONAME-Taste
Private Const VK_PA1 = &HFD ' PA1-Taste
Private Const VK_OEM_CLEAR = &HFE ' OEM_CLEAR-Taste
Dim mouseOffset As Point
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Timer1 As New Timer()
AddHandler Timer1.Tick, AddressOf Timer1_Tick
Timer1.Interval = 10
Timer1.Start()
End Sub
Private Sub ShortCutTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub CloseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown
mouseOffset = New Point(-e.X, -e.Y)
If e.Button = Windows.Forms.MouseButtons.Right Then
End
End If
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
Dim mousePos As Point = Control.MousePosition
mousePos.Offset(mouseOffset.X, mouseOffset.Y)
Location = mousePos
End If
End Sub
Private Sub Timer1_Tick(ByVal obj As Object, ByVal e As EventArgs)
Dim i As Integer
For i = 65 To 90
If (GetAsyncKeyState(i) And &H8000) = &H8000 Then
If (InStr(ShortCutTextBox.Text, UCase(Chr(i)), CompareMethod.Binary) = 0) Then
If (Len(ShortCutTextBox.Text) > 0) Then
ShortCutTextBox.Text = Trim(ShortCutTextBox.Text + " " + UCase(Chr(i)))
Else
ShortCutTextBox.Text = Trim(ShortCutTextBox.Text + UCase(Chr(i)))
End If
End If
ElseIf (GetAsyncKeyState(VK_MENU) And &H8000) = &H8000 Then
If (InStr(ShortCutTextBox.Text, "ALT", CompareMethod.Binary) = 0) Then
If (Len(ShortCutTextBox.Text) > 0) Then
ShortCutTextBox.Text = Trim(ShortCutTextBox.Text + " ALT")
Else
ShortCutTextBox.Text = Trim(ShortCutTextBox.Text + "ALT")
End If
End If
ElseIf (GetAsyncKeyState(VK_SHIFT) And &H8000) = &H8000 Then
If (InStr(ShortCutTextBox.Text, "SHIFT", CompareMethod.Binary) = 0) Then
If (Len(ShortCutTextBox.Text) > 0) Then
ShortCutTextBox.Text = Trim(ShortCutTextBox.Text + " SHIFT")
Else
ShortCutTextBox.Text = Trim(ShortCutTextBox.Text + "SHIFT")
End If
End If
ElseIf (GetAsyncKeyState(VK_SPACE) And &H8000) = &H8000 Then
If (InStr(ShortCutTextBox.Text, "SPACE", CompareMethod.Binary) = 0) Then
If (Len(ShortCutTextBox.Text) > 0) Then
ShortCutTextBox.Text = Trim(ShortCutTextBox.Text + " SPACE")
Else
ShortCutTextBox.Text = Trim(ShortCutTextBox.Text + "SPACE")
End If
End If
ElseIf (GetAsyncKeyState(VK_CONTROL) And &H8000) = &H8000 Then
If (InStr(ShortCutTextBox.Text, "STRG", CompareMethod.Binary) = 0) Then
If (Len(ShortCutTextBox.Text) > 0) Then
ShortCutTextBox.Text = Trim(ShortCutTextBox.Text + " STRG")
Else
ShortCutTextBox.Text = Trim(ShortCutTextBox.Text + "STRG")
End If
End If
Else
ShortCutTextBox.Text = Trim(Replace(ShortCutTextBox.Text, " ", " ", 1, -1, CompareMethod.Binary))
ShortCutTextBox.Text = Trim(Replace(ShortCutTextBox.Text, UCase(Chr(i)), "", 1, -1, CompareMethod.Binary))
End If
Next i
' Wenn keine Taste gedrück wird, dann wieder ausblenden ... vielleicht hau ich hier noch nen Fade rein, damit das
' schön smooth läuft, sonst ist das so "abgehackt"
If (Len(ShortCutTextBox.Text) = 0) Then
Hide()
Else
Show()
End If
End Sub
End Class
|
Ich frage mich aber grade, ob ich im Timer nicht prüfen kann, ob eine meiner Contstants gedrückt wurde, also ohne für jede Sondertaste (ALT etc) eine extra Abfrage zu machen?
LG |
|
| |
|
 |
|
|