AppActivate 函数用于具有相同标题且在一个进程下的窗口 [英] AppActivate Function for windows with the same title and under one Process
本文介绍了AppActivate 函数用于具有相同标题且在一个进程下的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用一个非常简单的 VBScript 在多个屏幕之间切换,然后在暂停和继续之前刷新,但是我想在两个屏幕之间切换的名称相同,任何帮助表示赞赏.
I a using a very simple VBScript to switch between numerous screens and refreshing then before pausing and moving on, however two of the screens I want to switch between are named the same, any help appreciated.
Option Explicit
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Do
WScript.Sleep 3000
WshShell.AppActivate("Inbox - Microsoft Outlook")
WScript.Sleep 3000
WshShell.AppActivate("CSE Task Monitor")
WSHShell.SendKeys "{F5}"
WScript.Sleep 3000
WshShell.AppActivate("website - Windows Internet Explorer")
WSHShell.SendKeys "{F5}"
Loop
谢谢大家.史蒂夫
推荐答案
您应该使用 ProcessId 而不是 Window Title.我从 exe 文件名中获取进程 ID.
You should use ProcessId and not Window Title. I get the process ID from the exe file name.
Set WShell = CreateObject("WScript.Shell")
Set WMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
wql = "SELECT ProcessId FROM Win32_Process WHERE Name = ProcessName.exe'"
i=0
For Each process In WMI.ExecQuery(wql)
ProcessIdArray(i) = process.ProcessId
i = i + 1
Next
现在您拥有相同 ProcessName.exe 的进程 ID 数组,您可以使用
Now you have array of processesIDs for the same ProcessName.exe and you can use
WshShell.AppActivate(ProcessIdArray(0))
WScript.Sleep 3000
WshShell.AppActivate(ProcessIdArray(1))
这篇关于AppActivate 函数用于具有相同标题且在一个进程下的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文