1

Why does this open two different windows and run each script in a different window? Is there a way to tell it to use the same window?

var Terminal = Application('Terminal');
Terminal.activate();
var window = Terminal.windows[0]
Terminal.doScript('ls',window);
Terminal.doScript('cd Desktop',window);

Thanks

foo
  • 3,171
  • 17
  • 18
aks.
  • 386
  • 1
  • 12

1 Answers1

2

You need to put the second parameter inside a "dictionary" using named parameters. This works:

var Terminal = Application('Terminal');
Terminal.activate();
var targetWindow = Terminal.windows[0];
Terminal.doScript('ls', {in: targetWindow});
Terminal.doScript('cd Desktop', {in: targetWindow});

Have fun! Michael / Hamburg

ShooTerKo
  • 2,242
  • 1
  • 13
  • 18