使用Applescript,是否可以打开一个新终端并将命令输入终端但不运行它?
tell application "Terminal"
do script "echo Hello"
end tell
此代码将在终端中键入行echo Hello
并运行它。我们可以避免执行吗?
答案 0 :(得分:1)
系统事件应用程序和模拟击键的好例子:
tell application "Terminal" to activate -- only needed if Terminal may not be running
tell application "System Events"
tell application process "Terminal"
set frontmost to true
keystroke "echo Hello"
end tell
end tell