Solved

ALT + TAB

Posted on 2000-05-13
19
491 Views
Last Modified: 2010-04-14
Is there any way to temporally disable the ALT + TAB key function or for that matter, ALT + ANYKEY (registry hack, utility, etc...).  I have these keys bound to play Quake and use them both frequently.  I don't wish to disable either of the keys, just the combination of the two bringing up the task manager which immediately quits Quake.  Nor do I wish to switch my key bindings around.  However, if need be - I will.  I have a MS Natural Keyboard Pro for what it's worth.
0
Comment
Question by:coyote050300
  • 10
  • 5
  • 2
  • +1
19 Comments
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2807878
I'm not sure this is possible under WinNT or Win2K--they both intercept the ALT+TAB, CTRL+ESC etc. combinations at a very low level. I know Microsoft did a tool for Win9x which would do this, but I haven't found a Win2K equivalent.
0
 
LVL 1

Author Comment

by:coyote050300
ID: 2809638
Adjusted points from 50 to 100
0
 
LVL 1

Author Comment

by:coyote050300
ID: 2809639
Guess it ain't that easy. =(
0
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2809942
I've found a Microsoft Knowledge Base article (Q226359) on how to do this, but unfortunately it only tells you how to do it programmatically--you'd have to write a program to do the trick. I haven't really got time to do this myself, unfortunately.
0
 
LVL 1

Author Comment

by:coyote050300
ID: 2810157
Yikes!  I'm a newbie at programming.  In fact, I just started not long ago.  I have MS DevStudio, but haven't gotten much further than "hello world" - hehe.  Can I just cut, paste and compile those instructions into an .exe?  If so, I'm assuming that if the return value is "0" it will enable the key combination functions again.  I was looking for something simple, however, this could be fun. =)
0
 
LVL 12

Accepted Solution

by:
pjknibbs earned 150 total points
ID: 2810309
Well, here's the complete text of the article, but I don't think it's as simple as a cut and paste job:

HOWTO: Disable Task Switching on Win32 Platforms
ID: Q226359

--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Win32 Application Programming Interface (API), included with:
Microsoft Windows versions 95, 98
Microsoft Windows 2000
Microsoft Windows NT versions 3.51, 4.0

--------------------------------------------------------------------------------


SUMMARY
This article describes how to disable task switching and other system functions accessed through key combinations such as CTRL+ESC and ATL+TAB on Win32 Platforms.

Windows 95 and Windows 98
Applications can enable and disable ALT+TAB and CTRL+ESC, for example, by calling SystemParametersInfo (SPI_SETSCREENSAVERRUNNING). To disable ALT+TAB and CTRL+ESC, set the uiParam parameter to TRUE; to enable the key combinations, set the parameter to FALSE:

UINT nPreviousState;

// Disables task switching
SystemParametersInfo (SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);

// Enables task switching
SystemParametersInfo (SPI_SETSCREENSAVERRUNNING, FALSE, &nPreviousState, 0);
NOTE: Applications that use SystemParametersInfo (SPI_SETSCREENSAVERRUNNING) to disable task switching must enable task switching before exiting or task switching remains disabled after the process terminates.
Windows NT 4.0 Service Pack 3 and Later and Windows 2000
Applications can disable ALT+TAB or CTRL+ESC by installing a low-level keyboard hook. A low-level keyboard hook (WH_KEYBOARD_LL) is installed by calling SetWindowsHookEx. For more information on Window hooks see the "Hooks" overview in the Platform SDK documentation.

The following is a sample low-level keyboard hook procedure that disables CTRL+ESC, ALT+TAB, and ALT+ESC:


LRESULT CALLBACK LowLevelKeyboardProc (INT nCode, WPARAM wParam, LPARAM lParam)
{
    // By returning a non-zero value from the hook procedure, the
    // message does not get passed to the target window
    KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam;
    BOOL bControlKeyDown = 0;

    switch (nCode)
    {
        case HC_ACTION:
        {
            // Check to see if the CTRL key is pressed
            bControlKeyDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);
           
            // Disable CTRL+ESC
            if (pkbhs->vkCode == VK_ESCAPE && bControlKeyDown)
                return 1;

            // Disable ALT+TAB
            if (pkbhs->vkCode == VK_TAB && pkbhs->flags & LLKHF_ALTDOWN)
                return 1;

            // Disable ALT+ESC
            if (pkbhs->vkCode == VK_ESCAPE && pkbhs->flags & LLKHF_ALTDOWN)
                return 1;

            break;
        }

        default:
            break;
    }
    return CallNextHookEx (hHook, nCode, wParam, lParam);
}
Windows NT 4.0 Service Pack 2 and Earlier, Windows NT 3.51 and Earlier
Applications can disable CTRL+ESC system-wide by replacing the Windows NT Task Manager, but this is not recommended.

Applications can disable ALT+TAB and ALT+ESC when the application is running by registering hotkeys for the ALT+TAB and ALT+ESC combinations by calling RegisterHotKey.



MORE INFORMATION
Older development tools, such as Microsoft Visual C++ Version 5.0 and earlier, might not contain the header files necessary to build an application that uses low-level keyboard hooks. To obtain the most recent header files, download the latest Platform SDK from:

http://msdn.microsoft.com/developer/sdk
Because low-level keyboard hooks are a feature specific to Windows NT 4.0 Service Pack 3 and later, define _WIN32_WINNT >= 0x0400 prior to including winuser.h (or windows.h).

0
 
LVL 6

Expert Comment

by:Lermitte
ID: 2810344
Why not make a shortkut and say there to use some alt-q key to startup the quake...

Mario
0
 
LVL 10

Expert Comment

by:tonnybrandt
ID: 2810383
I don't think that pjknibbs suggestion is worth trying. To the my best of knowledge, this will only work if it's compiled into the application, that should be unaffected by the key-combination, or will be using the key-combination to another purpose.
I have been using this feature in Delphi programming, so i know it's how it's working.
And i don't think you will be recompiling Quake, will you :-).
0
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2810655
The above code should prevent ALT+TAB working so long as *any* application is running which implements it, so it should be a simple task to write an application which disables ALT+TAB while it's running and enables it again when it quits. This is why it uses a *low level* keyboard hook, which is only available under WinNT SP 3 and higher or Windows 2000.

Oh, and instead of rubbishing my suggestion, why not come up with something better yourself?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 10

Expert Comment

by:tonnybrandt
ID: 2811574
I wasn't rubbishing your suggestion, or at least, this was not my intention. I didn't think it would work and gave my opinon. Nothing more.
0
 
LVL 1

Author Comment

by:coyote050300
ID: 2812945
What's the name of the file that's executed when the ALT+TAB key combo is pressed?
0
 
LVL 1

Author Comment

by:coyote050300
ID: 2812949
Or is it an extension of taskmgr.exe?
0
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2813278
coyote: If you run Task Manager and hit ALT+TAB, not only does the task switch work without disrupting the TM window, but no extra process is created. Therefore ALT+TAB is handled by some system process--possibly Explorer, although I wouldn't swear to that.
0
 
LVL 1

Author Comment

by:coyote050300
ID: 2813732
Adjusted points from 100 to 150
0
 
LVL 1

Author Comment

by:coyote050300
ID: 2813733
Yeah, I'm beginning to believe that's the case.  I've looked all over for clues and found nuttin' at all.  I nearly spent $36 on a Windows 2000 registry book yesterday - instead, I spent most the day in the store reading it to no avail.  I think you're right though about explorer.  Based on the KB Article with the code for turning it off, it looks to be a system call.  I'll have to download the latest SDK to even play with that.  A whopping 800+ megs for the entire thing.  I've been looking for software utility solutions for remaping the keyboard etc..  However, so far nothing found will do the trick.  I hadn't expected this to be so difficult.  It wasn't really a big deal until now.  Now that I don't understand why it's so difficult - hehe.
0
 
LVL 6

Expert Comment

by:Lermitte
ID: 2814000
That's the reason that I say to create a shortcut for the quake program and there you can say to assign a shortcut-key like alt-ctrl-Q to startup Quake.

Mario
0
 
LVL 1

Author Comment

by:coyote050300
ID: 2814369
Well, I didn't understand how that would keep Quake from quitting if I accidentally pressed the ALT+TAB key simultaneously.  And I still don't understand.  If you could clarify how that would disable the ALT+TAB function from killing Quake, I'm interested I wish to understanding.

I use GameSpy to play over the net, so a shortcut to start quake wouldn't be too appealing even if it could work.  Of course, if it did work, I could start Quake (using your proposed shortcut method) and from the command line join a server.  However, I would loose all the functionality of GameSpy and that would sux.

I you would, I still like you to explain how the shortcut method would disable the ALT+TAB function.  If I understood, then perhaps it would open my eyes to a solution to where I could still use GameSpy or find a compromise between the two.
0
 
LVL 1

Author Comment

by:coyote050300
ID: 2814383
Dam, I typed that way too fast.  Sorry for the typos. =)
0
 
LVL 1

Author Comment

by:coyote050300
ID: 2829252
Since there's seems no easy way to do it, I'll accept this answer.  It will be awhile before I try to compile the code, but I'm sure it will work.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Moving applications to the cloud or switching services to cloud-based ones, is a stressful job.  Here's how you can make it easier.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now