首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >一键打开开发环境,未激活时才激活系统事件

一键打开开发环境,未激活时才激活系统事件
EN

Stack Overflow用户
提问于 2011-07-11 01:14:05
回答 1查看 198关注 0票数 0

我正在使用applescript打开我的开发环境。

更新-此脚本有效。我将打开textmate移到了脚本的末尾,现在它的工作更一致了。

代码语言:javascript
复制
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

谢谢你的帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-07-11 03:06:09

我看到了三个可能的问题:

  1. tell application "System Events"行嵌套在tell块寻址Terminal中。您应该创建两个tell application "Terminal"块,其中的tell application "System Events"行位于them.
  2. AppleScript不能在同一行上执行两个操作。换句话说,更改这两个实例...

告诉应用程序“系统事件”告诉进程“终端”激活(使用向下命令按键"t“)

...to这个区块...

使用{command down} end tell告诉应用程序“系统事件”激活tell进程"Terminal“按键"t”

...should做到了。

  • 这并不是什么问题,但是没有必要激活System Events两次。应用程序有默认的五分钟退出延迟(System Events将在五分钟不活动后自动退出)。如果您的计算机速度很快,您应该删除第二个activate命令。

希望所有这些都能说得通。:)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6642560

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档