autoit3 ie.au3 函数之——_IEGetObjById、_IEGetObjByName

_IEGetObjByName AND _IEGetObjByIdReturns an object variable by name or id.

即: 返回一个指定id或者name的对象变量

#include <IE.au3>
_IEGetObjByName ( ByRef $o_object, $s_Id [, $i_index = 0] )


例子:

; *******************************************************
; Example 1 - Open a browser to the form example, get an object reference
;               to the element with the id "su".  In this case the
;               result is identical to using $oSubmit = _IEGetObjById ($oIE, "su")
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("www.baidu.com")
Sleep(1000)

$oSubmit = _IEGetObjById ($oIE, "su")

例子:

; *******************************************************
; Example 1 - Open a browser to the basic example, get an object reference
;               to the DIV element with the ID "line1". Display the innerText
;               of this element to the console.
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
$oDiv = _IEGetObjById ($oIE, "line1")
ConsoleWrite(_IEPropertyGet($oDiv, "innertext") & @CRLF)


PS: 这个方法应该比较实用, 尤其是用到页面元素的时候。

你可能感兴趣的:(autoit3 ie.au3 函数之——_IEGetObjById、_IEGetObjByName)