【问题标题】:Functions "_IEFormElementSetValue" and "_IEAction" in AutoITAutoIT 中的函数“_IEFormElementSetValue”和“_IEAction”
【发布时间】:2018-04-28 11:41:49
【问题描述】:

为什么我不能一个接一个地运行这些功能?函数_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】:

    您的代码适用于 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 中。

    【讨论】:

      猜你喜欢
      • 2011-03-19
      • 1970-01-01
      • 1970-01-01
      • 2012-07-23
      • 1970-01-01
      • 2014-08-26
      • 1970-01-01
      • 1970-01-01
      • 2013-11-25
      相关资源
      最近更新 更多