如果沒有終端應用程序打開,則以下代碼將打開兩個終端窗口。它爲什麼這樣做?我只想要打開一個窗口。爲什麼2個終端窗口用NSAppleScript打開?
如果只有一個終端窗口打開,則以下代碼僅打開一個附加窗口。
NSAppleScript* terminal = [[NSAppleScript alloc] initWithSource:
[NSString stringWithFormat:
@"tell application \"Terminal\"\n"
@" activate\n"
@" do script \"echo %@\"\n"
@" tell the front window\n"
@" set title displays shell path to false\n"
@" set title displays custom title to true\n"
@" set custom title to \"My session! %@\"\n"
@" end tell\n"
@"end tell", name, name]];
[terminal executeAndReturnError:nil];
當你說兩終端「應用」,你的意思是兩個終端窗口或應用程序的兩個實例實際? – zmccord 2012-03-08 03:27:43
兩個窗口 - 感謝撿起 – Coderama 2012-03-08 03:30:27