0

私は 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を制御することはできません...ページを下にスクロールできるようにする方法はありますか? 会社のテレビ全体に Web ページが表示されるため、ページを自動的に上下にスクロールしたいのですが、Web ページのデータが多すぎる場合は、下にスクロールして表示する必要があります。

4

1 に答える 1

2

それはきれいではありません...しかし、それは何かです。ページの上部にスクロールし、下部に戻ります。Web ページに間に表示するのに十分な項目があるわけではないので、私は幸運です。これは私のために働いた:

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
于 2013-05-29T15:03:14.887 に答える