使用 Applescript 启动两个应用程序

发布于 2024-12-21 23:03:35 字数 848 浏览 3 评论 0原文

我一直在尝试启动使用单个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

っ〆星空下的拥抱 2024-12-28 23:03:35

我无法重现该问题,因此无法告诉您为什么会发生这种情况,但是(假设存在计时问题)引入 应用程序启动之间的延迟可能会解决该问题。您需要尝试延迟时间。

tell application "app1" to activate
delay 10
tell application "app2" to activate

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.

tell application "app1" to activate
delay 10
tell application "app2" to activate
心奴独伤 2024-12-28 23:03:35
tell application "app1" to activate
end if

tell application "app2" to activate
end if

尝试一下,看看它是如何工作的。

tell application "app1" to activate
end if

tell application "app2" to activate
end if

Try that and see how it works.

哀由 2024-12-28 23:03:35

我发现这个脚本可以工作:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文