Macos Applescript进度条不工作

Macos Applescript进度条不工作,macos,applescript,Macos,Applescript,我有一个正常工作的进度条形码,但是当我把它和一些任务混合在一起时,比如在这里复制文件,它会给我错误并且不会增加,它会在第一次复制后停止,你知道问题出在哪里吗 代码如下: tell application "Finder" set selected_items to selection set fileCount to length of selected_items end tell set progress total steps to fileCount set progr

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

代码如下:

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
我将
设置进度…
处理程序移出
告诉应用程序“Finder”
-块,因为应用程序“Finder”不知道进度条,并更正了目标文件夹以匹配任何桌面文件夹。如果

  • 脚本保存为小程序
  • 小程序通过驳接启动
这是因为

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

  • 如果您在查找器内双击启动小程序,小程序本身将成为选择,因为您单击了它!从码头开始解决这个问题


祝你玩得开心,迈克尔/汉堡。您是否将其保存为小程序?2.也许Finder的选择只是在单击后包含了您的脚本?在复制之前,将对话框x显示为字符串,以确保3。告诉我们更多关于你所犯错误的信息。我将其保存为应用程序,在第一个错误之后它就会停止,这是整个脚本。如果你想运行它并查看错误,那么如何启动脚本?你试过我回答的第2点了吗?我从脚本编辑器运行脚本,我确信finder选择包含的文件不是脚本,你在你的机器上试过这段代码了吗?好的,然后请双击它来启动应用程序!但在添加
activate
之前,在第一次
告诉application Finder
后,实际上目标文件夹只是一个占位符,我必须将其更改为其他位置,我使用此脚本的目的是将其放入服务中,以便通过右键单击所选文件进行访问,我将尝试您的解决方案我可以在一个应用程序中使用它,它在邮件中做了一些事情,而不需要我从dock打开它。我确实与脚本所需的用户进行了一些交互,这使邮件应用程序成为焦点,所以这可能就是原因。Mail无法识别与Finder类似的进度指示器,因此必须退出Tell Mail才能使其正常工作。