Automatic screenshot on error

For questions and postings not covered by the other forums
Stokes
Posts: 66
Joined: Wed Oct 13, 2010 2:06 pm
Location: QLD, Australia

Automatic screenshot on error

Postby Stokes » Wed Oct 13, 2010 2:12 pm

Hello,

What we want to do is to take a screenshot of our application when the user gets an error.

So in the exception handler we would put in some code like this:

activeWindow.screenShot(c:\Temp\Error_Screenshot_1.jpg);

before the error comes up on the screen it will take a screen shot of what the user was doing so they can send it through to us if they wish.

The error message will say something like:

"Send error detail and the screenshot to support? Yes/No"

Has this been done by anyone before? Looking forward to any good ideas someone may have.

Thanks for your time,


Sam

torrie
Posts: 92
Joined: Fri Aug 14, 2009 11:24 am

Re: Automatic screenshot on error

Postby torrie » Wed Oct 13, 2010 3:55 pm

I haven't specifically done this, we use CardSchema (http://www.jade.co.nz/jadecare/download.htm) which provides good logging on exceptions, if gives very good information about the call stack and current state of the application.

You could get a image of the current form using the Window::createPicture method. This would capture the active window, not the complete desktop. The ActiveForm method on the Application would let you get the form that the user had open.

Stokes
Posts: 66
Joined: Wed Oct 13, 2010 2:06 pm
Location: QLD, Australia

Re: Automatic screenshot on error

Postby Stokes » Thu Oct 14, 2010 2:31 pm

Torrie, you are a legend!

This works well. Bug fixing will be much quicker now and there will be less going back and forth with the client trying to explain to them how to take a screen shot.

There are still a few things that I want to tidy up, my file is not deleting off the PC after I have used it and I want to give each of the screen shots and individual number. Both I will continue to work on for the rest of the day.

Here is the basic part of the code for anyone that is interested. This is within my exception handler:

Code: Select all

vars trFile : File; begin // Create the screenshot. create trFile transient; trFile.usePresentationFileSystem := false; trFile.fileName := "C:\temp6.bmp"; trFile.kind := File.Kind_Binary; // Open the file. trFile.open; // Read. trFile.writeBinary(app.activeForm.createPicture(false, true, 8)); // EMAIL THE ATTACHMENT ALONG WITH THE CALL STACK AND OTHER ERROR INFORMATION // Close the file. trFile.close; delete trFile;

Stokes
Posts: 66
Joined: Wed Oct 13, 2010 2:06 pm
Location: QLD, Australia

Re: Automatic screenshot on error

Postby Stokes » Thu Oct 14, 2010 2:34 pm

oh and I will change it to create a .png or .jpg instead of a bitmap.

I will paste my final code in here once it is complete.

Stokes
Posts: 66
Joined: Wed Oct 13, 2010 2:06 pm
Location: QLD, Australia

Re: Automatic screenshot on error

Postby Stokes » Thu Oct 14, 2010 3:33 pm

Final code:

Code: Select all

// Create the screenshot. create trFile transient; trFile.usePresentationFileSystem := true; trFile.fileName := app.getTempDir & "\SCREENDUMP.png"; trFile.kind := File.Kind_Binary; // Open the file. trFile.open; // Read. trFile.writeBinary(app.activeForm.createPictureAsType(false, true, 8, Window.PictureType_Png)); // Close the file. trFile.close; // Email the exception and screenshot to the specified email address. trSmtpManager.email(psToEmail, null, null, "Application exception on " & app.dbServerComputerName, psForEmail, String.None, trFile.fileName); trFile.purge; delete trFile;


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 49 guests