简体   繁体   English

AppleScript中的增量进度栏

[英]Increment Progress Bar in AppleScript

I have an app that is using the "SKProgressbar". 我有一个使用“ SKProgressbar”的应用程序。 I'm looking to have this progress bar increment say by 10 based on the process of the second shell script that is running in it. 我希望根据正在其中运行的第二个Shell脚本的过程,使进度条增加10。 I am not sure if this is possible. 我不确定这是否可能。 I have provided the script below. 我在下面提供了脚本。 I am new to this. 我是新来的。

    on open adisk
    set terminalcommand to "cd " & quoted form of (POSIX path of adisk) & " ; find . -name '.DS_Store' -type f -delete"
    do shell script terminalcommand
    set xxx to "cd " & quoted form of (POSIX path of adisk) & " ; find * -type f -exec md5 -r {} \\; > *New_File.md5"
    set iconPath to ((path to me) as text) & "Contents:Resources:droplet.icns"

    tell application "SKProgressBar"
        activate
        set floating to false --> default is true
        set position to {500, 550} --> default is {1000, 750}, origin point is bottom left
        set width to 400.0 --> default is 500.0
        set title to "CreateMD5"
        set header to "Processing..."
        set header alignment to center
        set footer to "" --> default is empty string
        set footer alignment to center -->  default is left
        -- image path can be HFS or POSIX path, default is missing value (no image)
        set image path to iconPath
        tell progress bar
            set minimum value to 0.0 --> default is 0.0
            set maximum value to 100.0 -->  default is 100.0
            set current value to 0.0 --> default is 0.0
        end tell
        set show window to true --> default is false
        tell progress bar
            set indeterminate to false --> default is true
            start animation
            increment by 10.0
            do shell script xxx
            stop animation
        end tell
        quit
    end tell
    activate
    display dialog "        MD5 Complete!" with icon 1 buttons {"Close", "Open Directory"} cancel button 1 default button 2
    tell application "Finder"
        open adisk
    end tell
end open

Any help on this would be great. 任何帮助都会很棒。 If the simple answer is no, then I will move on and try to figure something out. 如果简单的答案是“否”,那么我将继续尝试找出一些答案。

I'm unfamiliar with how SKProgressbar works, but if it doesn't reset everything after the script ends, couldn't you reverse this whole process? 我不熟悉SKProgressbar的工作方式,但是如果脚本结束后它没有重设所有内容,您是否可以撤消整个过程? Instead of attempting to run a bash script from within applescript, why not make an applescript that solely increments the bar by one and then have the bash script call it throughout its code? 与其尝试从applescript中运行bash脚本,不如制作一个applebar只将bar增加一,然后让bash脚本在其整个代码中调用它呢?

eg. 例如。

#/Users/user_name/Desktop/update_progbar.scpt
on run()
    tell application "SKProgressBar"
        activate
        tell progress bar
            increment by 10.0
        end tell
    end tell
end

And then 接着

#!/bin/bash
#/Some/Location/my_bash_script.sh
for x in {1..10}; do
    #do stuff here
    osascript /Users/user_name/Desktop/update_progbar.scpt
done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM