Changeset 2271
- Timestamp:
- 07/18/08 05:17:06 (6 months ago)
- Files:
-
- 4 modified
-
keyHook/keyHook.c (modified) (5 diffs)
-
keyHook/keyHook.h (modified) (2 diffs)
-
mouseHook/MOUSEHook.c (modified) (4 diffs)
-
mouseHook/MOUSEHook.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
keyHook/keyHook.c
r1146 r2271 1 1 //keyHook.c 2 //Copyright (c) 2007 Michael Curran <mick@kulgan.net>2 //Copyright (c) 2007-2008 Michael Curran <mick@kulgan.net> 3 3 //This file is covered by the GNU General Public Licence 4 //See the file Copyingfor details.4 //See the file copying.txt for details. 5 5 6 6 #define UNICODE … … 13 13 HINSTANCE moduleHandle; 14 14 HHOOK keyHookID=0; 15 BOOL isInitialized=FALSE;16 15 17 16 #pragma comment(linker,"/entry:_DllMainCRTStartup@12") … … 47 46 48 47 int initialize(keyCallback_t downCallback, keyCallback_t upCallback) { 49 if( isInitialized) {48 if(keyHookID) { 50 49 fprintf(stderr,"Already initialized\n"); 51 50 return -1; … … 53 52 keyDownCallback=downCallback; 54 53 keyUpCallback=upCallback; 55 if( (keyHookID=SetWindowsHookEx(WH_KEYBOARD_LL,(HOOKPROC)keyHook,moduleHandle,0))<=0) {54 if(!(keyHookID=SetWindowsHookEx(WH_KEYBOARD_LL,(HOOKPROC)keyHook,moduleHandle,0))) { 56 55 fprintf(stderr,"Error registering key hook\n"); 57 56 return -1; … … 60 59 } 61 60 62 void terminate() { 63 if(isInitialized) { 64 UnhookWindowsHookEx(keyHookID); 61 int terminate() { 62 if(keyHookID) { 63 if(UnhookWindowsHookEx(keyHookID)) { 64 keyHookID=0; 65 return 0; 66 } 65 67 } 68 return -1; 66 69 } -
keyHook/keyHook.h
r1146 r2271 1 //Copyright (c) 2007 Michael Curran <mick@kulgan.net>1 //Copyright (c) 2007-2008 Michael Curran <mick@kulgan.net> 2 2 //This file is covered by the GNU General Public Licence 3 3 … … 12 12 //Functions 13 13 DLLEXPORT int initialize(keyCallback_t downCallback, keyCallback_t upCallback); 14 DLLEXPORT voidterminate();14 DLLEXPORT int terminate(); 15 15 16 16 #endif -
mouseHook/MOUSEHook.c
r1147 r2271 1 1 //mouseHook.c 2 //Copyright (c) 2007 Michael Curran <mick@kulgan.net>2 //Copyright (c) 2007-2008 Michael Curran <mick@kulgan.net> 3 3 //This file is covered by the GNU General Public Licence 4 //See the file Copyingfor details.4 //See the file copying.txt for details. 5 5 6 6 #define UNICODE … … 12 12 HINSTANCE moduleHandle; 13 13 HHOOK mouseHookID=0; 14 BOOL isInitialized=FALSE;15 14 16 15 #pragma comment(linker,"/entry:_DllMainCRTStartup@12") … … 37 36 38 37 int initialize(mouseCallback_t callback) { 39 if( isInitialized) {38 if(mouseHookID) { 40 39 fprintf(stderr,"Already initialized\n"); 41 40 return -1; 42 41 } 43 42 mouseCallback=callback; 44 if( (mouseHookID=SetWindowsHookEx(WH_MOUSE_LL,(HOOKPROC)mouseHook,moduleHandle,0))<=0) {43 if(!(mouseHookID=SetWindowsHookEx(WH_MOUSE_LL,(HOOKPROC)mouseHook,moduleHandle,0))) { 45 44 fprintf(stderr,"Error registering mouse hook\n"); 46 45 return -1; … … 49 48 } 50 49 51 void terminate() { 52 if(isInitialized) { 53 UnhookWindowsHookEx(mouseHookID); 50 int terminate() { 51 if(mouseHookID) { 52 if(UnhookWindowsHookEx(mouseHookID)) { 53 mouseHookID=0; 54 return 0; 55 } 54 56 } 57 return -1; 55 58 } -
mouseHook/MOUSEHook.h
r1147 r2271 1 //Copyright (c) 200 7Michael Curran <mick@kulgan.net>1 //Copyright (c) 2008 Michael Curran <mick@kulgan.net> 2 2 //This file is covered by the GNU General Public Licence 3 3 … … 12 12 //Functions 13 13 DLLEXPORT int initialize(mouseCallback_t callback); 14 DLLEXPORT voidterminate();14 DLLEXPORT int terminate(); 15 15 16 16 #endif

NVDA is supported by