我开始用了如下的语句,能够实现对任意标题的窗口进行选择性截屏,但是printwindow这个函数好像不能对directX的游戏截取..只能获得一块白色 (我要对冒险岛这个游戏进行截图)
在模块中
Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
在窗体中
Option Explicit
Private Declare Function PrintWindow Lib "User32" (ByVal SrcHwnd As Long, ByVal DesHDC As Long, ByVal uFlag As Long) As Long
Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Type RECT'窗口的四个点的位置数据
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetWindowRect Lib "User32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Sub Command1_Click()
Dim hw As Long
hw = FindWindow(vbNullString, "MapleStory")'获取句柄
If hw = 0 Then
XXXXXXXXXption = "Maplestory未运行" '显示运行状况
Exit Sub
End If
If hw <> 0 Then
XXXXXXXXXption = "Maplestory已运行" '显示运行状况
End If
Dim rc As RECT
If GetWindowRect(hw, rc) Then
Picture1.Width = (rc.Right - rc.Left): Picture1.Height = (XXXXXttom - XXXXXp)'按照窗口大小调整picture1的长度和宽度
End If
Call PrintWindow(hw, Picture1.hDC, 0)
XXXXXXXXXXXfresh
End Sub
Private Sub Form_Load()
XXXXXXXXXXXtoRedraw = True
XXXXXXXXXXXrderStyle = 0
Picture1.Appearance = 0
End Sub
于是我又用了下面的代码 (这个不是我自己写的)
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const theScreen = 0
Const theForm = 1
Private Sub Command1_Click()
Call keybd_event(vbKeySnapshot, theScreen, 0, 0)
DoEvents
Picture1.Picture = XXXXXXXXXXXXtData(vbCFBitmap)
End Sub
这个可以对游戏和视屏任意截图 但是却是全屏抓取 没有看到有使用句柄的迹象 应该不能选择抓取窗口
请教如何实现我想要的功能了 谢谢
200字以内,仅用于支线交流,主线讨论请采用回复功能。