cesarsouza / screencast-capture

Free utility to continuously capture the computer screen.
http://cesarsouza.github.io/screencast-capture/
GNU General Public License v3.0
121 stars 39 forks source link

Question : listening to global keyboard input (in-game) #20

Open bigworld12 opened 9 years ago

bigworld12 commented 9 years ago

first thanks for this awesome program and your efforts to keep it awesome :)

second i have been facing some problems trying to make a global keyboard hook that listens to games (like bf3) but it just doesn't work -it works in winforms, wpf applications only- may i ask where is the class you use to install such a global keyboard hook ?

cesarsouza commented 9 years ago

Hi there, thanks for the positive feedback!

The hook is installed at line 151 of file NativeKeybardContext:

Line 154 installs a hook to call the method lowLevelKeyboardProcHook at line 161:

and then the keys are passed to the rest of the application.

The SetWindowHook function is defined at the file SafeNativeMethods on line 178:

The problem is that this function may not be low-level enough to intercept DirectX/DirectInput calls. Depending on the game, it may be necessary to do something differently, like interacting with DirectX directly. There are some libraries that can help us with that:

Hope it helps, if you make some progress in this direction, please let me know!

Regards, Cesar

bigworld12 commented 9 years ago

first of all thanks , the whole problem was "Run as administrator" , yes actually all the libraries work , they aren't just run as administrator (i recommend using this http://tutplusplus.blogspot.ro/2010/10/ultimate-keylogger-lesson-1-global.html )