使用 Applescript 启动两个应用程序
我一直在尝试启动使用单个 applescript 文件创建的两个应用程序。 (我正在使用 OS X Lion)
我使用的代码是:
tell application "app1" to activate
tell application "app2" to activate
执行这两个告诉中的任何一个都有效,但两者一起只启动第一个应用程序...
有谁知道我做错了什么?
第一个应用程序是由 xCode 编译的 C 应用程序,第二个应用程序是在 Flash CS4
编辑
中创建/发布的 AIR/Flash 应用程序我也尝试
do shell script "my_path_here/app1"
do shell script "my_path2_here/app2"
过仅启动第一个应用程序。
我也尝试过:
do shell script "my_path_here/app1" & "; my_path2_here/app2"
它仍然只启动第一个应用程序。
编辑2
我发现这个脚本可以工作:
do shell script "cd my_path_here/ ; open app1 ; cd my_path2_here/ ; open app2"
这完成了我需要做的事情,但仍然留下了原始问题,因为这是一种解决方法,而不是修复...这可能会带来更多问题阐明问题可能是什么。
I have been trying to launch two applications that I created with a single applescript file. (I am using OS X Lion)
The code I am using is:
tell application "app1" to activate
tell application "app2" to activate
Doing either one of these two tells works, but both together only launches the first application...
Does anyone know what I an doing wrong?
The first application is a C application compiled by xCode, and the second application is an AIR/Flash application created/published in Flash CS4
Edit
I've also tried
do shell script "my_path_here/app1"
do shell script "my_path2_here/app2"
which only launches the first application.
I've also tried:
do shell script "my_path_here/app1" & "; my_path2_here/app2"
which STILL only launches the first application.
Edit 2
I've discovered that this script will work:
do shell script "cd my_path_here/ ; open app1 ; cd my_path2_here/ ; open app2"
This accomplishes what I need done, but still leaves open the original problem, as this is a workaround and not a fix... This might shed more light on what the issue could be though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我无法重现该问题,因此无法告诉您为什么会发生这种情况,但是(假设存在计时问题)引入 应用程序启动之间的延迟可能会解决该问题。您需要尝试延迟时间。
I couldn't reproduce the issue, so can't tell you why it's happening, but (assuming there's a timing problem) introducing a delay between the application launches may resolve the problem. You'll need to experiment with the delay time.
尝试一下,看看它是如何工作的。
Try that and see how it works.
我发现这个脚本可以工作:
do shell script "cd my_path_here/ ; open app1 ; cd my_path2_here/ ; open app2"
这完成了我需要做的事情,但仍然留下了原始问题,因为这是一种解决方法,而不是修复...这可能会更清楚地说明问题可能是什么。
I've discovered that this script will work:
do shell script "cd my_path_here/ ; open app1 ; cd my_path2_here/ ; open app2"
This accomplishes what I need done, but still leaves open the original problem, as this is a workaround and not a fix... This might shed more light on what the issue could be though.