AppleScript for Finder已停止与Mavericks合作

AppleScript for Finder已停止与Mavericks合作,applescript,osx-mavericks,finder,Applescript,Osx Mavericks,Finder,我有一个非常简单的AppleScript: tell application "Finder" activate set |Window| to get Finder window 1 set the current view of |Window| to icon view set |View Options| to icon view options of |Window| set the icon size of |View Options|

我有一个非常简单的AppleScript:

tell application "Finder"
    activate

    set |Window| to get Finder window 1

    set the current view of |Window| to icon view

    set |View Options| to icon view options of |Window|

    set the icon size of |View Options| to 256
    set the label position of |View Options| to bottom
    set the shows item info of |View Options| to true
    set the shows icon preview of |View Options| to true
    set the arrangement of |View Options| to arranged by name
end tell
在小牛队之前,它一直运作良好。好的,它仍然运行,但缺少所需的效果。没什么,绝对没什么再发生了

有人知道新版OSX改变了什么吗

更新1:


现在我注意到这些变化确实发生了——在Finder重新启动之后。因此,它可能(或可能不)与这个问题有关,那么«»-只是我对10.8没有问题,它只出现在10.9中。我现在可能有帮助的简单修复方法是,在脚本中添加一个关闭窗口和打开窗口

     tell application "Finder"
    activate

    set |Window| to get Finder window 1

    set the current view of |Window| to icon view

    set |View Options| to icon view options of |Window|

    set the icon size of |View Options| to 256
    set the label position of |View Options| to bottom
    set the shows item info of |View Options| to true
    set the shows icon preview of |View Options| to true
    set the arrangement of |View Options| to arranged by name

    set flipTarget to folder "Users" of startup disk 
    set targ to target of |Window|

    set target of |Window| to flipTarget
    set target of |Window| to targ
    (* --close |Window|

    --open targ
    *)
end tell
不太理想,但除非有人想出解决这个错误的方法。我称之为bug,因为我没有更好的解释。也许可以

脚本收集窗口1的目标。关闭窗口1。然后打开窗口1的目标

我怀疑这个bug与在Mavericks中打开应用程序首选项plist文件并进行更改有关。变更可能不会像10.9之前那样生效。我认为这是因为偏好的读取方式和读取时间发生了变化。看来记忆中的东西将取代手工修改。但是,如果使用unix命令默认值,它们会立即更改


***更新*1

在马丁的回答中,有一个好主意,就是把目标翻转过来。 但是由于无法在根目录上工作的问题

简单的答案是使用特定的翻转目标。在此cae中,将显示用户的主文件夹。我们每个人都有自己的想法

我已经更新了代码的最后一部分,并注释掉了旧的部分


更改代码为

set flipTarget to folder "Users" of startup disk
    set targ to target of |Window|

    set target of |Window| to flipTarget
    set target of |Window| to targ

@markhunte是对的——这似乎是一个bug,你需要重新打开窗口或类似的东西才能绕过它。在上,我发现了一些附加信息。我现在的版本是(还学到了其他新技巧):

此解决方案不需要关闭窗口,只需更改其目标。在脚本编辑器中,您会看到窗口闪烁,但从脚本菜单启动时,它的速度太快,您不会再注意到


与@markhunte solution相比,此解决方案的缺点是:无法在根目录上工作。

您所说的“现在我注意到这种情况确实发生了”是什么意思?更改是持久的,但不会立即触发GUI更新。这是一个新问题,问题仍然是:“10.9改变了什么?”错误就在那里。但您不需要重新启动finder。只需打开并关闭窗口。我已更新我的答案,以通过翻转目标来解决根目录问题。我试图通过
tell | window |显式触发刷新以更新每个项目
,但这也不起作用!仅在@markhunte描述刷新时前后更改目标。谢谢你的解决方案!短抖动,但可以接受。我甚至找到了改善抖动的方法!将flipTarget设置为空文件夹并设置为图标视图。然后刷新只是一个空白画布(而不是图标/用户),几乎不可见!
  tell application "Finder"
    activate
    tell Finder window 1
        set current view to icon view

        set its icon view options's properties to {icon size:64, label position:bottom, shows item info:true, shows icon preview:true, arrangement:arranged by name}

        -- we refresh the window to reflect the icon size change!
        set Original_Target to its target as alias
        set Parent_Target to container of its target as alias
        set target to Parent_Target
        set target to Original_Target
    end tell
end tell