Results 1 to 13 of 13
  1. #1
    Lyoto Machida's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Far away with girls
    Posts
    3,734
    Reputation
    133
    Thanks
    1,621
    My Mood
    Aggressive

    [Help]Quick Simple Fast Question[Solved]

    How do i get the pressed key?

    I did this:
    Code:
        Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Form1.KeyPress
            Dim PressedKey As String = Asc(e.KeyChar)
            Label1.Text = PressedKey
        End Sub
    But i want to get F5 and that keys..
    Last edited by Lyoto Machida; 02-06-2011 at 02:57 PM.

  2. #2
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Try this:

    Code:
    Label1.Text = e.KeyChar.ToString

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  3. #3
    Lyoto Machida's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Far away with girls
    Posts
    3,734
    Reputation
    133
    Thanks
    1,621
    My Mood
    Aggressive
    Quote Originally Posted by Jason View Post
    Try this:

    Code:
    Label1.Text = e.KeyChar.ToString
    Works like my code...


    But i want to get the FX Keys .. Like F5 F6 etc..

    I need to GetAsyncKeyState?

  4. #4
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Handle the keydown then:

    Code:
    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Label1.Text = CType(e.KeyCode, Keys).ToString
    End Sub

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  5. #5
    Lyoto Machida's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Far away with girls
    Posts
    3,734
    Reputation
    133
    Thanks
    1,621
    My Mood
    Aggressive
    Quote Originally Posted by Jason View Post
    Handle the keydown then:

    Code:
    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Label1.Text = CType(e.KeyCode, Keys).ToString
    End Sub
    WOW , Thanks man.

    You pro!

    /SOLVED

  6. #6
    ♪~ ᕕ(ᐛ)ᕗ's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Uterus
    Posts
    9,119
    Reputation
    1096
    Thanks
    1,970
    My Mood
    Doh
    Quote Originally Posted by Jason View Post
    Handle the keydown then:

    Code:
    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Label1.Text = CType(e.KeyCode, Keys).ToString
    End Sub
    if I can make you a question....Why call the CType function?

  7. #7
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by 3Li0 View Post
    if I can make you a question....Why call the CType function?
    "Keys" is an enum. So basically what I did was convert the integer represented in "e.KeyCode" to it's counterpart in the enum (the one with the same value as the integer) then called ".ToString" to convert this into a string. For example, say I have an enum like this:

    Code:
    Enum Test
      Test1 = 1
      Test2 = 2
      Test3 = 69
    End Enum


    And I have the integer 69, so I want to get the string "Test3" from the enum.

    Code:
    CType(69, Test).ToString


    I convert 69 to it's counterpart in the Enum (i.e the Test3 block) then call ".ToString" to get the name of the block ("Test3")

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  8. #8
    ♪~ ᕕ(ᐛ)ᕗ's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Uterus
    Posts
    9,119
    Reputation
    1096
    Thanks
    1,970
    My Mood
    Doh
    Quote Originally Posted by Jason View Post


    "Keys" is an enum. So basically what I did was convert the integer represented in "e.KeyCode" to it's counterpart in the enum (the one with the same value as the integer) then called ".ToString" to convert this into a string. For example, say I have an enum like this:

    Code:
    Enum Test
      Test1 = 1
      Test2 = 2
      Test3 = 69
    End Enum


    And I have the integer 69, so I want to get the string "Test3" from the enum.

    Code:
    CType(69, Test).ToString


    I convert 69 to it's counterpart in the Enum (i.e the Test3 block) then call ".ToString" to get the name of the block ("Test3")
    oh yea, so basically you simply converted the Integer of the key in the enum to a string value...
    I did understand thanks....oh and an other function, can we convert it using DirectCast for ie?

  9. #9
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by 3Li0 View Post
    oh yea, so basically you simply converted the Integer of the key in the enum to a string value...
    I did understand thanks....oh and an other function, can we convert it using DirectCast for ie?
    Yeah DirectCast is similar to CType however it has become obsolete and CType is favored over it.

    EDIT: 2700th post. Yay?

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  10. #10
    ♪~ ᕕ(ᐛ)ᕗ's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Uterus
    Posts
    9,119
    Reputation
    1096
    Thanks
    1,970
    My Mood
    Doh
    Quote Originally Posted by Jason View Post


    Yeah DirectCast is similar to CType however it has become obsolete and CType is favored over it.

    EDIT: 2700th post. Yay?
    thx again for answering my questions, ure great!

    P.S.
    GJ on 2,700!

  11. #11
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Plus, DirectCast has been obsolete for awhile, it's only a matter of time before it is completely removed form the framework, meaning somewhere download the line, apps using directcast will fail.

    Stick to ctype.


     


     


     



    The Most complete application MPGH will ever offer - 68%




  12. #12
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by NextGen1 View Post
    Plus, DirectCast has been obsolete for awhile, it's only a matter of time before it is completely removed form the framework, meaning somewhere download the line, apps using directcast will fail.

    Stick to ctype.
    I know I'm not supposed to post now, but who was having a little hissy fit about DirectCast being obsolete 2 days ago Rich? So much for kicking it oldschool.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  13. #13
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    I do hate the fact that it is obsolete, so much of my past applications use direccast over Ctype, so eventually there may be a lot of failing apps.

    But, Still sharing the truth, it is Obsolete


     


     


     



    The Most complete application MPGH will ever offer - 68%