vb 求”当前窗体“截图源码 ,并可以保存到文件 每秒钟截几张,越简单越好。
1个回答
展开全部
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()
a = 0
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
On Error Resume Next
Me.Height = Screen.Height
Me.Width = 5000
MkDir "D:\zt" '建文件夹
Me.AutoRedraw = True
Pic1.AutoRedraw = True
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
a = a + 1
Me.Hide
If a = 3 Then '三秒后开始抓屏
BitBlt Me.hdc, 0, 0, Screen.Width, Screen.Height, _
GetDC(GetActiveWindow), 0, 0, vbSrcCopy '抓屏
'BitBlt Me.hDC, 0, 0, 200, 200, GetDC(GetActiveWindow), 100, 100, vbSrcCopy '抓屏
Me.Show
Dim sFile As String
sFile = "D:\zt\" & Format(Now, "yyyymmddhhmmss") & ".BMP"
'Pic1.Picture = sFile
SavePicture Me.Image, sFile '保存Me.hDC
Timer1.Enabled = False
End If
End Sub
自己再修改修改时间,保存路径等
祝你好运!
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()
a = 0
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
On Error Resume Next
Me.Height = Screen.Height
Me.Width = 5000
MkDir "D:\zt" '建文件夹
Me.AutoRedraw = True
Pic1.AutoRedraw = True
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
a = a + 1
Me.Hide
If a = 3 Then '三秒后开始抓屏
BitBlt Me.hdc, 0, 0, Screen.Width, Screen.Height, _
GetDC(GetActiveWindow), 0, 0, vbSrcCopy '抓屏
'BitBlt Me.hDC, 0, 0, 200, 200, GetDC(GetActiveWindow), 100, 100, vbSrcCopy '抓屏
Me.Show
Dim sFile As String
sFile = "D:\zt\" & Format(Now, "yyyymmddhhmmss") & ".BMP"
'Pic1.Picture = sFile
SavePicture Me.Image, sFile '保存Me.hDC
Timer1.Enabled = False
End If
End Sub
自己再修改修改时间,保存路径等
祝你好运!
追问
不行啊,用不了,截图不起,别说截当前窗口了!!!
追答
我在我的电脑上调试没问题呀!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |