Applescript ASObjc运行程序shell脚本进度
我正在尝试使用ASObjC Runner制作进度条。 进度条必须显示shell脚本的进度,在本例中为“sleep 5”。我想出了这个剧本:Applescript ASObjc运行程序shell脚本进度,applescript,Applescript,我正在尝试使用ASObjC Runner制作进度条。 进度条必须显示shell脚本的进度,在本例中为“sleep 5”。我想出了这个剧本: repeat with i from 1 to 100 do shell script "sleep 5" tell application "ASObjC Runner" reset progress activate show progress set propert
repeat with i from 1 to 100
do shell script "sleep 5"
tell application "ASObjC Runner"
reset progress
activate
show progress
set properties of progress window to {detail:"Progress: " & i, current value:i}
if button was pressed of progress window then
exit repeat
end if
end tell
end repeat
tell application "ASObjC Runner" to quit
但是如果shell脚本完成,他的脚本只会将进度条更新1%,因此需要5秒才能获得1%的进度。
是否有可能使其正常工作,因此在shell脚本完成后,进度条是100%。
感谢你的帮助 如果希望在shell脚本运行时更新进度条,恐怕这是不可能的。AppleScript中的Shell脚本同步运行,您的代码会这样做(一步一步)
- 脚本开始
- 脚本等待5秒
- 脚本开始与ASObjC运行程序对话
将PID设置为执行shell脚本“sleep 5&>/dev/null&echo$!”
使shell脚本异步运行。这样做的好处是,它还将返回进程的PID作为背景,因此您可以将其用于任何您想要的用途。使用更高级的shell脚本,您可以在这个后台进程和调用AppleScript之间实现一些通信。