Monday, August 20, 2007

Quick way to disable global keys (like ALT + TAB )


Some times it needed to disable the functonality of the global keys like ALT + TAB ,CTRL + ESC . For example when playing some games , pressing ALT + TAB will not cause to switch the tasks. Personaly i don't like this ,but programmers do these ,otherwise they might needed to handle something more..


So if you want to do these , One way is to use Hooks , using SetWindowHookEx api. But there is much simpler way to do this , using hot keys. There is function named RegisterHotKey , this will define a system wide hot key. So the effect is same as Hook.


After defining a hotkey ,when the hotkey is pressed by the user WM_HOTKEY message will be posted to message queue of that window .


So if you want to disable ALT+TAB , install a hotkey using
                                 RegisterHotKey(hwnd,id,MOD_ALT,VK_TAB).


  Done!!!! . Very simple than hooks.you can also handle the WM_HOTKEY message to do your own tasks..


1 comment:

Sarath said...

KD, Super da... Kollam...