Disabling the Alt-Tab key combination
Posted
by Dan Crea
on February 4th, 1999
// Call the RegisterHotKey function when the application
// is instantiated to block the ALT-TAB combination
// Note: The m_nHotKeyID is a int which specifies the hotkey
// ID, the hotkey id is programmer defined
CMainFrame::CMainFrame()
{
m_nHotKeyID = 100;
BOOL m_isKeyRegistered = RegisterHotKey(GetSafeHwnd(), m_nHotKeyID,
MOD_ALT, VK_TAB);
ASSERT(m_isKeyRegistered != FALSE);
}
//lets remove the hotkey block when the application is destroyed
CMainFrame::~CMainFrame()
{
BOOL m_iskeyUnregistered = UnregisterHotKey(GetSafeHwnd(), m_nHotKeyID);
ASSERT(m_isKeyUnregistered != FALSE);
}
There you have it, the simplest way to block the ALT-TAB without writing a VxD.
One last thing, the hotkey block will continue as long as your application is running. When your process terminates the hotkey will return to its original functionality.

Comments
crash with release build
Posted by Legacy on 12/22/2003 12:00amOriginally posted by: Sam
It seem that App with RegisterHotKey function will crash with release build upon second time pressing the hotkey. Who can help? Thanks!
ReplyAPI
Posted by Legacy on 07/08/2003 12:00amOriginally posted by: Mobeen
I want to disable IE toolbar in my Application
ReplyDisabling the Alt-Tab key combination
Posted by Legacy on 08/11/2002 12:00amOriginally posted by: Aamod Joshi
How to control all the KB messages
ReplyDoes not work with Direct Input 8.0
Posted by Legacy on 05/01/2002 12:00amOriginally posted by: Robert
Hello,
Direct Input (DirectX 8.0) does not seem to allow ALT+TAB to be captured in the application (hotkey and global low level hook methods were tested). Allow though, the HotKey or hook does effect all of the other application in the Desktop until the application is ended.
Any suggestions?
ReplyTAB Key
Posted by Legacy on 12/24/2001 12:00amOriginally posted by: Abhijeet Sheorey
ReplyHow make the virus !!!!????
Posted by Legacy on 06/28/2001 12:00amOriginally posted by: Buggy
ReplyALT+F4 and others in Win 9x
Posted by Legacy on 03/14/2001 12:00amOriginally posted by: J.
I was using the command, SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, (PVOID)1, 0);
to disable alt+esc, alt+tab and ctl+alt+del
However, I also need to get rid of alt+F4 so the user can not close the program.
I tried using the code posted here (altering it for F4 not Tab), but it doesn't seem to work with my SystemParametersInfo code. I can only use one or the other. I am just getting in to visual programming with a mild background in C++. Any hints, suggestions...preferably something that's not too difficult. This is for a school project, and we are told to learn Visual C++ as we go. A task that is easier said than done (at least for me).
Yes, the RegisterHotKey did work for Alt+F4 in a Win 9x environment. It did not however, work for alt+tab.
ReplyHow about WINLOGO+TAB and WINLOGO+ALT+TAB
Posted by Legacy on 09/26/1999 12:00amOriginally posted by: P. Kournetas
ReplyHow to process a WM_HOTKEY in MFC?
Posted by Legacy on 08/14/1999 12:00amOriginally posted by: Alvin Sia
Instead of the existing process that Windows do when encountered ALT+TAB, I would like to do another process, say invoking a hidden application. How should I implement WM_HOTKEY keyboard event in an MFC application?
ReplyIt does not work on DirectX based application.
Posted by Legacy on 07/22/1999 12:00amOriginally posted by: Kim, Hyoun Woo
The way of using RegisterHotKey API doesn't work on DirectX based application.
How do I make it disable ALT+TAB in DirectX based application?
>> I've used SystemParametersInfo API also, but it's doesn't work too.
ReplyLoading, Please Wait ...