Results 1 to 10 of 10

Thread: [RESOLVED] Keystrokes Catcher?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2011
    Posts
    99

    Resolved [RESOLVED] Keystrokes Catcher?

    Hello guys,
    I just wanted to know how do I implement stuffs like this.

    I am making a software where it will catch a keystrokes, take note. Not a Keylogger


    it will be running on the Background, like it will be minimized to System Tray

    then for example a combination keys like Ctrl Shift F or Ctrl Shift (a certain key)
    then the software will react to the keystrokes..



    Anyone can help? Thanks
    If my post did help, or make sense.
    A simple Thanks or Rate would be even better
    .
    Proxy Checker S.Code
    .
    <- Hit this

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Keystrokes Catcher?

    That is called a "hotkey" and you use the RegisterHotKey API to implement it. There are examples all around the web, including in our own VB.NET CodeBank forum.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2011
    Posts
    99

    Re: Keystrokes Catcher?

    Thanks jm, i'll try to search that, i don't have really an idea it was a hotkey lmao
    If my post did help, or make sense.
    A simple Thanks or Rate would be even better
    .
    Proxy Checker S.Code
    .
    <- Hit this

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Keystrokes Catcher?

    Quote Originally Posted by aronquiray View Post
    Thanks jm, i'll try to search that, i don't have really an idea it was a hotkey lmao
    Not really any reason you should have. Once you have a keyword provided though, you can find lots of information for yourself. You obviously intend to do that, which is good. Far too many people seem unwilling to even try on their own behalf and just want others to provide it all on a silver platter. If you have issues with what you find, by all means post back but it's good that you intend to put in the effort first.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2011
    Posts
    99

    Re: Keystrokes Catcher?

    I got it thanks JM for the keyword

    vb Code:
    1. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
    2.  
    3. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    4.         Dim ctrlkey As Boolean
    5.         Dim shiftkey As Boolean
    6.         Dim k As Boolean
    7.         ctrlkey = GetAsyncKeyState(Keys.ControlKey)
    8.         shiftkey = GetAsyncKeyState(Keys.ShiftKey)
    9.         k = GetAsyncKeyState(Keys.K)
    10.  
    11.         If ctrlkey And shiftkey And k = True Then
    12.             MsgBox("Another Code to Trigger here")
    13.         End If
    14.  
    15.  
    16.     End Sub
    17.  
    18. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    19.         Me.Visible = False
    20.         NotifyIcon1.Visible = True
    21.         NotifyIcon1.ShowBalloonTip(3000)
    22.  
    23.     End Sub
    24.  
    25.  
    26.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    27.         Timer1.Enabled = True
    28.         Timer1.Interval = 100
    29.     End Sub




    hehe, it was on the System Tray and it worked.
    If my post did help, or make sense.
    A simple Thanks or Rate would be even better
    .
    Proxy Checker S.Code
    .
    <- Hit this

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] Keystrokes Catcher?

    That is absolutely not the way to do it. How is it that I say that you should use the RegisterHotkey API, you say thanks and end up not using it? DO NOT use GetAsyncKeyState for this. Use RegisterHotKey
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Sep 2011
    Posts
    99

    Re: [RESOLVED] Keystrokes Catcher?

    oh sorry, but this solved my problem though the keyword "hotkey"
    If my post did help, or make sense.
    A simple Thanks or Rate would be even better
    .
    Proxy Checker S.Code
    .
    <- Hit this

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] Keystrokes Catcher?

    You may think that it solved your problem but it didn't. That code is inefficient at best and has a big hole in it at worst. I specifically said:
    use the RegisterHotKey API
    What you do is up to you but that is the proper way to do what you want to do, which is why I suggested it. It overcomes both issues with the code you are now using.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Sep 2011
    Posts
    99

    Re: [RESOLVED] Keystrokes Catcher?

    okies Jm
    search mode
    If my post did help, or make sense.
    A simple Thanks or Rate would be even better
    .
    Proxy Checker S.Code
    .
    <- Hit this

  10. #10
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: [RESOLVED] Keystrokes Catcher?

    Please do not use GetAsyncKeyState. I am quite confused how you searched for Register Hotkey API and got GetAsyncKeyState. You are forcing your application to check ever N seconds for a key stroke. Even more so on the UI thread. Your application will be amazing slow.

    Register HotKey API Source

    Also if you really are interested in learning take the time to read:

    RegisterHotKey Function

    WM_HOTKEY message
    Last edited by ident; Dec 11th, 2011 at 05:38 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width