|
-
Dec 10th, 2011, 11:58 PM
#1
Thread Starter
Lively Member
[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 
-
Dec 11th, 2011, 12:15 AM
#2
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.
-
Dec 11th, 2011, 12:20 AM
#3
Thread Starter
Lively Member
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 
-
Dec 11th, 2011, 12:26 AM
#4
Re: Keystrokes Catcher?
 Originally Posted by aronquiray
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.
-
Dec 11th, 2011, 01:50 AM
#5
Thread Starter
Lively Member
Re: Keystrokes Catcher?
I got it thanks JM for the keyword 
vb Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim ctrlkey As Boolean Dim shiftkey As Boolean Dim k As Boolean ctrlkey = GetAsyncKeyState(Keys.ControlKey) shiftkey = GetAsyncKeyState(Keys.ShiftKey) k = GetAsyncKeyState(Keys.K) If ctrlkey And shiftkey And k = True Then MsgBox("Another Code to Trigger here") End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Visible = False NotifyIcon1.Visible = True NotifyIcon1.ShowBalloonTip(3000) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Enabled = True Timer1.Interval = 100 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 
-
Dec 11th, 2011, 01:56 AM
#6
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
-
Dec 11th, 2011, 02:00 AM
#7
Thread Starter
Lively Member
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 
-
Dec 11th, 2011, 02:18 AM
#8
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.
-
Dec 11th, 2011, 02:20 AM
#9
Thread Starter
Lively Member
Re: [RESOLVED] Keystrokes Catcher?
If my post did help, or make sense.
A simple Thanks or Rate would be even better
.
Proxy Checker S.Code
.
<-  Hit this 
-
Dec 11th, 2011, 05:24 AM
#10
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|