I have a short script which (1) does some folder emptying, including the Trash, (2) clears the Recent Items menu and then (3) restarts. Without the last restart, no problem; the problem is that with restart, no clearing of the Recent Items menu occurs. I’ve tried various values of delay x, and zip clearing.
tell application "Finder"
my doEmptySomeFolders()
my doClearRecentItems()
delay x -- have tried up to 5
restart
end tell
on doClearRecentItems()
tell application "System Events"
click menu item "Clear Menu" of ¬
menu "Recent Items" of ¬
menu item "Recent Items" of ¬
menu "Apple" of ¬
menu bar item "Apple" of ¬
menu bar 1 of ¬
(first process whose frontmost is true)
end tell
end doClearRecentItems
Try using System Events instead:
tell application "Finder"
my doEmptySomeFolders()
my doClearRecentItems()
delay x -- have tried up to 5
end tell
tell application "System Events"
launch
restart
end tell
Bruce, unfortunately, this did not work. I’ve been thinking this may call for a solution similar to Jon Pugh’s routine for emptying the Trash such as:
Anyone got any ideas?
tell application "Finder"
empty the trash
set nbrTrashItems to length of (items of the trash as string)
-- display dialog nbrTrashItems
set trash_loop to 0
repeat while (nbrTrashItems > 0)
-- this prevents an endless loop in case
-- there are locked items in the Trash
--
-- suggested by Jon Pugh
set trash_loop to trash_loop + 1
if (trash_loop = 5 * minutes) then exit repeat
set nbrTrashItems to length of (items of the trash as string)
end repeat
end tell
John:
Be sure to read through the other thread you started, which has been interesting (and informative) of late:
http://bbs.applescript.net/viewtopic.php?id=14931
Amen … and by the way, a Blessed and Merry Christmas to all.