程序在后台时,使用键盘快捷键调用功能

时间:2017-07-20 13:37:31

标签: c# screenshot

当程序在前台时它可以工作,但是如果它在后台它不工作。求救!

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Control && e.KeyCode.ToString() == "A")
    {
        Bitmap bm = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
        Graphics g = Graphics.FromImage(bm);
        g.CopyFromScreen(0, 0, 0, 0, bm.Size);
        pictureBox1.Image = bm;
    }
}

0 个答案:

没有答案