Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 在Automator中按顺序运行多个Applescripts_Macos_Applescript_Automator - Fatal编程技术网

Macos 在Automator中按顺序运行多个Applescripts

Macos 在Automator中按顺序运行多个Applescripts,macos,applescript,automator,Macos,Applescript,Automator,我正试图使这个过程自动化 步骤1:将系统日期更改为特定日期 步骤2:打开一个应用程序 步骤3:将系统日期更改回正常状态 现在在Automator上,我有三个苹果脚本像这样放置 问题是自动机只运行第一个代码。我不知道如何让它按顺序运行所有代码 对不起,如果这是一个愚蠢的问题。我完全不熟悉automator和applescript 谢谢你我不太清楚你为什么选择使用三个独立的AppleScripts。您可以将它们组合成一个AppleScript,正如我在下面的示例中所做的那样。我不太清楚你为什么

我正试图使这个过程自动化

步骤1:将系统日期更改为特定日期

步骤2:打开一个应用程序

步骤3:将系统日期更改回正常状态

现在在Automator上,我有三个苹果脚本像这样放置



问题是自动机只运行第一个代码。我不知道如何让它按顺序运行所有代码

对不起,如果这是一个愚蠢的问题。我完全不熟悉automator和applescript


谢谢你

我不太清楚你为什么选择使用三个独立的AppleScripts。您可以将它们组合成一个AppleScript,正如我在下面的示例中所做的那样。我不太清楚你为什么使用“激活”命令。我认为它们不是必需的,所以我删除了这些代码行。无论如何,下面的代码应该适合您

tell application "Terminal"
    do script with command "sudo date 082704002018"
end tell
delay 1
tell application "System Events"
    keystroke "mypassword" & return
    delay 3
end tell
tell application "Terminal"
    do script with command "open -a applicationName"
    delay 1
    do script with command "sudo ntpdate -u time.apple.com"
end tell
delay 1
tell application "System Events"
    keystroke "mypassword" & return
    delay 3
end tell
或者,不必一直启动终端应用程序来运行shell脚本,因为您可以使用“do shell script”命令在AppleScript中运行shell脚本。下面的applescript代码是仅使用八行代码的代码

do shell script "sudo date 082704002018"
tell application "System Events" to keystroke "mypassword" & return
delay 3
do shell script "open -a applicationName"
delay 1
do shell script "sudo ntpdate -u time.apple.com"
delay 1
tell application "System Events" to keystroke "mypassword" & return
如果我的代码版本出现错误,可能需要调整延迟命令或重新插入
激活
命令


如果您执意要使用您的代码版本和三个单独的AppleScript,只需从每个AppleScript中删除
运行时{input,parameters}
结束运行时
代码行,就可以消除您的问题

您测试了代码吗?我没有,但我已经看到您的最后一个代码块将无法工作<代码>执行shell脚本启动没有终端的shell进程,因此无法接收用户输入。因此,键入密码将毫无意义。
on run {input, parameters}

tell application "Terminal"
    do script with command "sudo ntpdate -u time.apple.com"
    activate
end tell

delay 1
tell application "System Events"

    keystroke "mypassword" & return
    delay 3

end tell

end run
tell application "Terminal"
    do script with command "sudo date 082704002018"
end tell
delay 1
tell application "System Events"
    keystroke "mypassword" & return
    delay 3
end tell
tell application "Terminal"
    do script with command "open -a applicationName"
    delay 1
    do script with command "sudo ntpdate -u time.apple.com"
end tell
delay 1
tell application "System Events"
    keystroke "mypassword" & return
    delay 3
end tell
do shell script "sudo date 082704002018"
tell application "System Events" to keystroke "mypassword" & return
delay 3
do shell script "open -a applicationName"
delay 1
do shell script "sudo ntpdate -u time.apple.com"
delay 1
tell application "System Events" to keystroke "mypassword" & return