如果没有终端应用程序打开,则以下代码将打开两个终端窗口。它为什么这样做?我只想要打开一个窗口。为什么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