best working version yet
works for all windows excecpt for spyder it seems.
This commit is contained in:
BIN
SpyderScripts/.minimize_all.py.swp
Normal file
BIN
SpyderScripts/.minimize_all.py.swp
Normal file
Binary file not shown.
@@ -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
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user