一键打开开发环境;激活“系统事件”仅当尚未激活时
我正在使用 applescript 打开我的开发环境。
更新 - 该脚本有效。我将打开文本移至脚本末尾,现在它的工作更加一致。
tell application "Terminal"
activate
do script "cd web_sites/mydomain" in front window
do script "rvm 1.9.2" in front window
do script "rails server" in front window
end tell
tell application "System Events"
if not (exists process "System Events") then
tell application "System Events" to activate
end if
tell process "Terminal" to (keystroke "t" using command down)
end tell
tell application "Terminal"
do script "cd web_sites/mydomain/public/stylesheets" in front window --> tab 2
do script "rvm 1.9.2" in front window --> tab 2
do script "sass --watch stylin.scss:stylin.css" in front window --> tab 2
end tell
tell application "System Events"
tell process "Terminal" to (keystroke "t" using command down)
end tell
tell application "Terminal"
do script "cd web_sites/mydomain" in front window --> tab 3
do script "rvm 1.9.2" in front window --> tab 3
do script "mate ." in front window
delay 4
do shell script "open -a Firefox http://localhost:3000"
end tell
感谢您的帮助。
I am using applescript to open my development environment.
UPDATE - This script works. I moved opening textmate to the end of the script and it works much more consistently now.
tell application "Terminal"
activate
do script "cd web_sites/mydomain" in front window
do script "rvm 1.9.2" in front window
do script "rails server" in front window
end tell
tell application "System Events"
if not (exists process "System Events") then
tell application "System Events" to activate
end if
tell process "Terminal" to (keystroke "t" using command down)
end tell
tell application "Terminal"
do script "cd web_sites/mydomain/public/stylesheets" in front window --> tab 2
do script "rvm 1.9.2" in front window --> tab 2
do script "sass --watch stylin.scss:stylin.css" in front window --> tab 2
end tell
tell application "System Events"
tell process "Terminal" to (keystroke "t" using command down)
end tell
tell application "Terminal"
do script "cd web_sites/mydomain" in front window --> tab 3
do script "rvm 1.9.2" in front window --> tab 3
do script "mate ." in front window
delay 4
do shell script "open -a Firefox http://localhost:3000"
end tell
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现三个可能的问题:
tell 应用程序“系统事件”
行嵌套在tell
块寻址终端
中。您应该创建两个tell application“Terminal”
块,并在它们之间插入tell application“System Events”
行。AppleScript 无法在一行上执行两个操作。换句话说,更改两次出现的...
...到这个块...
...应该可以解决问题。
系统事件
两次。该应用程序有默认的五分钟退出延迟(系统事件
将在五分钟不活动后自动退出)。如果您的计算机速度很快,您应该删除第二个activate
命令。希望这一切都有意义。 :)
I am seeing three possible issues:
The
tell application "System Events"
lines are nested within thetell
block addressingTerminal
. You should create twotell application "Terminal"
blocks with thetell application "System Events"
lines in between them.AppleScript cannot perform two actions on a single line. In other words, changing both occurrences of...
...to this block...
...should do the trick.
System Events
twice. The application has a default five minute quit delay (System Events
will automatically quit after five minutes of inactivity). You should remove the secondactivate
command provided your computer is fast.Hopefully all this should make sense. :)