PC Review


Reply
Thread Tools Rate Thread

Capture Screen Image via Code w/out User Interaction

 
 
dch3
Guest
Posts: n/a
 
      29th Sep 2008
I'm entertaining the idea of enhancing my error logging by doing a screen
capture at the time that the error handler kicks in.

Anyone have experience with capturing the screen image and then saving it
via code?
 
Reply With Quote
 
 
 
 
BeWyched
Guest
Posts: n/a
 
      29th Sep 2008
Hi.

You can use a Windows API call to achieve this:

In the form's declaration section (i.e. at the top) enter:

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan
As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Then, in your error capture coding put:

keybd_event VK_SNAPSHOT, 1, 0, 0

This will copy a 'Print Screen' image to the clipboard. What will you to do
with that? Let me know and I'll try and help.

Cheers.

BW





"dch3" wrote:

> I'm entertaining the idea of enhancing my error logging by doing a screen
> capture at the time that the error handler kicks in.
>
> Anyone have experience with capturing the screen image and then saving it
> via code?

 
Reply With Quote
 
dch3
Guest
Posts: n/a
 
      29th Sep 2008
From the clipboard, it'd be saving the image to a file. Off the top of the
head, mostly likely using Paint along the lines of Set objPaint =
CreateObject("Paint.Application"). Of course, I've never tried automating
paint and have no idea if its possible.

"BeWyched" wrote:

> Hi.
>
> You can use a Windows API call to achieve this:
>
> In the form's declaration section (i.e. at the top) enter:
>
> Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan
> As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
>
> Then, in your error capture coding put:
>
> keybd_event VK_SNAPSHOT, 1, 0, 0
>
> This will copy a 'Print Screen' image to the clipboard. What will you to do
> with that? Let me know and I'll try and help.
>
> Cheers.
>
> BW
>
>
>
>
>
> "dch3" wrote:
>
> > I'm entertaining the idea of enhancing my error logging by doing a screen
> > capture at the time that the error handler kicks in.
> >
> > Anyone have experience with capturing the screen image and then saving it
> > via code?

 
Reply With Quote
 
BeWyched
Guest
Posts: n/a
 
      29th Sep 2008
No, you can't automate Paint.

How about automating Word and pasting in the image.

Try:

Dim wdApp, docNew
keybd_event VK_SNAPSHOT, 1, 0, 0
Set wdApp = CreateObject("Word.Application")
With wdApp
docNew = .Documents.Add
.Selection.Paste
.Visible = True
End With

Cheers.

BW

"dch3" wrote:

> From the clipboard, it'd be saving the image to a file. Off the top of the
> head, mostly likely using Paint along the lines of Set objPaint =
> CreateObject("Paint.Application"). Of course, I've never tried automating
> paint and have no idea if its possible.
>
> "BeWyched" wrote:
>
> > Hi.
> >
> > You can use a Windows API call to achieve this:
> >
> > In the form's declaration section (i.e. at the top) enter:
> >
> > Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan
> > As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
> >
> > Then, in your error capture coding put:
> >
> > keybd_event VK_SNAPSHOT, 1, 0, 0
> >
> > This will copy a 'Print Screen' image to the clipboard. What will you to do
> > with that? Let me know and I'll try and help.
> >
> > Cheers.
> >
> > BW
> >
> >
> >
> >
> >
> > "dch3" wrote:
> >
> > > I'm entertaining the idea of enhancing my error logging by doing a screen
> > > capture at the time that the error handler kicks in.
> > >
> > > Anyone have experience with capturing the screen image and then saving it
> > > via code?

 
Reply With Quote
 
dch3
Guest
Posts: n/a
 
      29th Sep 2008
Always a possibility, but if its an office app I'd probably end up looking
flat out at sending me messages via Outlook with the image. All of my
On_Error routines call an external sub which can be easily modified.

"BeWyched" wrote:

> No, you can't automate Paint.
>
> How about automating Word and pasting in the image.
>
> Try:
>
> Dim wdApp, docNew
> keybd_event VK_SNAPSHOT, 1, 0, 0
> Set wdApp = CreateObject("Word.Application")
> With wdApp
> docNew = .Documents.Add
> .Selection.Paste
> .Visible = True
> End With
>
> Cheers.
>
> BW
>
> "dch3" wrote:
>
> > From the clipboard, it'd be saving the image to a file. Off the top of the
> > head, mostly likely using Paint along the lines of Set objPaint =
> > CreateObject("Paint.Application"). Of course, I've never tried automating
> > paint and have no idea if its possible.
> >
> > "BeWyched" wrote:
> >
> > > Hi.
> > >
> > > You can use a Windows API call to achieve this:
> > >
> > > In the form's declaration section (i.e. at the top) enter:
> > >
> > > Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan
> > > As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
> > >
> > > Then, in your error capture coding put:
> > >
> > > keybd_event VK_SNAPSHOT, 1, 0, 0
> > >
> > > This will copy a 'Print Screen' image to the clipboard. What will you to do
> > > with that? Let me know and I'll try and help.
> > >
> > > Cheers.
> > >
> > > BW
> > >
> > >
> > >
> > >
> > >
> > > "dch3" wrote:
> > >
> > > > I'm entertaining the idea of enhancing my error logging by doing a screen
> > > > capture at the time that the error handler kicks in.
> > > >
> > > > Anyone have experience with capturing the screen image and then saving it
> > > > via code?

 
Reply With Quote
 
Jim Burke in Novi
Guest
Posts: n/a
 
      29th Sep 2008
If your error log is a table, you could create a bound object frame field to
contain the picture, then set that field = the picture you copied to the
clipboard. I've never done this, but it seems like that would work. You can
imbed the picture into the field or the field can point to a file. Maybe I'm
off base with what you're trying to do.

"dch3" wrote:

> I'm entertaining the idea of enhancing my error logging by doing a screen
> capture at the time that the error handler kicks in.
>
> Anyone have experience with capturing the screen image and then saving it
> via code?

 
Reply With Quote
 
Jim Burke in Novi
Guest
Posts: n/a
 
      29th Sep 2008
If I'm on the right track for what you're trying to do, here's a link that
may help..

http://www.devx.com/vb2themax/Tip/18341

"Jim Burke in Novi" wrote:

> If your error log is a table, you could create a bound object frame field to
> contain the picture, then set that field = the picture you copied to the
> clipboard. I've never done this, but it seems like that would work. You can
> imbed the picture into the field or the field can point to a file. Maybe I'm
> off base with what you're trying to do.
>
> "dch3" wrote:
>
> > I'm entertaining the idea of enhancing my error logging by doing a screen
> > capture at the time that the error handler kicks in.
> >
> > Anyone have experience with capturing the screen image and then saving it
> > via code?

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      30th Sep 2008
"dch3" <(E-Mail Removed)> wrote in message
news:2A5B6FFA-50BF-4317-9D47-(E-Mail Removed)...
> I'm entertaining the idea of enhancing my error logging by doing a screen
> capture at the time that the error handler kicks in.
>
> Anyone have experience with capturing the screen image and then saving it
> via code?



I suggest you have a look at this from Stephen Lebans:

http://www.lebans.com/imageclass.htm


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Screen Capture (Screen Copying) example / the perils of Image/ Bitmapcopying to file raylopez99 Microsoft C# .NET 2 30th Aug 2008 12:10 PM
What is wrong with this code? Screen capture and export as image? Internetdomainowner@hotmail.com Microsoft Excel Programming 1 5th Aug 2008 04:07 AM
Re: can't capture screen image Elmo Windows XP Help 0 20th Jan 2007 01:54 AM
Capture Screen Image wvnatvcrw Windows XP General 2 22nd Jan 2004 07:35 PM
How can I capture a screen image Ron Chiles Windows XP General 2 29th Aug 2003 08:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:01 PM.