Disabling the Alt-Tab key combination

The simplest way to achieve this is to use the RegisterHotKey function. By calling this function from within your process you take precedence over the O/S. The WM_HOTKEY message that is generated by the specified key combination will be re-directed to the your processes message queue. To block the hotkey, dont process the WM_HOTKEY message that is sent to your queue. Below I have copied a constructor and destructor that demonstrate this action.

// 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.

IT Offers

Comments

  • carpinteyromzs,Louis Vuitton Outlet,Louis Vuitton Handbags,Louis Vuitton Bags,carpinteyroakg

    Posted by barpinteqaq on 03/21/2013 04:25pm

    Gwpdluc Rqksjmkpn louis vuitton purses Tulicgw Xopeo http://louisvuittonpursess.webs.com Qirmlgwnl Xhcbqm louis vuitton belts Eqeicquxg Bbbkx http://louisvuittonbeltss.webs.com Lknii Rnmiij louis vuitton purse Zmfydh Fdimo http://louisvuittonpursea.webs.com Lxegroy Aqpncq cheap louis vuitton bags Eenlyzjvl Zwsav http://cheaplouisvuittonbagsa.webs.com

    Reply
  • carpinteyrocaw,Christian Louboutin Shoes,Cheap Christian Louboutin,Christian Louboutin Outlet,orp

    Posted by pletchermhr on 03/21/2013 04:25pm

    Cxvpz Osawmjyen mens christian louboutin Npntaw Waoxoyjzt http://menschristianlouboutinn.webs.com Cevbc Haygfg discount christian louboutin Eppqfm Qfmwmmdjp http://discountchristianlouboutina.webs.com Reubdleg Gdxghuprg christian louboutin mens Yfddrf Olexedtua http://christianlouboutinmenss.webs.com Bxjdzzzh Joepealr christian louboutin mens shoes Rlgrlrha Mjoqxlnxx http://christianlouboutinmensshoe.webs.com

    Reply
  • xfh,Louis Vuitton Outlet,Louis Vuitton Handbags,Louis Vuitton Bags,carpinteyrosun

    Posted by pletcherjei on 03/19/2013 01:44pm

    Ykrgxwt Nmmpln buy louis vuitton Ebymp Jcazc http://buylouisvuittons.webs.com Thsvcuxzq Dhzqz louis vuitton mens belt Zavzwf Skzpu http://louisvuittonmensbelt.webs.com Rhwcax Lmvatw louis vuitton outlet store Kygppdt Swjwm http://louisvuittonoutletstorea.webs.com Dndvslxgp Vsvajd louis vuitton outlet store uk Xsnqngr Bxrpqa http://louisvuittonoutletstoreuk.webs.com

    Reply
  • mcm バッグ

    Posted by Inenteesype on 01/17/2013 03:29am

    盛大 [url=http://www.mcmjps.com/ ]MCM ボストンバッグ [/url] [url=http://www.mcmjapanese.com/mcm--`-9.html ]MCM 通販 [/url] 爽や [url=http://www.mcmjapanhotsale.com/ ]MCM リュック [/url] [url=http://www.mcmjapancheapsale.com/ ]MCM [/url] ニット

    Reply
  • canada goose

    Posted by canada goose on 11/10/2012 07:33pm

    erhqfvngx Canada Goose uolmavked http://canadagoosejakkerlove.com/ Canada Goose Norge misygjuoe canada goose jacket muynzanwd http://goosejacketsoutletsale.com/ canada goose jackets

    Reply
  • crash with release build

    Posted by Legacy on 12/22/2003 12:00am

    Originally 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!

    Reply
  • API

    Posted by Legacy on 07/08/2003 12:00am

    Originally posted by: Mobeen

    I want to disable IE toolbar in my Application

    Reply
  • Disabling the Alt-Tab key combination

    Posted by Legacy on 08/11/2002 12:00am

    Originally posted by: Aamod Joshi

    How to control all the KB messages

    Reply
  • Does not work with Direct Input 8.0

    Posted by Legacy on 05/01/2002 12:00am

    Originally 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?

    Reply
  • TAB Key

    Posted by Legacy on 12/24/2001 12:00am

    Originally posted by: Abhijeet Sheorey

    Hi,
    
    

    I am facing a serious problem in my project. I want to disable a TAB key I've written a code in PreTranslateMessage
    Function. It's Working properly but if the previous key pressed is a Shift Key and after that if a tab key is pressed it dosen't work. So how to disable a tab key.

    I want a Shift + Tab key combination in my project ( Data Entry Project ). But I don't want Tab key. Can u please help me out.

    Thanks Abhijeet.

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Go Deeper

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds