Jan 05 2021 10:37 AM - edited Jan 05 2021 10:40 AM
After launch a URL on a single tab of Chrome, the following will work just fine. But It will not work if Google.com is on an inactive tab of multiple tabs. Is there other way to do that? Thanks.
Start-Process chrome ("https://www.google.com")
Start-Sleep -Seconds 3
$p = Get-Process Chrome | ? { $_.MainWindowTitle.Contains('Google') }
[Microsoft.VisualBasic.Interaction]::AppActivate($p.Id)
PS 5 on Windows 10
Jan 05 2021 12:07 PM
bases on what I see, all Google Chrome Tabs are Child-Process to Google Chrome it self
Check this
even with the code you provide, if you have multiple Chrome Tabl open, it will only get the Main process
The result from your Code.
Did you notice the same Process ID?
Google is changing the Main Windows Title based on the Active Tab, this is why you are facing this issue,
I tried to dig via Process Explorer and see if I can get anything via the command ID or whatever parameter assigned to the tab but did not find anything.
it seems that other tabs don't hold a Title until activation, Check this
(Get-Process Chrome).foreach{$_.MainWindowTitle}
the only result you will get is the active Window Title, and a lot of other null values
Jan 05 2021 12:20 PM