6

I'm bit of a noob so please bear with me. I'm trying to open a lot of urls in internet explorer at once. About 40 urls.

I have an array of my urls and I'm using the following code:

for (int i = 0; i < urls.length; i++){
        java.awt.Desktop.getDesktop().browse(java.net.URI.create(urls[i]));
}

This works perfectly if I already have IE open. However if it's not open already it creates 40 new windows not tabs. I have tried to get around it by using the following:

for (int i = 0; i <= 9; i++){
        java.awt.Desktop.getDesktop().browse(java.net.URI.create(urls[i]));
        try {
            Thread.currentThread().sleep(200);
        } catch (InterruptedException ex) {
            Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
Peck3277
  • 1,383
  • 8
  • 22
  • 46

2 Answers2

2

200, is just too small, i have tryed 1000 and it was also too small, but 2000 was OK. And of course, open the first one, then wait, and then open all the others at once.

kajacx
  • 12,361
  • 5
  • 43
  • 70
1

You could make your first call, then grab a list of running processes and wait until iexplore pops up then continue with the rest. Or of course wait for longer

This seems to have a method of getting the running processes

Community
  • 1
  • 1
Joey Ciechanowicz
  • 3,345
  • 3
  • 24
  • 48