AppActivate Function for windows with the same title and under one Process


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

Thanks all. Steve


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

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))


  • Dynamically set focus to another program in C#
  • Google CSE multiple redefinements
  • Permanently press key via vbs (Keep key pressed)
  • Get the value of selected option from a dropdown list in the same file in php?
  • Creating a new list and eliminate empty cells from existing list
  • How do I edit PHP variable with JavaScript/jQuery?
  • vbscript - Bring Internet Explorer Appliation window to front
  • Intercept incoming SMS
  • Exporting data from Excel to Outlook
  • Set Outlook's 'show this address list first' option
  • Extending the User Interface in Outlook 2010 to add to the Right Click menu
  • Aggregating based on “near” row values
  • Is there a simple MVC4 html helper for collapsible (multi-level) Bootstrap 3 menus?
  • Override method for a collection of classes implementing an interface
  • Obtain access token for both Microsoft Graph and individual service API endpoints (Outlook REST APIs
  • How can I mark as read all emails fetched through EWS in a single update?
  • Cannot debug project after upgrading to Service Fabric SDK v2.3.301
  • How to fetch the alt value from an img using vba
  • Read files from URL
  • Pasting URLs That Have Been Scraped From a Webpage
  • Is the Go HTTP handler goroutine expected to exit immediately in this case?
  • Parallel sieve of Eratosthenes - Java Multithreading
  • How to access recipient on sent messages page with mailboxer
  • why calling cd shell command through system() or execvp() from a child process won't work?
  • Installing Perl6 and Panda on Ubuntu 15.10. Problems with bootstrap.pl
  • powershell Get-Counter -ComputerName parameter on Windows 7
  • Xamarin MonoAndroid Azure mobile service InsertAsync
  • How can I get the full list of running processes on a Mac from a python app
  • Private IP address in reserved subnet range
  • How To Customize ASP.NET Chart Databound To SqlDataSource
  • nonblocking BIO_do_connect blocked when there is no internet connected
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • Typescript - Unable to get 'import' statement to function
  • Spark fat jar to run multiple versions on YARN
  • Debugging ASP.NET on a built-in web server suddenly stops
  • Is there any way to access browser form field suggestions from JavaScript?
  • Volusion's generic SQL folder, functionality
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent