按PRINTSCREEN时Form_Keydown事件不工作 [英] Form_Keydown event is not working when PrintScreen is pressed

查看:194
本文介绍了按PRINTSCREEN时Form_Keydown事件不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检测我的表格上的<大骨节病>打印屏幕键,但像<大骨节病> PRTSC 和<大骨节病> SysRq的不火的<键code>的KeyDown 事件。

I'm trying to detect the Print Screen key on my form, but keys like Prtsc and SysRq don't fire the KeyDown event..

    private void Form1_KeyDown(object sender, KeyEventArgs e)
    {
        // Trying to detect if it fires KeyDown, but it doesn't
        MessageBox.Show(e.KeyValue.ToString());
    }



我不出来,也许我真的很愚蠢..

I can't figure it out, maybe I'm really dumb..

推荐答案

这是可以做到的,但它不是直接的。你不能做到这一点的KeyPress 的KeyDown 事件:正如你所发现的,它并不能让他们消防

It can be done, but it's not straightforward. You can't do it with the KeyPress or KeyDown events: as you have discovered, it doesn't make them fire.

但你仍然可以用C#做​​:你只需要使用Windows的API。因为相关的代码是漫长的,我张贴的链接:

But you can still do it with c#: you just have to use the Windows APIs. Because the relevant code is lengthy, I'm posting the link:

捕获Print Screen键

顺便说一句,你不是哑巴。 :)虽然这看起来像它应该有一个明显的,简单的答案,它没有:这是真正的复杂,使情况发生。但它可以做到的。

Incidentally, you're not dumb. :) Even though this seems like it should have an obvious, simple answer, it doesn't: this is genuinely complex to make happen. But it can be done.

这篇关于按PRINTSCREEN时Form_Keydown事件不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆