If you run multiple Chrome windows with different profiles, and you need to activate the window with a specific profile, then this script is for you.
I recommend to use distinctive names for the profiles, for example, Work, Games, or Profile1, Profile2, etc
Special thanks to rbrtryn who created the original script to get the command line info of the running process.
All I did is to adapt it to my needs.
Code: Select all
ActivateChrome() {
var1 := "chrome.exe" ;process name
var2 := "00Default" ;set the specific profile
for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process where Name = '" var1 "'") {
Commandline := process.Commandline
str := process.ProcessId
StringReplace Parameters, Commandline, % Process.ExecutablePath
StringReplace Parameters, Parameters, ""
IfInString, Parameters, %var2%
{
WinActivate ahk_pid %str%
Break
}
}
}
I run it with no problems in Windows 10 Pro 64bit and AHK v1.1.26.01.