AutoIT中的函数“_IEFormElementSetValue”和“_IEAction”

问题描述 投票:0回答:1

为什么我不能一个接一个地运行这些功能?函数_IEFormElementSetValue()_IEAction()不能一起工作?

码:

#include <IE.au3>

Local $oIE = _IECreate("http://www.google.com")
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE)

; Feature 1: inserts the text into the search box google
Local $oDigita = _IEGetObjByName($oIE, "q")
_IEFormElementSetValue($oDigita, "Nome pesquisado")

; Feature 2: option button "I'm feeling lucky"
Local $oClica = _IEGetObjByName($oIE, "btnI")
_IEAction($oClica, "click")
autoit
1个回答
0
投票

您的代码适用于AutoIt版本3.3.14.2,IE版本11.0.9600.19266。请尝试下面的调整后的变体,因为_IECreate()的行为并不总是稳定的。

码:

#include-once
#include <IE.au3>

Global $oIE = _IECreate( 'http://www.google.com', 0, 1, 1, 1 )
WinSetState( '[ACTIVE]', '', @SW_MAXIMIZE )
Sleep( 1000 )

; Feature 1: inserts the text into the search box google
Global $oDigita = _IEGetObjByName( $oIE, 'q' )
_IEAction( $oDigita, 'click' )

ClipPut( 'Nome pesquisado' ) ; save string in clipboard
Send( '^v' )                 ; paste string with CTRL+V

; Feature 2: option button "I'm feeling lucky"
Global $oClica = _IEGetObjByName( $oIE, 'btnI' )
_IEAction( $oClica, 'click' )

注意:

功能_IEAction()非常不稳定,就像Send()一样。我建议使用一个IE对象,用_IECreateEmbedded()嵌入到GUI中。

© www.soinside.com 2019 - 2024. All rights reserved.