| View previous topic :: View next topic |
| Author |
Message |
iTz SWAT I post too much
Reputation: 1
Joined: 20 Dec 2007 Posts: 2227 Location: Me.Location;
|
Posted: Thu Mar 18, 2010 3:45 am Post subject: [VB2008/2010] Keyboard Hook |
|
|
Hey,
I haven't programmed in years.
I have a simple question.
A while ago I used the GetAsyncKeyState function to check when ever a key was pressed. I used it as a Global Hotkey for many applications.
I was told that you can hook a keyboard so then instead of running a timer consuming performance and also sometimes missing a key, a hook will send the application a message when ever the key is pressed.
1. How is this done?
2. Can this be used globally (when application is minimized etc)
3. Does it consume more performance then GetAsyncKeyState
_________________
|
|
| Back to top |
|
 |
Jesper Grandmaster Cheater Supreme
Reputation: 9
Joined: 21 Feb 2007 Posts: 1156
|
Posted: Thu Mar 18, 2010 7:51 am Post subject: |
|
|
| I don't know about hooking the keyboard but I recently made a keylogger that uses GetAsyncKeyState to check every key code between 0 to 255 and it uses 0-2% CPU. So I'd say that GetAsyncKeyState doesn't use that many resources if used correctly.
|
|
| Back to top |
|
 |
iTz SWAT I post too much
Reputation: 1
Joined: 20 Dec 2007 Posts: 2227 Location: Me.Location;
|
Posted: Fri Mar 19, 2010 12:05 am Post subject: |
|
|
| SwallowIt wrote: | | I don't know about hooking the keyboard but I recently made a keylogger that uses GetAsyncKeyState to check every key code between 0 to 255 and it uses 0-2% CPU. So I'd say that GetAsyncKeyState doesn't use that many resources if used correctly. |
I don't want a timer running.
Nor do I want a key logger.
Tip: If you use GetAsyncKeySate within a timer, then if you press a button when the timer has a break, it won't count, so therefore it won't be as accurate as hooking.
_________________
|
|
| Back to top |
|
 |
FullyAwesome I post too much
Reputation: 0
Joined: 05 Apr 2007 Posts: 4438 Location: Land Down Under
|
Posted: Fri Mar 19, 2010 4:36 am Post subject: |
|
|
you use RegisterHotkey() (and UnregisterHotkey()), you should be able to find some vb.net examples around since it's pretty straight forward.
_________________
|
|
| Back to top |
|
 |
Jesper Grandmaster Cheater Supreme
Reputation: 9
Joined: 21 Feb 2007 Posts: 1156
|
Posted: Fri Mar 19, 2010 7:09 am Post subject: |
|
|
| Make a new thread and check for keys within a while statement.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Fri Mar 19, 2010 7:20 am Post subject: |
|
|
| iTz SWAT wrote: | | SwallowIt wrote: | | I don't know about hooking the keyboard but I recently made a keylogger that uses GetAsyncKeyState to check every key code between 0 to 255 and it uses 0-2% CPU. So I'd say that GetAsyncKeyState doesn't use that many resources if used correctly. |
I don't want a timer running.
Nor do I want a key logger.
Tip: If you use GetAsyncKeySate within a timer, then if you press a button when the timer has a break, it won't count, so therefore it won't be as accurate as hooking. |
What do you mean by 'when the timer has a break' ?
Also maybe you want to check out this thread:
http://forum.cheatengine.org/viewtopic.php?t=494994
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Fri Mar 19, 2010 9:12 am Post subject: |
|
|
SetWindowsHookEx is what ur looking for
using the WH_KEYBOARD_LL hook type
you're hooking the keyboard and whenever a keybd message is arrived like WM_KEYDOWN, WM_SYSTEMKEY or however it called u can hook it and u can do whatever u want to after the key is sent
|
|
| Back to top |
|
 |
iPromise Grandmaster Cheater
Reputation: -1
Joined: 27 Jun 2009 Posts: 529 Location: Canada
|
Posted: Fri Mar 19, 2010 10:56 am Post subject: |
|
|
| SetWindowsHookEx().
|
|
| Back to top |
|
 |
|