diff --git a/SpyderScripts/.minimize_all.py.swp b/SpyderScripts/.minimize_all.py.swp new file mode 100644 index 0000000..6ab960b Binary files /dev/null and b/SpyderScripts/.minimize_all.py.swp differ diff --git a/SpyderScripts/minimize_all.py b/SpyderScripts/minimize_all.py index cfff09a..9b5a3b4 100644 --- a/SpyderScripts/minimize_all.py +++ b/SpyderScripts/minimize_all.py @@ -70,10 +70,11 @@ def minimize_window_via_applescript(app_name): def minimize_finder_windows(): """Minimize all Finder windows using Finder's native scripting""" - # First, get count of Finder windows to know if we need to do anything + # First, get count of non-collapsed Finder windows count_script = ''' tell application "Finder" - return count of Finder windows + set visibleWindows to (every Finder window whose collapsed is false) + return count of visibleWindows end tell ''' try: @@ -86,19 +87,17 @@ def minimize_finder_windows(): window_count = int(result.stdout.strip()) if result.stdout.strip() else 0 if window_count == 0: - print("Finder: No windows to minimize") + print("Finder: No visible windows to minimize") return print(f"Finder: Minimizing {window_count} window(s)") - # Minimize each window one by one (more reliable than batch) + # Finder uses "collapsed" not "miniaturized" for minimizing windows minimize_script = ''' tell application "Finder" - repeat with aWindow in (every Finder window) - try - set miniaturized of aWindow to true - delay 0.2 - end try + set allWindows to every Finder window + repeat with w in allWindows + set collapsed of w to true end repeat end tell '''