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

本文介绍如何使用IE.au3脚本来通过ID或名称获取页面中的对象引用,并提供了两个实例来演示具体应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

_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: 这个方法应该比较实用, 尤其是用到页面元素的时候。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值