?
Solved

How to trap Alt+Tab & Ctrl+Esc keypress

Posted on 1997-11-06
7
Medium Priority
?
304 Views
Last Modified: 2013-12-03
Hello,

I'm writing a Vision Software where I don't want the user to accidentally press the system keys (ie: alt+tab & 
ctrl+esc). How do I go about trapping these messages?

I'm writing my software in Microsoft's Visual C++ 5.0 targeted for Window's NT platform. I tried to enter the above keypresses in the accelerator table and use the TranslateAccelerator API but somehow, these keypress messages never get trapped.


Please Help.


Thank You
Vivien A.
0
Comment
Question by:vcl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:kburns102197
ID: 1408223
The method & functions necessary to trap these keys is dependent on the development language.    What language are you writing in?
0
 

Author Comment

by:vcl
ID: 1408224
Edited text of question
0
 
LVL 22

Expert Comment

by:nietod
ID: 1408225
I've been watching this question intently, because it is a problem I've been having to.  The fact you haven't gotten an answer is discouraging, it looks like there almost isn't away.  
One thing that makes this hard to do (as you may already know) is that windows does not pass the regular keydown, keyup, and character messages for these keys.  In fact, it appears to me that it sends no messages at all for these keys.  That seems a little unfair.  If this is true, then a message processing solution is out.  An approach that might work (I haven't tried) would be to use a hook.  It is possible to hook the keyboard with SetWindowsHookEx() using WH_KEYBOARD.

I have no experience in this area, so I'm not sure that the restrictions, if any, are.  But you might have the hook routine look for the keys and, if found, send a message, to your application.  This of course requires that the hook routine get notified for these keys.  I don't know if it is.

If you try this, I'd like to know what you find.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Expert Comment

by:borov
ID: 1408226
Surely you can't do it without writing driver which intercepts these keystrokes. Setting hooks doesn't help, I've worked on the same problems a couple of years ago and had not found any simple solution. Try to search WEB for the driver.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1408227
What is the problem with hooks?  Is it that you don't get notification for these two keys?
0
 

Expert Comment

by:borov
ID: 1408228
No, you get notification on ALT as syskey. But when you press ALT-TAB - oops - you got nothing. Impossible to prevent the switching itself. I forgot many details, so dont ask me any details - I can get wrong :).
0
 
LVL 11

Accepted Solution

by:
alexo earned 300 total points
ID: 1408229
AFAIK, it is impossible to "steal" the ALT-TAB, etc. keystrokes from NT (95 is a different matter) but you can fudge it.

Whenever your window loses focus, just force it back.  (Of course, you'll have to deal with issues like message boxes, multiple-windows applications, etc. but it's doable).

One way: when your window gets a WM_KILLFOCUS message, do a SetFocus() back (maybe you'll also have to bring your window to the foreground and other stuff).
A WM_CAPTURECHANGED message is also a possible candidtate for "overriding".

Another way is to do it with global hooks -- SetWindowsHookEx().
Either use WH_CALLWNDPROC and look for focus switch messages, or use WH_CBT, look for HCBT_SETFOCUS and return 1 to disallow it.
See whichever works for you.

Note that there may be other caveats.  Spy++ is your friend.

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

777 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