プライマリディスプレイの画面イメージをキャプチャーすると、タスクバーが含まれた状態でキャプチャーされてしまいます。
タスクバー領域(オレンジで囲んだ部分)を取り除く為に、タスクバーの矩形情報を取得する方法を調べてみました。
|cs| [System.Runtime.InteropServices.DllImport("coredll.dll")] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[System.Runtime.InteropServices.DllImport("coredll.dll")] public static extern int GetWindowRect(IntPtr hwnd, ref RECT lpRect);
private void button1_Click(object sender, EventArgs e) { RECT rect = new RECT(); // タスクバーのhwndを取得 IntPtr hwnd = FindWindow("HHTaskBar", ""); // hwndの矩形情報を取得 GetWindowRect(hwnd, ref rect);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.AppendFormat(null, "top={0}\n", rect.top);
sb.AppendFormat(null, "bottom={0}\n", rect.bottom);
sb.AppendFormat(null, "left={0}\n", rect.left);
sb.AppendFormat(null, "right={0}\n", rect.right);
MessageBox.Show(sb.ToString());
} ||<