Search code examples
htmlinternet-explorerclickautoit

Can't get screenx property for DIV in AutoIT


I'm trying to get the screen coordinates for a DIV with id=1862 in order to click it in AutoIT. Here is how I'm able to view the text inside the DIV so that I know it can detect it:

local $element=_IEGetObjById($oIE, "ember1862")
_IEFormElementSetValue($element, "Eric")

It successfully resets the value in the search box.

But when I attempt to click it with:

_IEAction($element, "click")

or

$element.click

It does nothing.

When I try to get the coordinates it always tells me that they are all 0 which I know is not true (its sitting the middle of the page):

local $search = _IEGetObjById($oIE, "ember1862")
MsgBox(0,"",_IEPropertyGet($search,"screenx"))

Any tips?


Solution

  • I'm not sure why but this function worked---

    Function to get the coordinates:

    func _IEfindPosX($o_object)
        local $curleft = 0
        local $parent = $o_object
        if IsObj($parent) then
            while IsObj($parent)
                $curleft += $Parent.offsetLeft
                $parent = $Parent.offsetParent
            wend
        else
            local $objx = $o_object.x
            if IsObj($objx) then $curleft += $objx
        EndIf
        return $curleft
    EndFunc
    

    Looping through all html inputs to get the x coordinate:

    $oInputs = _IETagNameGetCollection ($oIE, "input")
    For $oInput In $oInputs
        MsgBox(0,"",$oInput.id)
        MsgBox(0,"",_IEfindPosX($oInput))
    Next