2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【C#】サブモニタのみフルスクリーンでスクリーンショットを撮りたい

Posted at

スクリーンショットがクリップボードにコピーされるやつ
丁度いいのがなかったので自作

// 何かしらのイベント
private void button_Click(object sender, EventArgs e)
{
    Screen p = Screen.AllScreens[0];     // プライマリ
    Screen s = Screen.AllScreens[1];     // セカンダリ(今回撮るのはこっち)
    int x = s.Bounds.X;
    int y = s.Bounds.Y;
    int w = s.Bounds.Width;
    int h = s.Bounds.Height;

    using (Bitmap b = new Bitmap(w, h))
    using (Graphics g = Graphics.FromImage(b))
    {
        g.CopyFromScreen(new Point(x, y), new Point(0, 0), b.Size);
        Clipboard.SetImage(b);
    }
}
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?