• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 520
  • Last Modified:

ALT + TAB

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
coyote050300
Asked:
coyote050300
  • 10
  • 5
  • 2
  • +1
1 Solution
 
pjknibbsCommented:
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
 
coyote050300Author Commented:
Adjusted points from 50 to 100
0
 
coyote050300Author Commented:
Guess it ain't that easy. =(
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
pjknibbsCommented:
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
 
coyote050300Author Commented:
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
 
pjknibbsCommented:
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
 
LermitteCommented:
Why not make a shortkut and say there to use some alt-q key to startup the quake...

Mario
0
 
tonnybrandtCommented:
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
 
pjknibbsCommented:
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
 
tonnybrandtCommented:
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
 
coyote050300Author Commented:
What's the name of the file that's executed when the ALT+TAB key combo is pressed?
0
 
coyote050300Author Commented:
Or is it an extension of taskmgr.exe?
0
 
pjknibbsCommented:
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
 
coyote050300Author Commented:
Adjusted points from 100 to 150
0
 
coyote050300Author Commented:
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
 
LermitteCommented:
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
 
coyote050300Author Commented:
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
 
coyote050300Author Commented:
Dam, I typed that way too fast.  Sorry for the typos. =)
0
 
coyote050300Author Commented:
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

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 10
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now