Is there a way to use sendkeys to do a print screen?
Printable View
Is there a way to use sendkeys to do a print screen?
No.
You can use bitblt though.
what is bitblt
API.
try:
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Call keybd_event(vbKeySnapshot, 0, 0, 0)
That's GREAT.......Quote:
Originally posted by BuggyProgrammer
try:
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Call keybd_event(vbKeySnapshot, 0, 0, 0)
Now I just need to find some way to get it to work in VBA....
i tested, it works. make sure
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
is at the TOP of everything.
It does work!!!!!
how would I then save it.
C:\test.....
??
I found some code but it does not work in Access.
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 Sub Command1_Click()
'1 is the screen. Replace it with 0 and you'll get the form
keybd_event vbKeySnapshot, 0, 0&, 0&
DoEvents
SavePicture Clipboard.GetData(vbCFBitmap), "C:\Test.bmp"
Clipboard.Clear
End Sub
VB Code:
Private Declare Function GetDesktopWindow Lib "USER32" () As Long Private Declare Function GetDC Lib "USER32" (ByVal hWnd As Long) As Long Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long Public Sub SaveDesktop(FilePath As String) Dim A As Long Dim s As Long A = GetDesktopWindow() s = GetDC(A) Picture1.Width = Screen.Width / Screen.TwipsPerPixelX Picture1.Height = Screen.Height / Screen.TwipsPerPixelY BitBlt Picture1.hDC, 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, s, 0, 0, vbSrcCopy SavePicture Picture1.Image, FilePath End Sub
Does it without loosing your clipboard data ;)
Did you get that to work in Access?
If so what did you reference?
i dont know if it would work in access...didnt try it