COMO PEGAR PEDACO DA TELA
BOM DIA
COMO EU FACO PARA TIRAR UMA PRINT E UMA DETERMINADA PARTE DA TELA DETERMINANDO O COMPRIMENTO E LARGURA ...
ALGUEM SE DISPOE
COMO EU FACO PARA TIRAR UMA PRINT E UMA DETERMINADA PARTE DA TELA DETERMINANDO O COMPRIMENTO E LARGURA ...
ALGUEM SE DISPOE
Eu faço assim
Clico a tecla print na tela desejada
Abro o paint ,colo a imagem e depois seleciono a parte que me interessa e salvo.
Clico a tecla print na tela desejada
Abro o paint ,colo a imagem e depois seleciono a parte que me interessa e salvo.
Vlw ADHEL pela Iniciative ... Mais naum é bem isso Naum Ja Encontrei o Codigo Abaixo No MOdulo
Option Explicit
Dim bolRes As Boolean
Private Declare Function GetPixel Lib [Ô]gdi32[Ô] ( _
ByVal hdc As Long, _
ByVal X As Long, _
ByVal Y As Long) As Long
[ô]-- Error handling definitions
Private Const E_ERR_BASE = 18020 + vbObjectError
Public Enum EErrScreenshot
eESS_InvalidWindowHandle = E_ERR_BASE + 1
eESS_InvalidCoordinates
eESS_CantGetWindowRect
eESS_NoActiveWindow
eESS_ComponentFailure
End Enum
Private Const S_ERR_InvalidWindowHandle = [Ô]Invalid window handle[Ô]
Private Const S_ERR_InvalidCoordinates = [Ô]Invalid screen coordinates[Ô]
Private Const S_ERR_CantGetWindowRect = [Ô]Could not get window rect[Ô]
Private Const S_ERR_NoActiveWindow = [Ô]No active window for the calling thread[Ô]
Private Const S_ERR_ComponentFailure = [Ô]IAPP_Screenshot component failure[Ô]
Private Const CCHDEVICENAME = 32
Private Const CCHFORMNAME = 32
Private Const SRCCOPY = &HCC0020
Private Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperlWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Long
dmPelslWidth As Long
dmPelslHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetActiveWindow Lib [Ô]user32[Ô] () As Long
Private Declare Function GetDesktopWindow Lib [Ô]user32[Ô] () As Long
Private Declare Function GetWindowRect Lib [Ô]user32[Ô] (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function IsWindow Lib [Ô]user32[Ô] (ByVal hwnd As Long) As Long
Private Declare Function GetSystemMetrics Lib [Ô]user32[Ô] (ByVal nIndex As Long) As Long
Private Declare Function SelectObject Lib [Ô]gdi32[Ô] (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function ReleaseDC Lib [Ô]user32[Ô] (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function OpenClipboard Lib [Ô]user32[Ô] (ByVal hwnd As Long) As Long
Private Declare Function EmptyClipboard Lib [Ô]user32[Ô] () As Long
Private Declare Function SetClipboardData Lib [Ô]user32[Ô] (ByVal wFormat As Long, ByVal hMem As Long) As Long
Private Declare Function CloseClipboard Lib [Ô]user32[Ô] () As Long
Private Declare Function DeleteDC Lib [Ô]gdi32[Ô] (ByVal hdc As Long) As Long
Private Declare Function BitBlt Lib [Ô]gdi32[Ô] (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nlWidth As Long, ByVal nlHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function CreateDC Lib [Ô]gdi32[Ô] Alias [Ô]CreateDCA[Ô] (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As DEVMODE) As Long
Private Declare Function CreateCompatibleBitmap Lib [Ô]gdi32[Ô] (ByVal hdc As Long, ByVal nlWidth As Long, ByVal nlHeight As Long) As Long
Private Declare Function CreateCompatibleDC Lib [Ô]gdi32[Ô] (ByVal hdc As Long) As Long
Private Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Private Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Private Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
bmiColors As RGBQUAD
End Type
Private Declare Function GetDIBits Lib [Ô]gdi32[Ô] (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFOHEADER, ByVal wUsage As Long) As Long
Private lonPix_1() As Long
Private lonPix_2() As Long
Public Sub CaptureRectangle(Left As Long, Top As Long, lWidth As Long, lHeight As Long)
On Error GoTo ehComponentFailure
Dim DM As DEVMODE
Dim hBmpImage As Long
Dim lhDcSource As Long
Dim lhDcTarget As Long
If (Left < 0) Or (Top < 0) Or (lWidth > GetSystemMetrics(0)) Or (lHeight > GetSystemMetrics(1)) Then
On Error GoTo 0
Err.Raise eESS_InvalidCoordinates, App.EXEName & [Ô].IAPP_Screenshot[Ô], S_ERR_InvalidCoordinates
End If
lhDcSource = CreateDC([Ô]DISPLAY[Ô], [Ô][Ô], [Ô][Ô], DM)
lhDcTarget = CreateCompatibleDC(lhDcSource)
hBmpImage = CreateCompatibleBitmap(lhDcSource, lWidth, lHeight)
SelectObject lhDcTarget, hBmpImage
BitBlt lhDcTarget, 0, 0, lWidth, lHeight, lhDcSource, Left, Top, SRCCOPY
OpenClipboard 0&
EmptyClipboard
SetClipboardData 2, hBmpImage
CloseClipboard
DeleteDC lhDcTarget
ReleaseDC hBmpImage, lhDcSource
Exit Sub
ehComponentFailure:
[ô]-- Fail: Raise The Error
Err.Raise eESS_ComponentFailure, App.EXEName & [Ô].IAPP_Screenshot[Ô], S_ERR_ComponentFailure
End Sub
[ô]---------------------[ô]
Chamando
Call CaptureRectangle(400, 550, 20, 20)
a imagem Fica no Clipboard
Option Explicit
Dim bolRes As Boolean
Private Declare Function GetPixel Lib [Ô]gdi32[Ô] ( _
ByVal hdc As Long, _
ByVal X As Long, _
ByVal Y As Long) As Long
[ô]-- Error handling definitions
Private Const E_ERR_BASE = 18020 + vbObjectError
Public Enum EErrScreenshot
eESS_InvalidWindowHandle = E_ERR_BASE + 1
eESS_InvalidCoordinates
eESS_CantGetWindowRect
eESS_NoActiveWindow
eESS_ComponentFailure
End Enum
Private Const S_ERR_InvalidWindowHandle = [Ô]Invalid window handle[Ô]
Private Const S_ERR_InvalidCoordinates = [Ô]Invalid screen coordinates[Ô]
Private Const S_ERR_CantGetWindowRect = [Ô]Could not get window rect[Ô]
Private Const S_ERR_NoActiveWindow = [Ô]No active window for the calling thread[Ô]
Private Const S_ERR_ComponentFailure = [Ô]IAPP_Screenshot component failure[Ô]
Private Const CCHDEVICENAME = 32
Private Const CCHFORMNAME = 32
Private Const SRCCOPY = &HCC0020
Private Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperlWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Long
dmPelslWidth As Long
dmPelslHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetActiveWindow Lib [Ô]user32[Ô] () As Long
Private Declare Function GetDesktopWindow Lib [Ô]user32[Ô] () As Long
Private Declare Function GetWindowRect Lib [Ô]user32[Ô] (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function IsWindow Lib [Ô]user32[Ô] (ByVal hwnd As Long) As Long
Private Declare Function GetSystemMetrics Lib [Ô]user32[Ô] (ByVal nIndex As Long) As Long
Private Declare Function SelectObject Lib [Ô]gdi32[Ô] (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function ReleaseDC Lib [Ô]user32[Ô] (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function OpenClipboard Lib [Ô]user32[Ô] (ByVal hwnd As Long) As Long
Private Declare Function EmptyClipboard Lib [Ô]user32[Ô] () As Long
Private Declare Function SetClipboardData Lib [Ô]user32[Ô] (ByVal wFormat As Long, ByVal hMem As Long) As Long
Private Declare Function CloseClipboard Lib [Ô]user32[Ô] () As Long
Private Declare Function DeleteDC Lib [Ô]gdi32[Ô] (ByVal hdc As Long) As Long
Private Declare Function BitBlt Lib [Ô]gdi32[Ô] (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nlWidth As Long, ByVal nlHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function CreateDC Lib [Ô]gdi32[Ô] Alias [Ô]CreateDCA[Ô] (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As DEVMODE) As Long
Private Declare Function CreateCompatibleBitmap Lib [Ô]gdi32[Ô] (ByVal hdc As Long, ByVal nlWidth As Long, ByVal nlHeight As Long) As Long
Private Declare Function CreateCompatibleDC Lib [Ô]gdi32[Ô] (ByVal hdc As Long) As Long
Private Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Private Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Private Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
bmiColors As RGBQUAD
End Type
Private Declare Function GetDIBits Lib [Ô]gdi32[Ô] (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFOHEADER, ByVal wUsage As Long) As Long
Private lonPix_1() As Long
Private lonPix_2() As Long
Public Sub CaptureRectangle(Left As Long, Top As Long, lWidth As Long, lHeight As Long)
On Error GoTo ehComponentFailure
Dim DM As DEVMODE
Dim hBmpImage As Long
Dim lhDcSource As Long
Dim lhDcTarget As Long
If (Left < 0) Or (Top < 0) Or (lWidth > GetSystemMetrics(0)) Or (lHeight > GetSystemMetrics(1)) Then
On Error GoTo 0
Err.Raise eESS_InvalidCoordinates, App.EXEName & [Ô].IAPP_Screenshot[Ô], S_ERR_InvalidCoordinates
End If
lhDcSource = CreateDC([Ô]DISPLAY[Ô], [Ô][Ô], [Ô][Ô], DM)
lhDcTarget = CreateCompatibleDC(lhDcSource)
hBmpImage = CreateCompatibleBitmap(lhDcSource, lWidth, lHeight)
SelectObject lhDcTarget, hBmpImage
BitBlt lhDcTarget, 0, 0, lWidth, lHeight, lhDcSource, Left, Top, SRCCOPY
OpenClipboard 0&
EmptyClipboard
SetClipboardData 2, hBmpImage
CloseClipboard
DeleteDC lhDcTarget
ReleaseDC hBmpImage, lhDcSource
Exit Sub
ehComponentFailure:
[ô]-- Fail: Raise The Error
Err.Raise eESS_ComponentFailure, App.EXEName & [Ô].IAPP_Screenshot[Ô], S_ERR_ComponentFailure
End Sub
[ô]---------------------[ô]
Chamando
Call CaptureRectangle(400, 550, 20, 20)
a imagem Fica no Clipboard
Tópico encerrado , respostas não são mais permitidas