|
自己写一个
用API函数,下边是个例子
下面的例子将演示怎样把桌面图片用BitBlt函数复制,你可以利用它制作抓图
把以下代码加入模块:
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Long) As Integer
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Const SRCCOPY = &HCC0020
Const SRCAND = &H8800C6
Const SRCINVERT = &H660046
脚本
Dim DeskhWnd As Long
dim DeskDC As Long
'得到桌面的hWnd
DeskhWnd& = GetDesktopWindow()
DeskDC& = GetDC(DeskhWnd&)
‘任意窗口的hdc也可以用上边的方法得到,在这里先用robot的dialog函数生成一个窗口
‘然后用getdc得到窗口dc,传给bitblt函数。这里getdc的参数hwnd,你可以用findwindow函数得到!
BitBlt 窗口.hdc, 0&, 0&, _Screen.Width, Screen.Height, DeskDC&, 0&, 0&, SRCCOPY
上边代码实现了抓图函数并显示在窗口中,图片你可以可以抓取后保存! |
|