2014-07-14 44 views
0

僅供參考,我是Autoit的新手......我可以使用autoit成功從IE中讀取一些div內容,但我只能在頁面加載時閱讀它。我想在頁面關閉時閱讀它以獲取最新信息。我有一些JavaScript在頁面上更改div內容,然後我想轉儲該信息以在其他地方使用。Autoit在瀏覽器上閱讀html關閉

$oIE = _IECreate("\\developnow\Local Files\HTML5\Test Form 1.html#docid=144_721=Test Form 1") 
$divs = _IETagNameGetCollection($oIE, "div") 

For $div In $divs 
    If $div.className == "bigString" Then 
     $divContent = $div.innerText 
    EndIf 

我如何獲得的bigStringinnerText的頁面關閉,而不是在頁面加載?或者只有在bigString更改時才能獲取信息?

謝謝!

回答

0

簡單AdlibRegister解決方案:

#include <IE.au3> 

_IEErrorHandlerRegister() 
Global $oIE = _IECreate("\\developnow\Local Files\HTML5\Test Form 1.html#docid=144_721=Test Form 1") 
Global $LatestText = "" 
$OldText = "" 

AdlibRegister("_IEGetElementText") 

While True 
    If $OldText <> $LatestText Then 
     $OldText = $LatestText 
     ConsoleWrite($LatestText & @LF) 
    EndIf 
WEnd 



Func _IEGetElementText() 

     $divs = _IETagNameGetCollection($oIE, "div") 

     For $div In $divs 
      If ($div.className == "bigString") And ($div.innerText <> "") Then 
       $LatestText = $div.innerText 
      EndIf 
     Next 

EndFunc