如何让嵌入的IE浏览器自动滚动到最后?
本帖最后由 mbdnmt 于 2013-12-5 23:41 编辑采用GUICtrlCreateObj方式创建嵌入的IE,如何让显示的网页自动滚动到最后?
要载入的网页是随时间不断增加新的行的(类似于聊天记录),如何操作可以让嵌入的IE不断刷新,并且自动滚动到最后(相当于滚动到最后一条消息)
这是例子里嵌入IE的例子#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Example()
; 简单示例: 嵌入Internet Explorer对象到 AutoIt GUI
;
; 参见: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp
Func Example()
Local $oIE, $GUI_Button_Back, $GUI_Button_Forward
Local $GUI_Button_Home, $GUI_Button_Stop, $msg
$oIE = ObjCreate("Shell.Explorer.2")
; 为输出创建一个简单的 GUI
GUICreate("嵌入 Web 控件测试", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
GUICtrlCreateObj($oIE, 10, 40, 600, 360)
$GUI_Button_Back = GUICtrlCreateButton("返回", 10, 420, 100, 30)
$GUI_Button_Forward = GUICtrlCreateButton("向前", 120, 420, 100, 30)
$GUI_Button_Home = GUICtrlCreateButton("主页", 230, 420, 100, 30)
$GUI_Button_Stop = GUICtrlCreateButton("停止", 330, 420, 100, 30)
GUISetState() ;显示 GUI
$oIE.navigate("http://www.autoitx.com")
; 等待用户关闭窗口
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $GUI_Button_Home
$oIE.navigate("http://www.autoitx.com")
Case $msg = $GUI_Button_Back
$oIE.GoBack
Case $msg = $GUI_Button_Forward
$oIE.GoForward
Case $msg = $GUI_Button_Stop
$oIE.Stop
EndSelect
WEnd
GUIDelete()
EndFunc ;==>Example
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Example()
; 简单示例: 嵌入Internet Explorer对象到 AutoIt GUI
;
; 参见: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp
Func Example()
Local $oIE, $GUI_Button_Back, $GUI_Button_Forward
Local $GUI_Button_Home, $GUI_Button_Stop, $msg
$oIE = ObjCreate("Shell.Explorer.2")
; 为输出创建一个简单的 GUI
GUICreate("嵌入 Web 控件测试", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
GUICtrlCreateObj($oIE, 10, 40, 600, 360)
$GUI_Button_Back = GUICtrlCreateButton("返回", 10, 420, 100, 30)
$GUI_Button_Forward = GUICtrlCreateButton("向前", 120, 420, 100, 30)
$GUI_Button_Home = GUICtrlCreateButton("主页", 230, 420, 100, 30)
$GUI_Button_Stop = GUICtrlCreateButton("停止", 330, 420, 100, 30)
GUISetState() ;显示 GUI
$oIE.navigate("http://www.autoitx.com")
Sleep(100)
While $oIE.readystate<>4
Sleep(100)
WEnd
$oIE.document.parentwindow.execscript("javascript:window.scrollTo(0,document.body.scrollHeight);")
; 等待用户关闭窗口
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $GUI_Button_Home
$oIE.navigate("http://www.autoitx.com")
Case $msg = $GUI_Button_Back
$oIE.GoBack
Case $msg = $GUI_Button_Forward
$oIE.GoForward
Case $msg = $GUI_Button_Stop
$oIE.Stop
EndSelect
WEnd
GUIDelete()
EndFunc ;==>Example滚动到最后试一下这个,估计要再加个判断才能实现你说的不断增加不断滚动 回复 2# kevinch
非常感谢,要的就是这句
$oIE.document.parentwindow.execscript("javascript:window.scrollTo(0,document.body.scrollHeight);")
如何知道$oIE.都有那些方法呢? mark学习一下,以后必须要用到的 不错!楼主完善完善 非常感谢,学习学习。留到后头用
页:
[1]