【问题标题】:Change Finder folder background color AppleScript更改 Finder 文件夹背景颜色 AppleScript
【发布时间】:2015-03-20 08:52:13
【问题描述】:

我正在尝试在重复循环中更改 Finder 的背景颜色。

tell application "Finder"

    set windowCount to (count windows) 
    if windowCount > 0 then #check if windows are available

        set bgcolor to {65535, 0, 32896}

        repeat 10 times
            tell the icon view options of window 1
                set the background color to {some item of bgcolor, some item of bgcolor, some item of bgcolor}
                delay 0.1
            end tell
        end repeat

    end if
end tell

我知道我在这里遗漏了一些简单的东西。我让它在其他环境中工作(在循环之外)......

【问题讨论】:

    标签: macos applescript finder


    【解决方案1】:

    如果您手动关闭并重新打开您的 Finder 窗口,背景会发生变化!根据this question from yesterday,解决方案是重新打开窗口(也就是打开新窗口并关闭旧窗口)以“刷新”视图:

    tell application "Finder"
        set windowCount to (count windows)
        if windowCount > 0 then #check if windows are available
            set bgcolor to {65535, 0, 32896}
            repeat 10 times
                tell the icon view options of window 1
                    set the background color to {some item of bgcolor, some item of bgcolor, some item of bgcolor}
                end tell
                try
                    set w to front window
                    tell (make new Finder window)
                        try
                            set target to (get target of w)
                        end try
                        set bounds to (bounds of w)
                        set current view to (current view of w)
                    end tell
                    tell w to close
                end try
                delay 0.1
            end repeat
        end if
    end tell
    

    享受吧,迈克尔/汉堡

    【讨论】:

    • 谢谢迈克尔!我对 Mavericks/Yosemite 中的 AppleScript 更新感到沮丧,导致我的一些旧脚本死了...vimeo.com/11054114(大约 1:05)
    猜你喜欢
    • 2018-12-25
    • 1970-01-01
    • 1970-01-01
    • 2013-08-08
    • 2016-06-02
    • 1970-01-01
    相关资源
    最近更新 更多