. . . keep butting your head against the brick wall until something gives.
Hey Chris. Thanks for all your help and suggestions.
After doing everything you suggested, it still failed on an intermittent basis.
For a while I suspected SnagIT, and the Parallels Desktop. I even reinstalled SnagIT, and tested without it installed. No help.
But I finally figured it out, I think: If the Finder window is in a different monitor than where the macro/script is initiated, then it fails.
When activated, the Finder menu is active on Screen 1, but the Finder Window is on Screen 2, showing in front of everything else, yet not truly/fully active.
What’s strange is that the “Activate” command works fine for other apps, regardless of which screen they are on.
Go figure!?!?
From your vast experience with System Events, is there anyway to detect which screen the Finder is on, and somehow use that to bring it to the front?
Okay. In the former case run this with output to a text-window and see what you get:
------------------------------------------------------------
# List Finder Window Index & Name
------------------------------------------------------------
tell application "System Events"
if quit delay ≠0 then set quit delay to 0
tell application process "Finder" to set frontmost to true
end tell
set AppleScript's text item delimiters to ""
tell application "Finder" to set {nameList, indexList} to {name, index} of windows
if nameList ≠{} then
set _cntr to 0
repeat with i in nameList
set _cntr to _cntr + 1
set contents of i to ((item _cntr of indexList) & tab & (contents of i)) as text
end repeat
end if
set AppleScript's text item delimiters to linefeed
nameList as text
------------------------------------------------------------
If I send you a script to run in a diagnostic context please do not add it to other scripts. I’m looking for a specific result without possible side-effects.
Okay, try running this before your close-tab menu action.
------------------------------------------------------------
set myDesktop to path to desktop
------------------------------------------------------------
tell application "System Events"
if quit delay ≠0 then set quit delay to 0
tell application process "Finder" to set frontmost to true
end tell
------------------------------------------------------------
tell application "Finder"
if (insertion location as alias) = myDesktop then
if (count of windows) > 0 then
set index of window 1 to 1
end if
end if
end tell
------------------------------------------------------------