Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
您好我正在开发一个 C# WM 6.5 控制台应用程序。它在后台运行,而另一个应用程序具有焦点。我需要能够在用户按下 ESC 键时进行捕捉,但我不想干扰主应用程序的操作。我不知道该怎么做。有什么建议么?
能否请您发布您的确切方法
[System.Runtime.InteropServices.DllImport("coredll.dll")] public static extern short GetAsyncKeyState(int keyCode); if (GetAsyncKeyState(27) != 0) { //do something here cause the ESC key was pressed }