6

For example if I click on a link in vscode editor it does not interfere with what I am currently doing - opens it without making chrome window active.

I want to achieve the same from command line from windows using one of: cmd, msys bash, powershell.

There is a similar question answered but without foreground requirement.

Community
  • 1
  • 1
honzajde
  • 2,270
  • 3
  • 31
  • 36
  • You can try to look through List of Chromium Command Line Switches at http://peter.sh/experiments/chromium-command-line-switches/ but after a quick glance over it I think there is nothing simple that would help you. – SergGr Mar 28 '17 at 18:20
  • I have checked that too, that's why I put that link into my question. thx – honzajde Mar 29 '17 at 08:53
  • Would a scripted solution, maybe involving something like AutoHotkey, which just switches back to the original window or minimises Chrome after it has popped up in foreground, be an option? – kriegaex Mar 29 '17 at 13:00
  • I believe there must be neater solution. No need to be so hacky:) – honzajde Apr 01 '17 at 20:20

3 Answers3

1

Haven't tried it but with PowerShell you can try :

Start-Process -WindowStyle Hidden "chrome.exe" "www.google.com"

or

Start-Process -WindowStyle Minimized "chrome.exe" "www.google.com"
ChuckMaurice
  • 111
  • 7
  • 1
    This does not work. But in form it's close to what I would imagine the solution will look like... – honzajde Apr 11 '17 at 07:29
1

I see a solution here, however there seem to be no direct way to open links in chrome without bringing chrome window to foreground.

Use Chrome Remote Debugging Protocol. The browser has to be run with param --remote-debugging-port=9222. Actually, all instances of chrome have to be closed first. Then chrome can be controlled via this API. There is a client for it in most major languages, e.g. node:chrome-remote-interface.

I believe this is how also vscode does it, however they can do it even without remote-debugging-port parameter on the chrome instance.

So to complete the task in my original question, u need only to write some script that makes use of installed Debugging Protocol client of your choice.

Update: this also brings chrome to foreground (only if the window is hidden behind another window it doesn't). For definitive solution use chrome extension with tabs API (I am afraid this is necessary).

honzajde
  • 2,270
  • 3
  • 31
  • 36
-2

You can just Create one text file with .bat extension in windows OS. Then you can write path where your Chrome is present and then you can write Chrome.exe and then give the link as argument which you want to open.

For Example, cd C:\Program Files (x86)\Google\Chrome\Application

chrome.exe www.yahoo.com

I hope it will help you.

Sejal Baraiya
  • 238
  • 2
  • 9