想請問一下,我擷取一個網頁內的表格,想要讓表格的內容依照順序顯示在GUI介面上,按照GUICtrlCreateListViewItem的方式來寫入,在程式的部分還要有哪些修正?
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <IE.au3>
#include <Array.au3>
Dim $oInput[10][10]
#Region ### START Koda GUI section ### Form=D:\AutoIt\腳本\tabbed pages.kxf
$dlgTabbed = GUICreate("Tabbed Notebook Dialog", 413, 298, 261, 182)
GUISetIcon("D:\005.ico")
$PageControl1 = GUICtrlCreateTab(8, 8, 396, 256)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
;讀取網頁表格數據
$oIE2 = _IECreate ("http://fund.cnyes.com/fund_nav.asp?fundcode=A10031",0,0,1,0);不顯示IE
$oInputs = _IETableGetCollection ($oIE2) ;返回指網頁內所有表格的目標變量
$iNumTables = @extended ;文檔內所以表格的數量
;MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page")
$i = 14;指定顯示第幾個表格欄位 $i+1個
;For $oInput In $oInputs
$table = _IETableGetCollection ($oIE2,$i)
$oInput = _IETableWriteToArray ($table) ;讀取指定表格內的數據,寫入到數組
_ArrayDisplay($oInput, "第"&$i+1&"個表單內容",0,1) ;顯示數組
;
$TabSheet1 = GUICtrlCreateTabItem("Funds")
$ListView1 = GUICtrlCreateListView("Item|Date|Name|Address|Value", 8,25,396,250)
$ListView1_0 = GUICtrlCreateListViewItem("1|C", $ListView1)
$ListView1_1 = GUICtrlCreateListViewItem("2|D", $ListView1)
$ListView1_2 = GUICtrlCreateListViewItem("3|F", $ListView1)
$ListView1_3 = GUICtrlCreateListViewItem("4|c", $ListView1)
$ListView1_4 = GUICtrlCreateListViewItem("5|r", $ListView1)
$ListView1_5 = GUICtrlCreateListViewItem("6|j", $ListView1)
GUICtrlSetState(-1,$GUI_SHOW); will be display first
$TabSheet3 = GUICtrlCreateTabItem("Image")
;嵌入圖片
$oIE_code = _IECreateEmbedded ()
$GUIActiveX = GUICtrlCreateObj($oIE_code, 8,25,396,250);定義內嵌IE 窗口大小
_IENavigate ($oIE_code, "about:blank",1)
;加載一個空白網頁,可以自定一個網頁,讓驗證碼圖片顯示左左對齊,頂部對齊,如果你會HTML應該明白什麼意思
$oBody = _IETagNameGetCollection($oIE_code, "body", 0)
_IEDocInsertHTML($oBody, 'IE加載中...', "afterbegin");在嵌入IE底部追加文字
;嵌入圖片 結束
$TabSheet2 = GUICtrlCreateTabItem("IE TAB")
;嵌入IE在分頁上
;$oIE_code = GUICtrlCreateTabItem("IE TAB")
$oIE = _IECreateEmbedded ();Create a Webbrowser object suitable for embedding in an AutoIt GUI with GuiCtrlCreateObj().
$GUIActiveX = GUICtrlCreateObj($oIE, 8,25,396,250);定義內嵌IE 窗口大小
_IENavigate ($oIE, "http://allsharing.net/drupal_5_1/lineworld/fund/html/0676.htm");將IE指向URL
;嵌入IE在分頁上 結束
GUICtrlCreateTabItem(""); end tabitem definition
$Button1 = GUICtrlCreateButton("&OK", 166, 272, 75, 25, 0)
$Button2 = GUICtrlCreateButton("&Cancel", 246, 272, 75, 25, 0)
$Button3 = GUICtrlCreateButton("&Help", 328, 272, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Get_image()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func Get_image()
;$oImg = _IEImgGetCollection ($oIE,4);返回IE文檔內IMG 實際上就是第4+1張圖
$oImg = _IEImgGetCollection ($oIE,0);返回IE文檔內IMG
$oPic = $oIE.Document.body.createControlRange()
$oPic.Add($oImg)
$oPic.execCommand("Copy");複製到剪貼板
$ImageFilePath = ClipGet();獲取路徑,在臨時文件裡面
_IEAction ( $oIE_code,"refresh" );刷新嵌入IE頁面
$oBody = _IETagNameGetCollection($oIE_code, "body", 0)
_IEDocInsertHTML($oBody, '<img src='& FileGetShortName($ImageFilePath) &'>', "afterbegin");在嵌入IE底部追加圖片顯示
EndFunc
[ 本帖最后由 fancky 于 2009-2-26 09:37 编辑 ] |