我试图在重复循环中更改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
我知道我在这里错过了一些简单的东西。我让它在其他环境中工作(在循环之外)......
答案 0 :(得分:1)
如果您关闭并手动重新打开Finder窗口,背景会发生变化!根据{{3}},解决方案是重新打开窗口(也就是打开一个新窗口并关闭旧窗口)到“刷新”视图:
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
享受,迈克尔/汉堡