截取整个区域的屏幕截图

时间:2017-01-05 13:40:09

标签: vb.net winapi bitmap screenshot

我正在使用Visual Basic获取截图,在本例中是记事本中的编辑控件:

Dim windowHandle = FindWindow("Notepad", Nothing)
windowHandle = FindWindowEx(windowHandle, Nothing, "Edit", Nothing)

Dim clientRect As RECT
GetClientRect(windowHandle, clientRect)

Dim windowDeviceContext = GetDC(windowHandle)
Dim memoryDeviceContext = CreateCompatibleDC(windowDeviceContext)
Dim bitmapHandle = CreateCompatibleBitmap(windowDeviceContext, clientRect.Right, clientRect.Bottom)
Dim selectObjectResult = SelectObject(memoryDeviceContext, bitmapHandle)
Dim bitBltResult = BitBlt(memoryDeviceContext, 0, 0, clientRect.Right, clientRect.Bottom, windowDeviceContext, 0, 0, TernaryRasterOperations.SRCCOPY)
Dim bmpScreen As Bitmap = Bitmap.FromHbitmap(bitmapHandle)

bmpScreen.Save(Filepath)

这样可以正常工作,但是当您继续输入时,最终您将在编辑控件中获得一个滚动条。上面的代码仅捕获控件的可见区域。有没有办法让FULL控制区好像没有滚动条?我显然仅限于Visual Basic和Win32 API。

0 个答案:

没有答案