Disabling Alt-Tab and Other Keys

Page 1 of 2 12 LastLast

  1. Posts : 6
    Windows 7 Ultimate 64-bit
       #1

    Disabling Alt-Tab and Other Keys


    I have been researching all over the internet for a way to disable the Alt+Tab key combination, and possibly the Windows key as well. There was even a post about this particular topic in this forum (Disabling alt+tab screen? Please help), but it was inconclusive. Registry edits do not seem to work, at least not in Windows 7. I was wondering if there is any way to disable these keys safely. I'm creating a security application that will lock a computer until the correct password is entered. I cannot have people using Alt-Tab or other key combinations while this program is active. Alt-Tab is specifically a problem because it's possible for a user to switch to open programs by using it, hence giving them access to the machine (I don't want to interrupt programs that are running when my program is activated). Also, whatever method used to lock or disable these keys must be able to be used through command prompt since I'm creating this program with a batch file (with some C++ as well). It could be an executable or whatever, but I can't really use a key mapping program because it needs to be automatic when the program is started. Maybe I could use some C++ code to disable these keys? If so, I would really appreciate it if complete code could be posted to do this (as I'm not very savvy with C++ quite yet). I also need something to disable the key restrictions and something to re-enable them separately. Thanks in advance and I hope that I can finally find a solution to this annoying problem! :)
      My Computer


  2. Posts : 2,726
    Windows 7 Ultimate 64bit
       #2
      My Computer


  3. Posts : 1,506
    W7 Ult. x64 | OS X
       #3

    If those suggestions don't work you could try finding the process that allows Alt-Tab to work (it's not explorer.exe) and kill that process (if safe) while your lock is in place.
      My Computer


  4. Posts : 6
    Windows 7 Ultimate 64-bit
    Thread Starter
       #4

    PooMan UK- Thank you for trying to help but I have tried that solution before. I need the change (disabling Alt-Tab and any other keys) to take effect immediately. Like I said, I don't want to disrupt the programs that are running when my program is started. Since you must restart the computer or log out and back in for the registry changes to take effect, this isn't an option for me. I've used many registry changes already in my program (they are safe and tested so don't worry) and they take effect immediately, so why won't these changes take effect immediately as well? It's really annoying!

    notsograymatter- I'll take a look into that. I know that it's not explorer.exe because my program kills that process already. Thanks for your help!
      My Computer


  5. Posts : 6
    Windows 7 Ultimate 64-bit
    Thread Starter
       #5

    Low-level keyboard hook, anyone?


    Well... I tried looking at processes to kill to disable Alt-Tab, but it seems like that's not an option either. I won't be able to kill any vital system processes to kill Alt-Tab. I tried to do so (by running Task Manager as an administrator), and when I tried to disable any important process, I got an "Ending this process will shut down the operating system immediately. You will lose all unsaved data. Are you sure you want to continue?" message (view the attached screenshot (Attachment 83670) to see what this looked like). At that point, I had the option to cancel or check the "Abandon unsaved data and shut down." box and then click the "Shut Down" button. Of course I didn't do this, but at least now I know that I won't be able to disable Alt-Tab safely by killing a process (at least not without crashing the system and/or getting a BSOD). The only other option that I have (at least that I know of) if to create a low-level keyboard hook to disable Alt+Tab, Ctrl+Esc, and Alt+Esc. I've been searching for a few days now for a complete code sample that I can use for my project, but with no success. Could someone please view How to disable task switching on Win32 platforms and tell me what it's missing? I tried compiling this code sample and it's missing something. Please help! Thanks in advance for everyone's help! Also, I've tried typing "#include <windows.h>" in the code sample but I still get an error on the last line of code (the "return CallNextHookEx (hHook, nCode, wParam, lParam);" part). What else needs to be done?
    Last edited by mtgfan2006; 06 Jul 2010 at 22:21. Reason: To fix my file attachment
      My Computer


  6. Posts : 1,326
    Windows 7 Ultimate RTM (Technet)
       #6

    Why not run your program as a service and just lock the workstation?
      My Computer


  7. Posts : 5,056
    Windows 7 x64 pro/ Windows 7 x86 Pro/ XP SP3 x86
       #7

    See this page.

    Disabling Alt Tab - Vista Forums

    See if you can use the AutoHotKey option.
      My Computer


  8. Posts : 6
    Windows 7 Ultimate 64-bit
    Thread Starter
       #8

    MacGyvr said:
    Why not run your program as a service and just lock the workstation?
    That would be too simple. I want to create my own program to lock a workstation. My program even runs at startup and replaces the Windows shell (explorer.exe). Once this program is started you basically can't access the system until the correct password is entered. If you enter the wrong password three times you are logged off. I just thought it would be fun to create something like this, and it's going to be a really cool tool (at least I think) when it's finished. Eventually it will have it's own desktop overlay (kind of like the normal Windows lockout feature) to keep users from accessing open programs while the program is active. Anyway... that's why. lol
      My Computer


  9. Posts : 6
    Windows 7 Ultimate 64-bit
    Thread Starter
       #9

    Bill2 said:
    See this page.

    Disabling Alt Tab - Vista Forums

    See if you can use the AutoHotKey option.
    Thanks, Bill2! I'll see if I can get this program to work (since it doesn't have to be installed). I'll post results once I'm finished! Hopefully someone else can benefit from this thread since it's caused me so many problems.
      My Computer


  10. Posts : 6
    Windows 7 Ultimate 64-bit
    Thread Starter
       #10

    Success!


    Problem solved! I was able to use AutoHotKeys to successfully (and effectively) disable the Alt-Tab key combination. For anyone interested, here's how to do it:

    1) Download the zip file located here: http://www.autohotkey.com/download/AutoHotkey.zip (or download the installer http://www.autohotkey.com/download/A...keyInstall.exe).

    2) Open up AutoHotKey and go to File > Edit Script (or create your own script file by opening up notepad and creating a .ahk file).

    3) The ONLY code that you have to type to disable the Alt-Tab key combination is "!Tab::return" (without quotes). That's it! All lines beginning with a semicolon ( ; ) are comment lines and you can just ignore or erase them. If you view the help file and read just a little bit you can disable just about any Windows hotkeys that you want. Experiment a little!

    4) Now, if you want the file to be portable like I did (without needing AutoHotKey to be installed) you can use the compiler included with AutoHotKey that will convert your file to an executable for you! If you downloaded the zip file, find the "Compiler" folder after you have extracted. If you downloaded the installer, find AutoHotKey in your Start Menu and find the "Convert .ahk to .exe" link.

    5) Enjoy being able to use your file on any computer without the need for AutoHotKey to be installed!

    I'd also like to thank Bill2 for suggesting this to me. Thanks for helping me with this annoying problem!
      My Computer


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 14:52.
Find Us