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():
|
def minimize_finder_windows():
|
||||||
"""Minimize all Finder windows using Finder's native scripting"""
|
"""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 = '''
|
count_script = '''
|
||||||
tell application "Finder"
|
tell application "Finder"
|
||||||
return count of Finder windows
|
set visibleWindows to (every Finder window whose collapsed is false)
|
||||||
|
return count of visibleWindows
|
||||||
end tell
|
end tell
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
@@ -86,19 +87,17 @@ def minimize_finder_windows():
|
|||||||
window_count = int(result.stdout.strip()) if result.stdout.strip() else 0
|
window_count = int(result.stdout.strip()) if result.stdout.strip() else 0
|
||||||
|
|
||||||
if window_count == 0:
|
if window_count == 0:
|
||||||
print("Finder: No windows to minimize")
|
print("Finder: No visible windows to minimize")
|
||||||
return
|
return
|
||||||
|
|
||||||
print(f"Finder: Minimizing {window_count} window(s)")
|
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 = '''
|
minimize_script = '''
|
||||||
tell application "Finder"
|
tell application "Finder"
|
||||||
repeat with aWindow in (every Finder window)
|
set allWindows to every Finder window
|
||||||
try
|
repeat with w in allWindows
|
||||||
set miniaturized of aWindow to true
|
set collapsed of w to true
|
||||||
delay 0.2
|
|
||||||
end try
|
|
||||||
end repeat
|
end repeat
|
||||||
end tell
|
end tell
|
||||||
'''
|
'''
|
||||||
|
|||||||
Reference in New Issue
Block a user