【问题标题】:Autoscroll Internet Explorer自动滚动 Internet Explorer
【发布时间】:2013-05-29 13:08:24
【问题描述】:

我没有使用 WebBrowser 控件,我试图将 IE 的进程放在一个变量中以便对其进行控制。

我的目标是在需要时自动向下滚动页面。以下是有关如何使用我的代码启动 IE 的更多信息:

    Dim IE As SHDocVw.InternetExplorer

    IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.Navigate("C:\rptStatusProd.xml") 'load web page google.com

    While IE.Busy
        Application.DoEvents()  'wait until IE is done loading page.
    End While

    IE.FullScreen = True

这并不能让我控制 IE... 有没有办法让我可以向下滚动页面?我想自动向上/向下滚动页面,因为网页将在整个公司的电视上显示,如果网页上的数据过多,则必须向下滚动才能查看。

【问题讨论】:

    标签: vb.net internet-explorer autoscroll


    【解决方案1】:

    它不漂亮......但它是一些东西。它将滚动到页面顶部并返回到底部。我很幸运,因为我的网页中没有足够的项目来显示两者之间的内容。这对我有用:

    Imports mshtml
    
    Sub Main()
        Dim IE As SHDocVw.InternetExplorer
    
        IE = CreateObject("InternetExplorer.Application")
        IE.Visible = True
        IE.Navigate("C:\rptStatusProd.xml") 'load web page
    
        While IE.Busy
            Application.DoEvents()  'wait until IE is done loading page.
        End While
    
        IE.FullScreen = True
    
        Dim doc As HTMLDocumentClass = IE.Document
        Dim myProcesses() As Process
        myProcesses = Process.GetProcessesByName("iexplore")
    
        While myProcesses.Count > 0
            Try
                doc.activeElement.scrollIntoView(True) 'Scroll to top
                System.Threading.Thread.Sleep(5000)
                doc.activeElement.scrollIntoView(False) 'Scroll to bottom
                System.Threading.Thread.Sleep(5000)
            Catch COMEx As System.Runtime.InteropServices.COMException
                'RPC Server unavailable, Internet explorer was closed
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End While
    End Sub
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多