Hi, I am using ScriptEditor with javascript.
var app = Application('Terminal'); app.doScript("cd ~/Downloads;clear;"); app.activate();
It is work fine.
but i want to open the command to exist Terminal window's tab. so i put the code this:
var app = Application('Terminal'), frontWin = app.windows[0], frontTab = frontWin.tabs[-1]; frontTab.push(new app.Tab()) // Error -1700: Can't convert types. frontTab.doScript("cd ~/Downloads;clear;"); // Error on line 8: Error: Named parameters must be passed as an object app.activate();
But it is not work. please help me fix the problem.
Thanks.
You need to specify the tab you want to use, after checking that there is a window (or getting the tab will fail):
var app = Application('Terminal') app.activate try { currentWindow = app.windows.at(0) // is there a window? currentTab = currentWindow.selectedTab() app.doScript("echo testing", {in: currentTab}) } catch(err) { console.log(err) // no window app.doScript("echo 'test new window'"); }