2013-07-28 2 views
2

응용 프로그램의 스크린 샷으로 PDF 파일을 만들어야하는 응용 프로그램을 만들고 있습니다.활성 창을 캡쳐 한 스크린 샷이지만 창을 캡쳐하지 않았습니다.

스크린 샷을 만드는 방법과이를 파일에 저장하는 방법을 찾았습니다. 대부분의 상황에서 모두 잘 작동합니다.

Teamviewer와 같이 하나 이상의 화면이나 프로그램을 사용하면 내 문제가 발생합니다. 문제는 내 프로그램이 올바른 영역 (어떤 화면이 언제든지 화면의 좌표)을 캡처하지만 창 뒤에있는 모든 것을 캡처하지만 창은 캡처하지 않는다는 것입니다.

내가 잘못했거나 세부 사항을 놓친 사람이 누구인지 아는 사람이 있습니까? 어떤 도움이나 예에 미리

// creates an rectangle of the size of the window 
     Rectangle bounds = new Rectangle(
      (int)System.Windows.Application.Current.MainWindow.Left+10, 
      (int)System.Windows.Application.Current.MainWindow.Top+10, 
      (int)System.Windows.Application.Current.MainWindow.Width-20, 
      (int)System.Windows.Application.Current.MainWindow.Height-20); 

     // creates a bitmap with a screenshot of the size of the window 
     Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height); 
     Graphics g = Graphics.FromImage(bitmap); 
     g.CopyFromScreen(new System.Drawing.Point(bounds.Left, bounds.Top), new System.Drawing.Point(0,0), bounds.Size); 

감사 : 여기

내가 현재 사용하고 코드입니다.

답변

1

나는 당신을 정확하게 이해하지 못합니다. 나는 당신이 할 필요가 있다고 생각합니다 활성 창을 캡처합니다.

Rectangle bounds = Screen.GetBounds(Point.Empty); 
using(Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) 
{ 
    using(Graphics g = Graphics.FromImage(bitmap)) 
    { 
     g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size); 
    } 
    bitmap.Save("test.jpg", ImageFormat.Jpeg); 
} 

//for capturing current window use 

Rectangle bounds = this.Bounds; 
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) 
{ 
    using (Graphics g = Graphics.FromImage(bitmap)) 
    { 
     g.CopyFromScreen(new Point(bounds.Left,bounds.Top), Point.Empty, bounds.Size); 
    } 
    bitmap.Save("C://test.jpg", ImageFormat.Jpeg); 
} 

출처 : Capture screenshot of active window?