Re: Web Browser Control...
Try this
Code:
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 pstrFileName 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), pstrFileName
SaveScreen = True
End Function
Private Sub Command1_Click()
Call SaveScreen("C:\Windows\Desktop\shot1.bmp")
End Sub
Re: Web Browser Control...
Hack...
First off, thanks for your helpful code and quick reply !!!
I have tried out you code and it works great... However I really need to be able to capture only what is contained within the web browser control and not the entire form.
Thanks Again !!!
Re: Web Browser Control...
If you notice that the code I posted gives you two options.
Entire Screen is active.
Comment that out, and use the other one which is just the Active Window. See how that works.
Re: Web Browser Control...
Hack,
I must be doing something wrong because it gives me the same image as before (the entire screen).
I first thought maybe I needed to "setfocus" to the web browser control before calling your routine but that was no help...
Code:
WebBrowser1.SetFocus
Call SaveScreen("C:\" & Format(Now, "HHMMSS") & ".bmp")
Clipboard.Clear ' <-- doesn't seem to clear clipboard ??
Re: Web Browser Control...
Arey you using Call keybd_event(vbKeySnapshot, 0, 0, 0) instead of Call keybd_event(vbKeySnapshot, 1, 0, 0)
Re: Web Browser Control...
Yup... Calling the correct line.
Call keybd_event(vbKeySnapshot, 0, 0, 0)