多个IE浏览器实例之间则AppActivate [英] appactivate between multiple internet explorer instances

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

问题描述

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

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

我试图写一个脚本,将前线带来的Internet Explorer的不同实例Kiosk模式。最终的目标是要使它看起来像它从一个网页转到下一个。我尝试使用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.Run以下命令隐藏固定的路径。

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

"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

然后在脚本中使用

Then to use in script

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

现在我已经生成的GUID的为此动态创建COM对象。由于它们现在公共code你(的任何人复印本)必须在脚本中销毁对象。运行带有/ 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.

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

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