Last change
on this file since 937 was
70,
checked in by roman, 12 years ago
|
|
-
Property svn:keywords set to
Id
|
File size:
825 bytes
|
Line | |
---|
1 | #include "stdafx.h" |
---|
2 | |
---|
3 | HHOOK hKeyboardHook = 0; |
---|
4 | |
---|
5 | LRESULT CALLBACK KeyboardCallback(int code,WPARAM wParam,LPARAM lParam) { |
---|
6 | cout << "a key was pressed" << endl; |
---|
7 | return CallNextHookEx(hKeyboardHook,code,wParam,lParam); |
---|
8 | } |
---|
9 | |
---|
10 | int main() { |
---|
11 | HWND consoleWindow = GetConsoleWindow(); |
---|
12 | HINSTANCE hInstCons = (HINSTANCE)GetWindowLong( consoleWindow, GWL_HINSTANCE ); |
---|
13 | |
---|
14 | // NOTE: This has to be NULL |
---|
15 | hInstCons = NULL; |
---|
16 | |
---|
17 | hKeyboardHook = SetWindowsHookEx( WH_KEYBOARD, (HOOKPROC)KeyboardCallback, hInstCons, GetCurrentThreadId()); |
---|
18 | _tprintf(_T("consoleWindow 0x%p, hInstCons 0x%p, hKeyboardHook 0x%p\n"), consoleWindow, hInstCons, hKeyboardHook); |
---|
19 | |
---|
20 | MessageBox(NULL, _T("It is keyboard time!"), _T("Let's Go"), MB_OK); |
---|
21 | |
---|
22 | //for(int i=0; i<=10; i++) { |
---|
23 | // cout << i << endl; |
---|
24 | // Sleep(1000); |
---|
25 | //} |
---|
26 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.