我什至不知道从哪里开始我的问题,我尝试了100件事,并用Google搜索了几个小时,但没有发现任何有用的东西。 (我乐于接受每一个肮脏的把戏。)

这是我的问题:

我有一个.hta文件,其中的列表框如下所示:

windows - 使用vbscript激活(带到前台)特定窗口-LMLPHP

它列出了我运行的SAP Gui的所有 session /方式。

        Set SapGuiAuto  = GetObject("SAPGUI")
        Set application = SapGuiAuto.GetScriptingEngine

        If application.Connections.Count > 0 Then
            Set connection  = application.Children(0)

            If connection.Sessions.Count > 0 Then
                Set session = connection.Children(0)
            End If
        End If


        If IsObject(WScript) Then
            WScript.ConnectObject session,     "on"
            WScript.ConnectObject application, "on"
        End If

Set optGroup = Document.createElement("OPTGROUP")
    optGroup.label = "Server"


    'count all connected servers
    ConnectionCount = application.Connections.Count




        If ConnectionCount > 0 Then
            Sessionlist.appendChild(optGroup)

            Else
            optGroup.label = "No connection here."


        End If
        'count all sessions per server


        If ConnectionCount > 0 Then
            For Each conn in application.Connections

                'Text output connections and sessions

                SessionCount = conn.Sessions.Count
                whatIsIt  = conn.Description
                ConnectionFeld.innerhtml = ConnectionFeld.innerhtml & " <br> " & SessionCount & " Sessions auf " & whatIsIt

                'fill listbox with all connections

                Set objOption = nothing
                Set optGroup = Document.createElement("OPTGROUP")
                optGroup.label = conn.Description
                Sessionlist.appendChild(optGroup)

                i = 0

                    'fill listbox with all sessions
                    For Each sess In conn.Sessions

                        i = i + 1
                        Set objOption = Document.createElement("OPTION")

                            objOption.Text = "Session " & i & ": " & sess.ID
                            objOption.Value = sess.ID
                            SessionList.options.add(objOption)

                    Next
            Next

        Else

        Exit Sub

        End If

我的目标:当我双击该列表中的一个条目时,我的SAP Gui的选定实例应该进入前台/被激活。

不幸的是,我的任务管理器仅列出了一个任务,即“SAP Logon”。我打开的窗口之一也名为“SAP Logon”,其他所有窗口均具有相同的名称:“SAP Easy Access”。

windows - 使用vbscript激活(带到前台)特定窗口-LMLPHP

我可以看到连接ID(服务器名)和 session ID的唯一方法是使用vbscript提取它们。 (看上面)

有什么办法吗?在尝试一千种解决方案后,我唯一想到的解决方法是以下两种:

非常丑陋的解决方法:
If sessionID = sess.ID Then

Set objShell = CreateObject("shell.application")
objShell.MinimizeAll

sess.findById("wnd[0]").maximize

End If

它最小化所有窗口,然后最大化所选的SAP窗口。不幸的是,我的HTA-GUI也被最小化了。

第二个主意:

以某种方式通过快捷方式访问这些可点击的东西,并将其放入我的脚本或其他丑陋的方式。

手动执行此操作:

单击该小箭头,右键单击图标,然后左键单击名称。

windows - 使用vbscript激活(带到前台)特定窗口-LMLPHP

有什么办法可以自动化吗?这让我疯狂。

希望有人能帮助我,将不胜感激。

PS:我坐在一台权限受限的计算机上,因此我可能无法使用Windows API的解决方案来解决此问题。

编辑有关评论:

这不可能:
  • 更改注册表项
  • 创建COM对象
  • 除了VBScript以外,还可以使用
  • 最佳答案

    同样,它也可以与以下命令一起使用:

    session.findById("wnd[0]").iconify
    session.findById("wnd[0]").maximize
    

    10-07 14:01
    查看更多