Use VBS To focus on a specific process without process title or PID

I have a VBScript that should work to focus a given process (taken from here):

Dim ObjShell :Set ObjShell = CreateObject("Wscript.Shell")
ObjShell.AppActivate("Notepad")

But unfortunately this doesn't work when using the title of a specific process: "Ableton Live 10 Intro.exe" is what I believe to be the title.

Task Manager screenshot

Here you can see in the task manager that the parent process name is "Ableton Live 10 Intro.exe" (copypasted from the Properties panel). I also noticed that the description is "Ableton Live 10 Intro.exe":

enter image description here

Apparently AppActivate() requires a PID or title string "as it appears in the title bar", but the window title which appears in the title bar is empty. I also don't think I can use the PID to target this process because I don't know what the PID is, as this script should happen when this process launches on login (thus the PID will be different every time).

So how can I target this process given that I have its

  • description,
  • path of the executable,

but not its

  • title,
  • PID

Is this even possible? I am new to VBScript. Thanks for any help!

3

1 Answer

I would suggest using the freeAutoHotkeyrather than VBScript.

The following AutoHotkey script will activate your .exe:

WinGet, CalcIDs, List, ahk_exe Ableton Live 10 Intro.exe
If (CalcIDs = 1) ; Calc is NOT minimized CalcID := CalcIDs1
else CalcID := CalcIDs2 ; Calc is Minimized use 2nd ID
winRestore, ahk_id %CalcID%
winActivate, ahk_id %CalcID%

After installing AutoHotKey, put the above text in a .ahk file and double-click to test. To have it run on login, place it in the Startup group atC:\Users\USER-NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like