繁体   English   中英

Applescript进度条不起作用

[英]Applescript progress bar not working

我有一个正常工作的进度条形码但是当我把它与一些任务混合,比如在这里复制文件时,它会给我错误并且不会增加,它会在第一次复制后停止,任何想法问题在哪里?

这是代码:

tell application "Finder"
    set selected_items to selection
    set fileCount to length of selected_items
end tell

set progress total steps to fileCount
set progress completed steps to 0
set progress description to "Processing Images..."
set progress additional description to "Preparing to process."
set a to 1

tell application "Finder"
    set theFolder to POSIX file "/Users/graphics/Desktop/1"
    repeat with x in selected_items
        set progress additional description to "Processing image " & a & " of " & fileCount
        duplicate x to theFolder
        set progress completed steps to a + 1
        set a to a + 1
    end repeat
end tell

这是脚本, 请阅读以下注释

tell application "Finder"
    set selected_items to selection
    set fileCount to count of selected_items
end tell

set progress total steps to fileCount
set progress completed steps to 0
set progress description to "Processing Images..."
set progress additional description to "Preparing to process."
set a to 1

repeat with x in selected_items
    set progress additional description to "Processing image " & a & " of " & fileCount
    tell application "Finder"
        set theFolder to (path to desktop folder as string) & "1:"
        duplicate x to theFolder with replacing
    end tell
    tell me to set progress completed steps to a + 1
    set a to a + 1
end repeat

我将set progress...处理程序移出了tell application "Finder" -Block,因为应用程序“Finder”不知道进度条,并更正了目标文件夹以匹配任何桌面文件夹。 如果 ,它现在完美地工作

  • 脚本保存为Applet
  • Applet通过Dock启动

这是因为

  • 在脚本编辑器中运行时,脚本编辑器无法处理用于更新进度条的不同线程

  • 如果你通过在Finder中双击启动Applet,Applet本身就成了选择,只因为你点击它! 从码头开始解决了这个问题!

玩得开心,迈克尔/汉堡

暂无
暂无

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

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