Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[VB2008/2010] Keyboard Hook

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
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;

PostPosted: Thu Mar 18, 2010 3:45 am    Post subject: [VB2008/2010] Keyboard Hook Reply with quote

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
View user's profile Send private message
Jesper
Grandmaster Cheater Supreme
Reputation: 9

Joined: 21 Feb 2007
Posts: 1156

PostPosted: Thu Mar 18, 2010 7:51 am    Post subject: Reply with quote

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
View user's profile Send private message
iTz SWAT
I post too much
Reputation: 1

Joined: 20 Dec 2007
Posts: 2227
Location: Me.Location;

PostPosted: Fri Mar 19, 2010 12:05 am    Post subject: Reply with quote

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
View user's profile Send private message
FullyAwesome
I post too much
Reputation: 0

Joined: 05 Apr 2007
Posts: 4438
Location: Land Down Under

PostPosted: Fri Mar 19, 2010 4:36 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Jesper
Grandmaster Cheater Supreme
Reputation: 9

Joined: 21 Feb 2007
Posts: 1156

PostPosted: Fri Mar 19, 2010 7:09 am    Post subject: Reply with quote

Make a new thread and check for keys within a while statement.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Fri Mar 19, 2010 7:20 am    Post subject: Reply with quote

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
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Fri Mar 19, 2010 9:12 am    Post subject: Reply with quote

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
View user's profile Send private message
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Fri Mar 19, 2010 10:56 am    Post subject: Reply with quote

SetWindowsHookEx().
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites