appactivate 在多个 Internet Explorer 实例之间 [英] appactivate between multiple internet explorer instances

查看:38
本文介绍了appactivate 在多个 Internet Explorer 实例之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 wshshell.appactivate 在多个 Internet Explorer 窗口之间切换?

Is it possible to use wshshell.appactivate to switch between multiple internet explorer windows?

我正在尝试编写一个脚本,将处于信息亭模式的 Internet Explorer 的不同实例带到前面.最终目标是让它看起来像是从一个网页转到下一个网页.我尝试使用 wshshell.sendkey,但在弹出的打开网页对话框中看起来并不流畅.

I am trying to write a script that will bring different instances of internet explorer in kiosk mode to the front. The end goal is to make it look like it's going from one web page to the next. I tried using wshshell.sendkey but it doesn't look smooth with the open webpage dialog popping up.

推荐答案

我玩了几天.我们可以从 IE 获取 hwnd,但不能获取 PID.因此,我可以看到将 HWnd 与 PID 匹配的唯一方法是调用 Win32API 调用.那么如何在 VBS 中做到这一点.

I played with this for a few days. We can get an hwnd from IE, but not a PID. So the only way I can see to match HWnd to PID is call a Win32API call. So how to do that in VBS.

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

All computers have 4 VB.NET compilers installed. So all we need do is write a com server that wraps GetWindowThreadProcessId.

在您的脚本中,将以下行写入文本文件.我为此重新使用了不同的脚本,因此方法名称很愚蠢.

In your script write out the following line to a text file. I repurposed a different script for this so method names are silly.

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

然后编译WSHShell.运行以下命令隐藏修复路径.

Then to compile WSHShell.Run the following commands hidden fixing paths.

"C:WindowsMicrosoft.NETFrameworkv4.0.30319vbc.exe" /target:library /out:"%userprofile%desktopsendmailsendmail.dll" "%userprofile%desktopsendmailsendmail.cls" /verbose


"C:WindowsMicrosoft.NETFrameworkv4.0.30319
egasm" /codebase "%userprofile%desktopsendmailsendmail.dll" /tlb:"%userprofile%desktopsendmailsendmail.tlb" /v

然后在脚本中使用

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

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

Now I've generated the GUID's for this purpose of creating com objects on the fly. As they are in now public code you (AND ANYONE ELSE COPYING THIS) must destroy the object in your script. Run the Regasm command with /u. Or generate new GUIDs.

这篇关于appactivate 在多个 Internet Explorer 实例之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆