|
-
Mar 14th, 2006, 03:26 PM
#1
Thread Starter
Frenzied Member
getting the whole desktop
VB Code:
Option Explicit
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Function SaveFormPic() As Picture
Dim pic As StdPicture
Set pic = Clipboard.GetData(vbCFBitmap)
DoEvents
keybd_event vbKeySnapshot, 1, 0, 0
DoEvents
Set SaveFormPic = Clipboard.GetData(vbCFBitmap)
Clipboard.SetData pic, vbCFBitmap
End Function
Private Sub Command1_Click()
SavePicture SaveFormPic, "C:\MyPic.jpg" 'picture location
End Sub
hey guys, the above code works fine but only grabs the active window, how can i make it grab the desktop, thanks!
-
Mar 14th, 2006, 05:07 PM
#2
Re: getting the whole desktop
you may try the link in my signature. it grabs the whole desktop, but i made it for a specific post, you may need to experiment and change the code according to your need.
Harsh Gupta
-
Mar 14th, 2006, 06:15 PM
#3
Thread Starter
Frenzied Member
Re: getting the whole desktop
thanks harsh but the bmp is far too big, nearly 3mb
-
Mar 15th, 2006, 07:02 AM
#4
Re: getting the whole desktop
Try this
VB Code:
Option Explicit
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const VK_SNAPSHOT = &H2C
Private Function SaveScreen(ByVal theFile As String) As Boolean
'To get the Entire Screen
Call keybd_event(vbKeySnapshot, 1, 0, 0)
'To get the Active Window
'Call keybd_event(vbKeySnapshot, 0, 0, 0)
SavePicture Clipboard.GetData(vbCFBitmap), theFile
SaveScreen = True
End Function
Private Sub Command1_Click()
Call SaveScreen("d:\shot1.bmp")
End Sub
-
Mar 15th, 2006, 11:32 AM
#5
Re: getting the whole desktop
 Originally Posted by Pouncer
thanks harsh but the bmp is far too big, nearly 3mb
yes, it because BMPs do have large file size. you may need some good JPG encoder class to convert it to encode it to small size, because VB does not create JPG files.
you may search here to find one good JPG encoder thing, i dont remember exactly who posted it, but that was a good thing from Planet-source-code. so you may search PSC also.
Harsh Gupta.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|