更改 Finder 文件夹背景颜色 AppleScript [英] Change Finder folder background color AppleScript

查看:39
本文介绍了更改 Finder 文件夹背景颜色 AppleScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to change the background color of Finder within a repeat loop.

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

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

I know I'm missing something simple here. I got it to work in other contexts (outside the loop)...

推荐答案

如果您手动关闭并重新打开 Finder 窗口,背景会发生变化!根据 昨天的这个问题 解决方案是重新打开窗口(也就是打开一个新窗口并关闭旧窗口)以刷新"视图:

If you close and reopen your Finder window manually the background changes! According to this question from yesterday the solution is to re-open the window (aka open a new window and close the old) to "refresh" the view:

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

享受吧,迈克尔/汉堡

这篇关于更改 Finder 文件夹背景颜色 AppleScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆