Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am trying to capture the Screen. that is when our website was running that time particular webpage capture and store it folder. i think its possible in javascript pls help me

EDIT:
Server side code using CopyFromScreen throws error. My code is as follows -
C#
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap as System.Drawing.Image);
graphics.CopyFromScreen(25, 25, 25, 25, bitmap.Size);
bitmap.Save(@"c:\myscreenshot.bmp", System.Drawing.Imaging.ImageFormat.Bmp);


I get the following error -
HTML
Server Error in '/OnlineAutomation' Application.
The handle is invalid
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: The handle is invalid
Source Error:
Line 54:         System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap as System.Drawing.Image);
Line 55: 
Line 56:         graphics.CopyFromScreen(25, 25, 25, 25, bitmap.Size);
Line 57: 
Line 58:         bitmap.Save(@"c:\myscreenshot.bmp", System.Drawing.Imaging.ImageFormat.Bmp);

Source File: c:\Inetpub\wwwroot\OnlineAutomation\Forms\test.aspx.cs    Line: 56
Stack Trace:
[Win32Exception (0x80004005): The handle is invalid]
   System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation) +542
   System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize) +29
   Forms_test.btnsave_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\OnlineAutomation\Forms\test.aspx.cs:56
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053 


i need not capture coding page. capture in running webpage that is display page. Please help.
Posted
Updated 2-Mar-12 0:38am
v3
Comments
Dinesh Mani 2-Mar-12 1:39am    
Where do you want to place the screen shot? on the client machine?
Member 8311095 2-Mar-12 5:00am    
yes,in windows.form using CopyFromScreen did not work.its display error handle invalid so i think clientside possible.but how do? help me
Dinesh Mani 2-Mar-12 5:20am    
If you use javascript the screenshot would only be available on the client machine and not on the server. I believe CopyFromScreen is the way to go.

Post your code so that we can see what is throwing the invalid handle error...
Member 8311095 2-Mar-12 5:51am    
Server Error in '/OnlineAutomation' Application.
The handle is invalid
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: The handle is invalid

Source Error:

Line 54: System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap as System.Drawing.Image);
Line 55:
Line 56: graphics.CopyFromScreen(25, 25, 25, 25, bitmap.Size);
Line 57:
Line 58: bitmap.Save(@"c:\myscreenshot.bmp", System.Drawing.Imaging.ImageFormat.Bmp);


Source File: c:\Inetpub\wwwroot\OnlineAutomation\Forms\test.aspx.cs Line: 56

Stack Trace:

[Win32Exception (0x80004005): The handle is invalid]
System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation) +542
System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize) +29
Forms_test.btnsave_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\OnlineAutomation\Forms\test.aspx.cs:56
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053


i need not capture coding page. capture in running webpage that is display page

my code as follows

System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);

System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap as System.Drawing.Image);

graphics.CopyFromScreen(25, 25, 25, 25, bitmap.Size);

bitmap.Save(@"c:\myscreenshot.bmp", System.Drawing.Imaging.ImageFormat.Bmp);

help me
Anuja Pawar Indore 2-Mar-12 1:49am    
Done formatting of the question

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900