Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

taking screen shots 1

Status
Not open for further replies.

kenndot

Programmer
May 15, 2001
316
US
Hi folks,

I'm trying to write a program where I can take a screen shot of a module (another program) and send it to a word doc...

what's the most efficient way of accomplishing this? is there an api call?
 
Here's the first part... saves the screen to "My.bmp" in the current folder.
[tt]
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_MENU = &H12
Private Const VK_SNAPSHOT = &H2C
Private Const KEYEVENTF_KEYUP = &H2

Private Function SaveScreen(sFile As String) As Boolean
Dim sPic As IPictureDisp
On Error GoTo Errhandler
Clipboard.Clear
keybd_event VK_MENU, 0, 0, 0
DoEvents
keybd_event VK_SNAPSHOT, 1, 0, 0
DoEvents
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
DoEvents
Set sPic = Clipboard.GetData(0)
SavePicture sPic, sFile
Clipboard.Clear
Set sPic = Nothing
SaveScreen = True
Errhandler:
End Function

Private Sub Command1_Click()
SaveScreen "My.bmp"
End Sub
[/tt]

The rest shouldn't be to hard.

VCA.gif

Alt255@Vorpalcom.Intranets.com​
 
Alt255 -

Coool!
I was looking through the API functions for GetDesktopBMP, etc. without any success. Good old SendKeys (well, the API version anyway!).

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top