vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
TOP-Angebot: 17 bzw. 24 Entwickler-Vollversionen zum unschlagbaren Preis!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Visual-Basic Einsteiger
Re: Prüfen ob irgendeine Taste gedrückt wurde? 
Autor: WarLocK1912
Datum: 13.02.03 11:18

Hallo

dies hier kommt aus dem API-Guide 3.7
http://www.allapi.net
'In a module
Public Const DT_CENTER = &H1
Public Const DT_WORDBREAK = &H10
Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
Declare Function DrawTextEx Lib "user32" Alias "DrawTextExA" (ByVal hDC As _
  Long, ByVal lpsz As String, ByVal n As Long, lpRect As RECT, ByVal un As _
  Long, ByVal lpDrawTextParams As Any) As Long
Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As _
Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As _
Long) As Long
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal _
  Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Global Cnt As Long, sSave As String, sOld As String, Ret As String
Dim Tel As Long
Function GetPressedKey() As String
    For Cnt = 32 To 128
        'Get the keystate of a specified key
        If GetAsyncKeyState(Cnt) <> 0 Then
            GetPressedKey = Chr$(Cnt)
            Exit For
        End If
    Next Cnt
End Function
Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As _
  Long, ByVal lpTimerFunc As Long)
    Ret = GetPressedKey
    If Ret <> sOld Then
        sOld = Ret
        sSave = sSave + sOld
    End If
End Sub
 
'In a form
Private Sub Form_Load()
    'KPD-Team 1999
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    Me.Caption = "Key Spy"
    'Create an API-timer
    SetTimer Me.hwnd, 0, 1, AddressOf TimerProc
End Sub
Private Sub Form_Paint()
    Dim R As RECT
    Const mStr = "Start this project, go to another application, type" & _
      "something, switch back to this application and unload the form. If you" & _
      "unload the form, a messagebox with all the typed keys will be shown."
    'Clear the form
    Me.Cls
    'API uses pixels
    Me.ScaleMode = vbPixels
    'Set the rectangle's values
    SetRect R, 0, 0, Me.ScaleWidth, Me.ScaleHeight
    'Draw the text on the form
    DrawTextEx Me.hDC, mStr, Len(mStr), R, DT_WORDBREAK Or DT_CENTER, ByVal 0&
End Sub
Private Sub Form_Resize()
    Form_Paint
End Sub
Private Sub Form_Unload(Cancel As Integer)
    'Kill our API-timer
    KillTimer Me.hwnd, 0
    'Show all the typed keys
    MsgBox sSave
End Sub
Das sollte dein Problem lösen. Mußt du halt entsprechend umschreiben. Wichtig ist eigentlich nur die API
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Gruß
WarLocK
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Prüfen ob irgendeine Taste gedrückt wurde?5.523Nightlight12.02.03 17:12
Re: Prüfen ob irgendeine Taste gedrückt wurde?2.388ModeratorDieter12.02.03 18:07
Re: Prüfen ob irgendeine Taste gedrückt wurde?2.114Nightlight12.02.03 19:35
Re: Prüfen ob irgendeine Taste gedrückt wurde?2.143WarLocK191213.02.03 11:18
Re: Prüfen ob irgendeine Taste gedrückt wurde?2.058Nightlight13.02.03 13:53
Re: Prüfen ob irgendeine Taste gedrückt wurde?1.668WarLocK191213.02.03 15:47
Re: Prüfen ob irgendeine Taste gedrückt wurde?1.619Nightlight13.02.03 15:57

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel