Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,
I am creating a desktop application in C# using Visual Studio 2012 framework 4.0 for Win8. I want want to disable Alt+Tab key operation. How I can do this. Please reply fast its argent.
Posted
Comments
Prasad Khandekar 5-Jun-14 5:38am    
Checkout this http://stackoverflow.com/questions/3213606/how-to-suppress-task-switch-keys-winkey-alt-tab-alt-esc-ctrl-esc-using-low.
ZurdoDev 5-Jun-14 7:26am    
I would suggest post as solution.
BillWoodruff 5-Jun-14 6:24am    
I've used the code in the link that Prasad supplied above to experiment, and it worked. But, in general, there are very few reasons to ever block Alt-Tab. If you really need to block all but the simplest key-strokes, you should search on Google for "C# Kiosk Mode"
Bernhard Hiller 5-Jun-14 10:26am    
Alt-Tab is used for changing between applications. Hence: don't do that. It would disrupt user-experience. Any application trying to do so on my computer would be removed immediately!
Francine DeGrood Taylor 5-Jun-14 13:03pm    
http://social.msdn.microsoft.com/Forums/vstudio/en-US/d15600ee-150c-4a4f-b50f-71187de3bf94/disable-alt-tab-in-c-program?forum=csharpgeneral

 
Share this answer
 
Comments
Francine DeGrood Taylor 16-Jun-14 13:02pm    
Unfortunately, this doesn't seem to work either. I set up a sample form using it, and can successfully block any other key combination, but alt-tab is not blocked.
After doing a good bit of research, the best answer that I can come up with is you can't do it. I've tried the code for several of the "how can I disable alt-tab" solutions that google finds. None of them disable this specific functionality.

Here's the problem. You can influence the keystrokes that are processed by the application. So you can catch and cancel a tab key that would move you between controls. You can filter out keystrokes that are going into your text box. You can ignore numbers from the keypad while allowing those entered via keys across the top of the keyboard.

But you can't stop Windows from doing its job. You can't keep the capslock key from being toggled on your keyboard. You can't keep users from ctrl-alt-delete to bring up the task manager to cancel your application. You can't keep them from surfing the web while using it. You can't keep resident processes from reacting to keystrokes that they are monitoring for.

This is safe and proper behavior. You shouldn't be able to write an application that affects other applications so casually. How many times has a badly behaved application frozen up and you have needed to alt-tab away, or ctrl-alt-delete to call up task manager to cancel the application? How annoying it would be if this badly behaved application made it impossible to shift focus to other functionality. You can always turn your computer off and on again, true. But what if a hacker manager to get that application inserted into your startup processes? OK, there's safe mode or a booter but you get the idea. Bad idea. Why would you want to do it? People should be able to have multiple accessible applications in case your program freezes or they need to perform other work while it is running.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900