Open a file in google chrome with cmd without swapping to the new tab

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ariiza13
    New Member
    • Dec 2020
    • 5

    Open a file in google chrome with cmd without swapping to the new tab

    I'm new here and I'm looking for help, I found this way to open files on google chrome with java:


    private void abrirVideo(Stri ng archivo) {
    File arch = new File(archivo);
    String comando = "cmd.exe /c start chrome \"" + (archivo) + "\"";
    try {
    String s = arch.getParent( );
    Runtime.getRunt ime().exec(coma ndo, null, new File(s));
    } catch (Exception ex) {
    System.out.prin tln("Error abriendo archivo: " + archivo + "\n" + ex);
    }
    }


    and it does work fine, it opens the file in the same window, but the problem I have is that it automatically swaps chrome to the new tab, I've been looking for a couple days on the web and I don't see any post about this. Is there a way to open those files (like pictures, videos, etc...) in chrome in a new tab, without automatically swapping to that new tab. Thank you for your help.
  • dev7060
    Recognized Expert Contributor
    • Mar 2017
    • 655

    #2
    and it does work fine, it opens the file in the same window, but the problem I have is that it automatically swaps chrome to the new tab, I've been looking for a couple days on the web and I don't see any post about this. Is there a way to open those files (like pictures, videos, etc...) in chrome in a new tab, without automatically swapping to that new tab. Thank you for your help.
    What does 'swap' signify here? Switching of the active tab?

    Comment

    • Ariiza13
      New Member
      • Dec 2020
      • 5

      #3
      Yes. It switches the active tab to that new tab.
      I couldn't find any way to do it so i had to use this chrome extension to force chrome to never switch to new tabs:

      But that solution could stop working in the future, so if you know any way to do it in the code itself i'll be really thankful.

      Comment

      • dev7060
        Recognized Expert Contributor
        • Mar 2017
        • 655

        #4
        Command-line switches and flags may prove useful. Refer to the documentation.

        Comment

        Working...