0

I want my macOS app to display a modal progress bar like this:

enter image description here

and want to update the progress by AppleScript.

osascript -l JavaScript -e '
  const app = Application("MyApp")
  app.includeStandardAdditions = true
  app.activate()
  Progress.totalUnitCount = 100
  Progress.completedUnitCount = 1
  Progress.description = "Processing..."
  Progress.additionalDescription = "Preparing to process."
  for (i = 0; i < 100; i++) {
    Progress.additionalDescription = "Processing " + i + " of " + 100
    Progress.completedUnitCount = i
    delay(1)
  }
'

How to do that? What should I do in my MyApp?

koen
  • 5,383
  • 7
  • 50
  • 89
lonny
  • 11
  • 1
  • 2
  • 1
    Is this for an Objective-C application? Do you actually want AppleScript support, or are just wanting a progress indicator? – red_menace Jan 22 '22 at 14:35
  • Yes, it's oc app. I want applescript support really. – lonny Jan 22 '22 at 15:34
  • How to show a simple modal progress bar in a oc app maybe help. Maybe we could do it with NSScriptCommand. – lonny Jan 22 '22 at 15:36
  • AppKit has the [NSProgressIndicator](https://developer.apple.com/documentation/appkit/nsprogressindicator?language=objc) class, if that is all you need. Not much sense running a shell script to run a JavaScript/AppleScript that just uses Objective-C to do it anyway. – red_menace Jan 22 '22 at 18:17
  • Some jobs are running outside the app. They are extending the app. And they need to report the progress. – lonny Jan 23 '22 at 01:00
  • However these outside jobs report to your app would be different than implementing the progress indicator, or is getting their progress what you are asking about? – red_menace Jan 23 '22 at 01:41
  • How about writing a [coprocess](https://iterm2.com/documentation-coprocesses.html) for [iTerm2](https://github.com/gnachman/iTerm2). The coprocess want to display a progress bar, and prevents the user input until stop. What would you do with iTerm2? – lonny Jan 23 '22 at 02:07
  • I still don't understand what you're trying to accomplish. Is it an App and a plugin? Which one is doing the processing and which one shows the progress window? Are you developing the app, the plugin or both? How is AppleScript involved? Is iTerm an example or is the question about iTerm? Or is the question "Why is this script not working?"? – Willeke Jan 23 '22 at 09:52
  • I'm trying to write a plugin for iTerm2. And I'm trying to send a PR to iTerm2 if necessary. – lonny Jan 23 '22 at 12:46
  • I don't think osascript supports progress. – Willeke Jan 23 '22 at 14:38
  • Maybe we could tell iTerm2 to show progress? – lonny Jan 24 '22 at 00:44

0 Answers0