As all you know, PrintWindow api give us a black image when us want a capture screenshot of Google Chrome window. So, a friend said me that a possible solution for this problem is:
Reduce Google Chrome window for -1px in both sides and after this, reset to original size. And so, will repaint again.
Based on code below, someone could help me make this? sincerely I don't know where begin.
==================================================================
[DllImport("[login to view URL]", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("[login to view URL]", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("[login to view URL]")]
private static extern IntPtr GetDC(IntPtr WindowHandle);
[DllImport("[login to view URL]")]
private static extern void ReleaseDC(IntPtr WindowHandle, IntPtr DC);
[DllImport("[login to view URL]")]
private static extern IntPtr GetWindowRect(IntPtr WindowHandle, ref Rect rect);
[DllImport("[login to view URL]", SetLastError = true)]
[return: MarshalAs([login to view URL])]
static extern bool PrintWindow(IntPtr hwnd, IntPtr hDC, uint nFlags);
[StructLayout([login to view URL])]
private struct Rect
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
public static Bitmap Capture(IntPtr handle)
{
Rect rect = new Rect();
GetWindowRect(handle, ref rect);
Bitmap Bmp = new Bitmap([login to view URL] - [login to view URL], [login to view URL] - [login to view URL]);
Graphics memoryGraphics = [login to view URL](Bmp);
IntPtr dc = [login to view URL]();
bool success = PrintWindow(handle, dc, 0);
[login to view URL](dc);
return Bmp;
}
private void button1_Click(object sender, EventArgs e)
{
IntPtr WindowHandle = FindWindowEx([login to view URL], [login to view URL], "Chrome_WidgetWin_1", null);
Bitmap BMP = Capture(WindowHandle);
[login to view URL]("C:\\[login to view URL]");
[login to view URL]();
}
Hello, I'm an expert C# developer with 10 years of experience. I've read and understood your requirements. I've already made the changes to the code and it's working. Please contact me.
Hello, sir.
I read your job posting with interest.
I am very interested in your job.
I am a excellent software developer and have rich experiences in c/c++ for 10+ years.
I can help you complete your job perfectly in short time.
I want to discuss in more details about this job.
Looking forward your reply.
Thank you.
Best regards.
i hope you wait until i send my proposal because i did not want to do the work this way and i did not worked with this api but if you only want to capture the screen from a application there may be easier ways to do that