Jump to content
Sign in to follow this  
Gui

Getting location of Webpage Image for ScreenCapture?

Recommended Posts

Gui

Well, I have a screencapture of an image, and I want to get it exact incase of a screw up. Before I had already set coords, using the AutoIt Window Tool, but I thought it would be more accurate to get the objects coords from functions. I've tried :

$ex = _IEImgGetCollection($oIE,23)
        $left = _IEPropertyGet($ex,'left') ; Always returns --> IE.au3 V2.4-0 Error from function _IEPropertyGet, $_IEStatus_InvalidObjectType
        $top = _IEPropertyGet($ex,'top') ; Same here. --> IE.au3 V2.4-0 Error from function _IEPropertyGet,$_IEStatus_InvalidObjectType         
        $right = $left + $ex.width   ; I've tried _IEPropertyGet($ex,'width') and height, but don't work either.
        $bottom = $top - $ex.height

Is this the right way to do it? Or is their a better way? I havn't found anything else to do in the Help File. Thanks.

Share this post


Link to post
Share on other sites
PsaltyDS

Looks like you are not getting the correct object in $ex. Do you have _IEErrorHandlerRegister() in the script, and does _IEImgGetCollection() show any errors? You might check @error or the object:

$ex = _IEImgGetCollection($oIE, 23)
If IsObj($ex) Then
    ConsoleWrite("Debug: $ex = object (" & ObjName($ex) & ")" & @LF)
Else
    ConsoleWrite("Debug: $ex is not an object" & @LF)
EndIf

That should be getting something like:

Debug: $ex = object (DispHTMLImg)

;)

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
Gui

Hmm, I see . It was wierd with it's src, it kept changing, probably because it was like an advertisement. I just used :

$filename = @DesktopDir & '\test.jpg'
   $hwnd = WinGetHandle('Title.')
$oSA = _IEImgGetCollection ($oIE)
$right = $oSA.getBoundingClientRect().right
$left = $oSA.getBoundingClientRect().left
$top = $oSA.getBoundingClientRect().top + 50
$bottom = $oSA.getBoundingClientRect().bottom + 50
$ii = _ScreenCapture_CaptureWnd ( $filename, $hwnd, $left, $top, $right, $bottom, False)
    
_ScreenCapture_SaveImage( $filename, $ii)
GUICtrlCreatePic( $filename, 1 , 1, 240, 60)

Share this post


Link to post
Share on other sites
PsaltyDS

Hmm, I see . It was wierd with it's src, it kept changing, probably because it was like an advertisement. I just used :

$filename = @DesktopDir & '\test.jpg'
   $hwnd = WinGetHandle('Title.')
$oSA = _IEImgGetCollection ($oIE)
$right = $oSA.getBoundingClientRect().right
$left = $oSA.getBoundingClientRect().left
$top = $oSA.getBoundingClientRect().top + 50
$bottom = $oSA.getBoundingClientRect().bottom + 50
$ii = _ScreenCapture_CaptureWnd ( $filename, $hwnd, $left, $top, $right, $bottom, False)
    
_ScreenCapture_SaveImage( $filename, $ii)
GUICtrlCreatePic( $filename, 1 , 1, 240, 60)
I don't think that will work because "$oSA = _IEImgGetCollection($oIE)", without the index, returns a collection object, not a single element. You need $oSA to be a reference to the IMG element, either by index, or walk through the collection looking for another attribute to get the right one.

;)


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
Gui

I don't think that will work because "$oSA = _IEImgGetCollection($oIE)", without the index, returns a collection object, not a single element. You need $oSA to be a reference to the IMG element, either by index, or walk through the collection looking for another attribute to get the right one.

;)

:idea: Sorry forgot the 6, must of deleted some way when inserting it here. :S not that bad at coding! I would share some of the bots i've made, but they are probably against some rules one way or another. I have a proxy checker that works really well with TCP, I guess I could share that :evil:. Thanks Psalty your always that kind penguin there to help me :evil:.

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  

×