Path Finder: Script to Avoid Warning when Closing a Window with Tabs
With Path Finder 4.6.1, when you close a window with tabs, you get an alert that’s asking if you really want to close all the tabs. This is very annoying. On the Path Finder forum, there is a mention of that, its supposed to be on the todo list for the developpers. Mainwhile, you can use this AppleScript if you want to get rid of the warning. Just put the script in your AppleScript Menu, or better, in your FastScripts menu, set a shortcut (mine is control-w) and there you go. Its not ideal, and I rather attach this script to the File menu of Path Finder, but for that, you need PreFab UI Actions because Path Finder is not “AppleScript attachable”. Well, that’s another reason tempting me to buy this app, and also PreFab UI Browser.
tell application "Path Finder"
activate
try
set allWindows to every finder window
set mainWindow to item 1 of allWindows
set go to true
repeat while go
try
set mainWindowName to name of mainWindow as string
if mainWindowName is equal to "" then return
tell application "System Events"
keystroke "w" using command down
end tell
on error
return
end try
end repeat
on error
return
end try
end tell
So the only way I have found is to ask each time for the name of the front window, and if the name doesn’t exist, then it means that there are no more windows to process. Since we took a reference to the main window with set mainWindow to item 1 of allWindows, this made sure that we won’t close a Path Finder window that is behind the main Path Finder window.