类似于QQ截图时自动选取窗口,不知道BitBlt能否用于屏幕场景的图像复制。代码如下Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) 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, ByValhSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As LongPrivate Type POINTAPI
        x As Long
        y As Long
End TypePrivate Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End TypePrivate Sub Timer1_Timer()
Dim xy As POINTAPI
Dim R As RECT
GetCursorPos xy
jb = WindowFromPoint(xy.x, xy.y)
GetWindowRect jb, R
dc = GetWindowDC(jb)
dc1 = GetWindowDC(GetDesktopWindow)
BitBlt dc, 0, 0, R.Right - R.Left, R.Bottom - R.Top, dc1, 0, 0, vbSrcCopy  '复制绘图
ReleaseDC jb, dc       '释放
ReleaseDC GetDesktopWindow, dc1     '释放
End Sub