Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

VBA保存剪贴板为Bmp(加PrtScrn截屏)

时 间:2011-10-09 07:40:55
作 者:dbaseIIIer   ID:22003  城市:深圳
摘 要:截屏只是模拟了键盘的 {PrtScrn} 及 %{PrntScrn} 未能做到范围的!

不过保存 bmp 是异常的快!
值得保留,学习的!
尤其是要做些逐个像素处理的工作, 
例如
破解登入图像的验证码,
十字绣转换软件,
excel的电影播放器等!
bmp 无疑是最好的选择!
正 文:

 

Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As PicBmp, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
  
Private Const CF_BITMAP = 2
  
Private Type PicBmp
    Size As Long
    type As Long
    hBmp As Long
    hpal As Long
    Reserved As Long
End Type
 
Private Type GUID
    Data1 As Long
    Data2 As Integer
    Data3 As Integer
    Data4(0 To 7) As Byte
End Type
 
Private Sub My_Screen_1()
    Call keybd_event(vbKeySnapshot, 0, 0, 0)
    DoEvents
End Sub
 
Private Sub My_Screen_2()
    Call keybd_event(vbKeySnapshot, 1, 1, 1)
    DoEvents
End Sub
 
Sub Scheduled_Snapshot()
    Dim Pic As PicBmp, IPic As IPicture, IID_IDispatch As GUID
   
    Call My_Screen_2
    oTime = Now()
   
    OpenClipboard 0

    With Pic
        .Size = Len(Pic)
        .type = 1
        .hBmp = GetClipboardData(CF_BITMAP)
    End With
   
    OleCreatePictureIndirect Pic, IID_IDispatch, 1, IPic
    stdole.SavePicture IPic, "d:\snapshot_" & Format(Now(), "yyyy-mm-dd hhnnss") & ".bmp"
    CloseClipboard
   
  
End Sub




Access软件网QQ交流群 (群号:54525238)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助