Что нового

[Окна, Диалоги] Захват, обработка, вывод изображения экрана

an1s1

Новичок
Сообщения
2
Репутация
0
Простите если что не так, я здесь впервые. :-[

Хочу в режиме реального времени захватывать область экрана, увеличивать ее в 2-3 раза и выводить в определенном месте :wacko:. Есть у когото идеи по этому поводу :scratch:? Буду рад любым ответам. Заранее спасибо.
 

Zaramot

I ♥ AutoIt
Сообщения
1,160
Репутация
660
Так ?:
Код:
#Include <WinAPIEx.au3>
#Include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $hParent, $hForm, $Pos, $Go = 1, $XPrev = MouseGetPos(0), $YPrev = MouseGetPos(1)

HotKeySet('{ESC}', '_Quit')

$hParent = GUICreate('', -1, -1, -1, -1, -1, $WS_EX_TOOLWINDOW)
$hForm = GUICreate('', 200, 200, $XPrev + 25, $YPrev + 25, BitOR($WS_DISABLED, $WS_POPUPWINDOW), BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST), $hParent)
GUISetState(@SW_SHOWNOACTIVATE, $hForm)

While 1
    GUIGetMsg()
    $Pos = MouseGetPos()
    If $pos[0] >= @DesktopWidth - 250 And $pos[1] >= @DesktopHeight - 250 And (($Go) Or ($Pos[0] <> $XPrev) Or ($Pos[1] <> $YPrev)) Then
        WinMove($hForm, '', $Pos[0] - 225, $Pos[1] - 225)
        $XPrev = $Pos[0]
        $YPrev = $Pos[1]
        $Go = 0
    EndIf
    If $pos[0] >= @DesktopWidth - 250 And (($Go) Or ($Pos[0] <> $XPrev) Or ($Pos[1] <> $YPrev)) Then
        WinMove($hForm, '', $Pos[0] - 225, $Pos[1] + 25)
        $XPrev = $Pos[0]
        $YPrev = $Pos[1]
        $Go = 0
    EndIf
    If $pos[1] >= @DesktopHeight - 250 And (($Go) Or ($Pos[0] <> $XPrev) Or ($Pos[1] <> $YPrev)) Then
        WinMove($hForm, '', $Pos[0] + 25, $Pos[1] - 225)
        $XPrev = $Pos[0]
        $YPrev = $Pos[1]
        $Go = 0
    EndIf
    If ($Go) Or ($Pos[0] <> $XPrev) Or ($Pos[1] <> $YPrev) Then
        WinMove($hForm, '', $Pos[0] + 25, $Pos[1] + 25)
        $XPrev = $Pos[0]
        $YPrev = $Pos[1]
        $Go = 0
    EndIf
    _Capture($Pos[0] - 25, $Pos[1] - 25, 50, 50)
    Sleep(1)
WEnd

Func _Capture($iX, $iY, $iWidth, $iHeight)

    Local $tRect, $hDC, $hMemDC, $hBitmap, $hScreenshort

    $hScreenshort = _ScreenCapture($iX, $iY, $iWidth, $iHeight)
    $hBitmap = _WinAPI_ResizeBitmap($hScreenshort, 200, 200)
    _WinAPI_DeleteObject($hScreenshort)
    $hDC = _WinAPI_GetDC($hForm)
    $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
    _WinAPI_SelectObject($hMemDC, $hBitmap)
    _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($NULL_BRUSH))
    _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_PEN))
    _WinAPI_SetDCPenColor($hMemDC, 0xA00000)
    $tRect = _WinAPI_CreateRect(0, 0, 200, 200)
    _WinAPI_Rectangle($hMemDC, $tRect)
    _WinAPI_ReleaseDC($hForm, $hDC)
    _WinAPI_DeleteDC($hMemDC)
    _SetBitmap($hForm, $hBitmap, 255)
    _WinAPI_DeleteObject($hBitmap)
EndFunc   ;==>_Capture

Func _Quit()
    Exit
EndFunc   ;==>_Quit

Func _ScreenCapture($iX, $iY, $iWidth, $iHeight)

    Local $hWnd, $hDC, $hMemDC, $hBitmap

    $hWnd = _WinAPI_GetDesktopWindow()
    $hDC = _WinAPI_GetDC($hWnd)
    $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
    $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
    _WinAPI_SelectObject($hMemDC, $hBitmap)
    _WinAPI_BitBlt($hMemDC, 0, 0, $iWidth, $iHeight, $hDC, $iX, $iY, $SRCCOPY)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    _WinAPI_DeleteDC($hMemDC)
    Return $hBitmap
EndFunc   ;==>_ScreenCapture

Func _SetBitmap($hWnd, $hBitmap, $iOpacity)

    Local $hDC, $hMemDC, $hSv, $pBlend, $tBlend, $pSize, $tSize, $pSource, $tSource

    $hDC = _WinAPI_GetDC($hWnd)
    $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
    $hSv = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = _WinAPI_GetBitmapDimension($hBitmap)
    $pSize = DllStructGetPtr($tSize)
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, 'Alpha', $iOpacity)
    DllStructSetData($tBlend, 'Format', 0)
    _WinAPI_UpdateLayeredWindow($hWnd, $hDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    _WinAPI_SelectObject($hMemDC, $hSv)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>_SetBitmap
 
Автор
A

an1s1

Новичок
Сообщения
2
Репутация
0
Было бы неплохо, если бы Вы просто сказали мне названия функций и их параметры. Но спасибо.
 
Верх