1

In an Applescript applet, progress can be shown like so:

set progress description to "A simple progress indicator"
set progress additional description to "Preparing…"
set progress total steps to -1

delay 5

set progress total steps to 100
repeat with i from 1 to 100
    try
        set progress additional description to "I am on step " & i
        set progress completed steps to i
        delay 0.2
    on error thisErr
        display alert thisErr
        exit repeat
    end try
end repeat

How would you access progress description, progress additional description, and progress total steps in Javascript for Automation (JXA)?

4

2 回答 2

2

IMO,优胜美地提供的所谓“进度条”就是个笑话。它不会显示大多数人所期望的:一个显示进度的小窗口。

Shane Stanley 编写了免费的ASObjC Runner 应用程序来提供此功能以及更多功能。

在这里查看一个真正的进度条: Demo of real Progress Bar using ASObjC Runner app

这是用 AppleScript 编写的,但转换为 JXA 应该不难。

编辑:我已将 AppleScript 代码转换为 JXA。你可以在这里得到它:

使用 ASObjC Runner 应用程序的 JXA 真实进度条演示

在此处输入图像描述

于 2016-01-12T20:07:47.673 回答
1

请参阅Progress本页 --> https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/Articles/OSX10-10.html

Progress使用该对象的脚本示例:

Progress.description =  "A simple progress indicator"
Progress.additionalDescription = "Preparing…"
delay(5)
Progress.totalUnitCount = 100;

for (var i = 1; i < 101; i++) {
    Progress.additionalDescription = "I am on step " + i
    Progress.completedUnitCount = i
    delay(0.1)
}
于 2016-01-11T20:21:18.143 回答