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.
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":
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!
31 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.