How to catch Alt-Tab and such in C#?

天涯浪子 提交于 2019-12-25 07:39:33

问题


A friend is trying to write something not entirely unlike the old wintutor.exe from the olden days of Windows 3.1. It's meant to show some complete newbs the ropes of using WinXP, and the tutorial needs to respond to Alt + Tab and such for their own protection. How do you do this in C# Winforms?


回答1:


I have no first-hand experience doing this and I don't know if there's an easier way now, but this CodeProject article discusses using C# to tap low-level Windows APIs that will trap keyboard strokes like Alt + Tab.




回答2:


Serious question: do you really need to change what Alt + Tab does if you're teaching someone to use Windows?

It's kind of a basic tool of the OS, and it would be quite misleading for their introduction to the OS to behave differently to normal in such a fundamental way.

It would be much simpler to just show them a video explaining what that key combination does.

Some background reading.

If you want to lock down the GUI (as is sometimes done by the demo apps that run in computer stores), you could have a timer running that constantly forces your app to be the foreground. Some info here.



来源:https://stackoverflow.com/questions/1267943/how-to-catch-alt-tab-and-such-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!