Jump to content

Screen capture with (X, Y, X, Y) Choords?


spyro
 Share

Recommended Posts

Have a look http://www.autoitscript.com/fileman/users/Lazycat/dlls.html


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Has anyone written a function that can do a screencapture when pass certain choords?

There are DLL calls that might be much faster, but for us low-tech, I-don't-know-DLLs-very-well mortals, you can combine this function call with evilertoaster's BMP.au3 (I think):

#include <bmp.au3>

If _PixelGetRect(100, 100, 100, 100, @ScriptDir & "\Test1.bmp") Then
    MsgBox(64, "Results", "_PixelGetRect() test completed successfully.")
Else
    MsgBox(16, "Results", "_PixelGetRect() test failed!" & @CRLF & _
            "Return = 0, @error = " & @error & ", and @extended = " & @extended)
EndIf


; Function _PixelGetRect() get the pixels of a rectangular screen area.
;   Screen area is defined by top/left at $X/$Y, and width/height as $W, $H
;   Captured screen shot is written to $sFile in BMP format.
;   Requires BMP.au3 from www.autoitscript.com/forum/index.php?showtopic=27362
Func _PixelGetRect($X, $Y, $W, $H, $sFile)
    Local $PosX, $PosY, $RGB, $RetCode
    Local $hBMP = _BmpCreate ($W, $H)
    If Not IsArray($hBMP) Then Return SetError(1, 0, 0)
    ; For each horizontal line...
    For $PosY = $Y To $Y + $H - 1
        ; Read the line's pixels into the BMP image
        For $PosX = $X To $X + $W - 1
            $RetCode = _PixelWrite ($hBMP, $PosX - $X, $PosY - $Y, Hex(PixelGetColor($PosX, $PosY), 6))
            If $RetCode <> 1 Then Return SetError(2, $RetCode, 0)
        Next
    Next
    $RetCode = _BMPWrite ($hBMP, $sFile, 1)
    If $RetCode = 1 Then
        Return 1
    Else
        Return SetError(3, $RetCode, 0)
    EndIf
EndFunc   ;==>_PixelGetRect

Tested OK for me, but I don't like BMP.au3's funky return codes, they cause extra handling for the coder that uses the functions. May have to post some recommended tweaks for that.

:)

Edit: Well, once again I did it the hard way. BigDod posted a link to exactly the DLL calls that I wouldn't know how to make... :P

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...