我讀過噸的其他問題與Google搜索這個問題,但我只能找出如何,如果我使用的WinForms做到這一點。我目前正在編寫一個庫,而庫的一個功能是處理日誌記錄。我正在實現的功能之一是在將問題寫入日誌之前自動截取頁面的屏幕截圖。與此相關的問題是我不知道哪個監視器需要截圖,因此如果用戶將瀏覽器移動到不同的監視器上,我仍然會拍攝一個主要的監視器。如何檢測運行ASP.NET程序的監視器?
public static Bitmap ScreenShot(string saveLocation, string fileName)
{
Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics.FromImage(bitmap).CopyFromScreen(0, 0, 0, 0, bitmap.Size);
string savePath = Path.Combine(Path.GetDirectoryName(saveLocation), "ScreenShots");
if (!Directory.Exists(savePath))
Directory.CreateDirectory(savePath);
bitmap.Save(Path.Combine(savePath, fileName), ImageFormat.Png);
return bitmap;
}
我試過Screen.FromControl()
,但因爲它不是一個WinForms應用程序,我沒有任何System.Windows.Forms.Controls爲它找到。
確實ASP.NET有什麼相同呢?或者我可以明確地投射到一個winform控件?
你的截圖()方法運行服務器端 - 它怎麼可能把客戶端的截圖? – n8wrl
只有當瀏覽器與ASP服務器在同一臺計算機上運行時,這纔有用嗎? – antlersoft
搶奪你有的代碼並轉換爲JavaScript :)。 – JonH