Jump to content

Dumb question: IE Coords


Recommended Posts

Hi,

I'm trying to capture an image at a certain set of coords, in IE, and got a problem:

Here's the sample code:

#include <IE.au3> 
#include <ScreenCapture.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;AutoItSetOption ("PixelCoordMode", 2)
;AutoItSetOption ("CaretCoordMode", 2)


; Not embedded
$oIE = _IECreate("http://www.cnn.com", 0, 1, 1)
$hwnd = WinGetHandle("CNN")


$oImgs = _IEImgGetCollection ( $oIE)
$iNumImg = @extended



For $oImg In $oImgs
    if stringinstr($oImg.src, "header_cnn_com_logo.gif") then
        consolewrite("Got it")
        $oImg.scrollIntoView
        $right = $oImg.getBoundingClientRect().right
        $left = $oImg.getBoundingClientRect().left
        $top = $oImg.getBoundingClientRect().top
        $bottom = $oImg.getBoundingClientRect().bottom
        $width = $oImg.width 
        $height = $oImg.height 
        $filename = @MyDocumentsDir & "\test.jpg"
    ;$left = _IEPropertyGet($oImg, "browserx")
    ;$right = _IEPropertyGet($oImg, "browserx") + $width
    ;$top = _IEPropertyGet($oImg, "browsery")
    ;$bottom = _IEPropertyGet($oImg, "browsery") + $height
        
        
        
        consolewrite(@crlf & "Right: " & $right)
        consolewrite(@crlf & "Left: " & $left)
        consolewrite(@crlf & "Top: " & $top)
        consolewrite(@crlf & "Bottom: " & $bottom)
        consolewrite(@crlf & "Width: " & $width)
        consolewrite(@crlf & "Height: " & $height)
        consolewrite(@crlf & "Hwnd: " & $hWnd)
         _ScreenCapture_CaptureWnd ($filename, $hWnd, $left, $top, $right, $bottom, false)
        
    endif   
    
Next


GUIDelete()

Exit

This does save an image OK, but although the all the getBoundingClientRect() are based on just the actual webpage/HTML part of the IE window. But when the screen shot is taken, the coords are based on the complete IE window (including toolbar, titlebar, menus, etc). So as this image is at the top of the webpage, the image produced is actually at the top of the IE window, and I end up with a nice image of the title bar... (as attached)

I've tried messing around with the lines

;AutoItSetOption ("PixelCoordMode", 2)

;AutoItSetOption ("CaretCoordMode", 2)

But they seem to make no difference.

Can anyone help??

Regards,

Andy

post-8991-1243441679_thumb.jpg

Link to comment
Share on other sites

Hi,

I'm trying to capture an image at a certain set of coords, in IE, and got a problem:

Maybe

#include <IE.au3> 
   #include <ScreenCapture.au3>
   #include <GUIConstantsEx.au3>
   #include <WindowsConstants.au3>
  ;AutoItSetOption ("PixelCoordMode", 2)
  ;AutoItSetOption ("CaretCoordMode", 2)
   
   
  ; Not embedded
   $oIE = _IECreate("http://www.cnn.com", 0, 1, 1)
   $hwnd = WinGetHandle("CNN")
   
   
   $oImgs = _IEImgGetCollection ( $oIE)
   $iNumImg = @extended
   
   
   
   For $oImg In $oImgs
       if stringinstr($oImg.src, "header_cnn_com_logo.gif") then
           consolewrite("Got it")
           $oImg.scrollIntoView
           $right = $oImg.getBoundingClientRect().right
           $left = $oImg.getBoundingClientRect().left
           $top = $oImg.getBoundingClientRect().top
           $bottom = $oImg.getBoundingClientRect().bottom
           $width = $oImg.width 
           $height = $oImg.height 
           $filename = @MyDocumentsDir & "\test.jpg"
       ; Capture window
       $wp = wingetpos($hWnd)
       $cp = WinGetClientSize($hWnd)
       $border = ($wp[2] - $cp[0])/2
       $TitleHt = $wp[3] - $cp[1] - $border
       _ScreenCapture_CaptureWnd ($filename, $hWnd, $border,$TitleHt,$cp[0]+$border,$cp[1]+$TitleHt)
   
           
       endif    
       
   Next
   
   
   GUIDelete()
   
   Exit
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...