如何用vb截屏并保存到指定文件夹
是截屏,截屏,不是截图,保存地址是建一个diverlistbox可随时更改的,要代码加解释,如果我看的懂追分,不要copy,我在百度上问没有一个写的是能运行的...
是截屏,截屏,不是截图,保存地址是建一个diverlistbox可随时更改的,要代码加解释,如果我看的懂追分,不要copy,我在百度上问没有一个写的是能运行的
展开
2个回答
2013-09-12
展开全部
一个非常简单的方法,非模拟按键。 只用一个timer控件,和一个按扭就可以。
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
Private Declare Function GetActiveWindow Lib "user32" () As Long
Dim a
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
On Error Resume Next
MkDir "c:\zt" '建文件夹
Me.AutoRedraw = True
End Sub
Private Sub Timer1_Timer()
a = a + 1
If a = 3 Then '三秒后开始抓屏
Me.Hide
BitBlt Me.hDC, 0, 0, Screen.Width, Screen.Height, _
GetDC(GetActiveWindow), 0, 0, vbSrcCopy '抓屏
Me.Show
Dim sFile As String
sFile = "C:\zt\" & Format(Now, "yyyymmddhhmmss") & ".BMP"
SavePicture Me.Image, sFile '保存Me.hDC
Timer1.Enabled = False
End If
End Sub
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
Private Declare Function GetActiveWindow Lib "user32" () As Long
Dim a
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
On Error Resume Next
MkDir "c:\zt" '建文件夹
Me.AutoRedraw = True
End Sub
Private Sub Timer1_Timer()
a = a + 1
If a = 3 Then '三秒后开始抓屏
Me.Hide
BitBlt Me.hDC, 0, 0, Screen.Width, Screen.Height, _
GetDC(GetActiveWindow), 0, 0, vbSrcCopy '抓屏
Me.Show
Dim sFile As String
sFile = "C:\zt\" & Format(Now, "yyyymmddhhmmss") & ".BMP"
SavePicture Me.Image, sFile '保存Me.hDC
Timer1.Enabled = False
End If
End Sub
2013-09-12
展开全部
设置
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询