Internet explorer 在多个internet explorer实例之间appactivate

Internet explorer 在多个internet explorer实例之间appactivate,internet-explorer,batch-file,vbscript,Internet Explorer,Batch File,Vbscript,是否可以使用wshshell.appactivate在多个internet explorer窗口之间切换 我正试图写一个脚本,将不同的internet explorer实例在kiosk模式下放到前台。最终目标是使它看起来像是从一个网页转到下一个网页。我尝试使用wshshell.sendkey,但在弹出“打开网页”对话框时,它看起来并不顺畅。您可以枚举所有explorer/internet explorer窗口 从帮助 窗口方法 创建并返回ShellWindows对象。此对象表示属于Shell的

是否可以使用wshshell.appactivate在多个internet explorer窗口之间切换


我正试图写一个脚本,将不同的internet explorer实例在kiosk模式下放到前台。最终目标是使它看起来像是从一个网页转到下一个网页。我尝试使用wshshell.sendkey,但在弹出“打开网页”对话框时,它看起来并不顺畅。

您可以枚举所有explorer/internet explorer窗口

从帮助

窗口方法


创建并返回ShellWindows对象。此对象表示属于Shell的所有打开窗口的集合

语法

oWindows = Shell.Windows()
返回值

对ShellWindows对象的对象引用

例子

以下示例使用Windows检索ShellWindows对象并显示其包含的项目数。显示了Microsoft JScript、Microsoft Visual Basic脚本编制版(VBScript)和Visual Basic的正确用法。 VBScript:

以身作则

<script language="VBScript">
    function fnShellWindowsVB()
        dim objShell
        dim objShellWindows

        set objShell = CreateObject("Shell.Application")
        set objShellWindows = objShell.Windows

        if (not objShellWindows is nothing) then
            alert(objShellWindows.Count)
        end if

        set objShellWindows = nothing
        set objShell = nothing
    end function
 </script>

我玩了几天。我们可以从IE获取hwnd,但不能获取PID。所以我能看到的唯一匹配HWnd和PID的方法是调用Win32API调用。那么如何在VBS中实现这一点

所有计算机都安装了4个VB.NET编译器。所以我们所需要做的就是编写一个com服务器来包装GetWindowThreadProcessId

在脚本中,将以下行写入文本文件。我为此重新调整了脚本的用途,因此方法名称很愚蠢

Imports System
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Imports System.Net.Mail



Namespace SendMail

    <Guid("85B4AD6D-2E89-4869-9BBC-69E42738FCFC"), _
    InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> _
   Public Interface _SendMail
        <DispId(1)> Function Send(ByVal hWnd As Integer) As Integer
    End Interface

    <Guid("C91EDEB2-3756-4893-905B-0E4E2150C7FD"), _
     ClassInterface(ClassInterfaceType.None), _
     ProgId("Scripting.SendMail")> Public Class SendMail
        Implements _SendMail

        Public SendMail()
        Public Declare Auto Function GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (ByVal hwnd As Integer, ByRef lpdwProcessId As Integer) As Integer

        Public Function Send(HWnd as Integer) As Integer Implements _SendMail.Send
            Dim X as Integer
            Dim M as Integer
    M=1

            X=GetWindowThreadProcessID(HWnd,M)
            msgbox(X & " " & M & " " & HWnd & " " & Err.LastDllError)
            Send = M

        End Function

    End Class

End Namespace
然后在脚本中使用

Set x = CreateObject("Scripting.SendMail")
Msgbox x.Send(&h1a013e)

现在我已经生成了GUID,用于动态创建com对象。因为它们现在在公共代码中,所以您(以及任何复制此代码的人)必须销毁脚本中的对象。使用/u运行Regasm命令。或者生成新的guid。

当然。你是说窗口,不是标签,对吗?“如果你试图激活一个活动窗口,它会失败,因为该窗口已经处于活动状态。”我不相信这是真的。无论呼叫前窗口是否已处于活动状态,它都应返回
True
。Internet explorer确实具有唯一的PID,但无法知道启动时将为其分配什么号码。我不知道如何搜索进程和PID编号。@Bond。无论是腻子还是NetTerm都是如此。但也许它们是不寻常的。
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:library /out:"%userprofile%\desktop\sendmail\sendmail.dll" "%userprofile%\desktop\sendmail\sendmail.cls" /verbose


"C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm" /codebase "%userprofile%\desktop\sendmail\sendmail.dll" /tlb:"%userprofile%\desktop\sendmail\sendmail.tlb" /v
Set x = CreateObject("Scripting.SendMail")
Msgbox x.Send(&h1a013e)