Sign in to follow this  
Followers 0
spyro

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

3 posts in this topic

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


www.SecurityDistro.com

Share this post


Link to post
Share on other sites



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



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0