By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 1,592 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

Print Screen to picture

P: 21
Is it possible to make a printscreen in scripting and let this printscreen come in a picture on the form?

thanks
Jan 15 '08 #1
Share this Question
Share on Google+
8 Replies


lotus18
100+
P: 866
Is it possible to make a printscreen in scripting and let this printscreen come in a picture on the form?

thanks
try to use an API function for that
Jan 16 '08 #2

P: 21
I solved it this way.

SendKeys "{PRTSC}"

followed by

imgPrintScreen.Picture = Clipboard.GetData

With imgPrintScreen the namen of the image on the screen.
Jan 16 '08 #3

P: 21
I was too fast with my post because now I see that SendKeys "{PRTSC}" isn't working. In API I can only find a way to take printscreen of a window, not of the whole screen.
Jan 16 '08 #4

Expert 5K+
P: 8,434
This is a standard function performed by screensavers. If you look up how to create a screensaver in VB, you'll find your answer.
Jan 16 '08 #5

QVeen72
Expert 100+
P: 1,445
Hi,

Declare this API on top of the form :

Expand|Select|Wrap|Line Numbers
  1. Private Declare Sub keybd_event Lib "user32" _
  2.         (ByVal bVk As Byte, ByVal bScan As Byte, _
  3.         ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
  4.  
  5. Private Sub Command1_Click()
  6.     DoEvents
  7.     Clipboard.Clear
  8.     keybd_event vbKeySnapshot, 0, 0, 0
  9.     DoEvents
  10.     keybd_event vbKeySnapshot, 0, &H2, 0
  11.     DoEvents
  12.     Picture1.Picture = Clipboard.GetData(vbCFBitmap)
  13.     DoEvents
  14.     Me.Refresh
  15. End Sub
  16.  
  17.  
Regards
Veena
Jan 16 '08 #6

P: 21
Thanks for the help.

Know I still have 1 small problem. I want to have the print screen without the form, so I hide the form just before I take the print screen, but the script is too fast, is it possible to wait until the form is really closed? I tried with frmblebleble.Visible but it looks like that parameter changes immediately when you do hide.
Jan 16 '08 #7

P: 21
Ok, problem fixed, just 1 DoEvents in between and it worked like I was hoping.
Jan 16 '08 #8

P: 4
hi bro,

i have a problem with the "vbKeySnapshot".
i am getting an error. where do i declare this??
Nov 4 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.