通过VB.net应用程序控制Web浏览器

时间:2018-06-19 18:11:20

标签: vb.net process

我想为指定的网站打开Internet Explorer的单独实例。打开它们后,我想循环显示在计时器上。

我有以下代码,但无法切换到指定的IE进程:

Dim rotatethrough As Boolean = True
    For i = 0 To ListBox1.Items.Count - 1 'I have a list box that contains the website URLs
        Dim Processname As New List(Of String)
        Dim processnum(Environment.ProcessorCount) As Process
        processnum(i) = New Process
        processnum(i) = System.Diagnostics.Process.Start(ListBox1.Items(i)) 'start up seperate instances of IE for each website
    Next
    Do While rotatethrough = True
        For n = 0 To ListBox1.Items.Count - 1
            AppActivate(processnum(n).Id) 'activate the websites
            Threading.Thread.Sleep(1000)
        Next
    Loop

到目前为止,该代码打开了IE的单独实例,但在appactivate上失败,因为“对象引用未设置为对象的实例。”。我曾尝试将IE创建为对象,但是然后我不确定如何为相应的列表框项获取正确的进程ID。

任何帮助都会很棒,我似乎可以弄清楚这一点。

0 个答案:

没有答案