diff --git a/.DS_Store b/.DS_Store index f0090ff..8b818fd 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/SpyderScripts/.DS_Store b/SpyderScripts/.DS_Store new file mode 100644 index 0000000..411a26c Binary files /dev/null and b/SpyderScripts/.DS_Store differ diff --git a/SpyderScripts/minimize_all.py b/SpyderScripts/minimize_all.py new file mode 100644 index 0000000..ae43774 --- /dev/null +++ b/SpyderScripts/minimize_all.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +""" +Minimize All Windows - Python Version +Requires: pip3 install pyobjc-framework-Cocoa pyobjc-framework-Quartz + +This uses native macOS APIs which should be more reliable than AppleScript. +""" + +import time +from Cocoa import NSWorkspace, NSRunningApplication +from Quartz import ( + CGWindowListCopyWindowInfo, + kCGWindowListOptionOnScreenOnly, + kCGNullWindowID +) +import subprocess + +def get_all_windows(): + """Get all visible windows from all apps""" + window_list = CGWindowListCopyWindowInfo( + kCGWindowListOptionOnScreenOnly, + kCGNullWindowID + ) + return window_list + +def minimize_window_via_applescript(app_name): + """Use AppleScript to minimize the frontmost window of an app""" + script = f''' + tell application "{app_name}" + activate + end tell + delay 0.8 + tell application "System Events" + tell process "{app_name}" + set frontmost to true + delay 0.4 + keystroke "m" using command down + end tell + end tell + ''' + try: + subprocess.run(['osascript', '-e', script], timeout=5, check=False) + return True + except Exception as e: + print(f"Failed to minimize {app_name}: {e}") + return False + +def main(): + # Apps to skip + skip_apps = {'Finder', 'SystemUIServer', 'Dock', 'Electron', 'MSTeams', 'nxdock'} + skip_keywords = ['Helper', 'Agent'] + + # Get all running applications + workspace = NSWorkspace.sharedWorkspace() + running_apps = workspace.runningApplications() + + processed_apps = set() + + for app in running_apps: + app_name = app.localizedName() + + # Skip if already processed + if app_name in processed_apps: + continue + + # Skip system apps and problematic apps + if app_name in skip_apps: + continue + + # Skip apps with certain keywords + if any(keyword in app_name for keyword in skip_keywords): + continue + + # Skip if not a regular app + if not app.activationPolicy() == 0: # NSApplicationActivationPolicyRegular + continue + + print(f"Processing: {app_name}") + minimize_window_via_applescript(app_name) + processed_apps.add(app_name) + time.sleep(0.3) + + # Handle Finder windows separately + print("Processing: Finder windows") + finder_script = ''' + tell application "Finder" + try + set allWindows to every Finder window + repeat with aWindow in allWindows + set miniaturized of aWindow to true + end repeat + end try + end tell + ''' + subprocess.run(['osascript', '-e', finder_script], check=False) + + print("Done minimizing all windows") + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/SpyderScripts/minimize_all_best.sh b/SpyderScripts/minimize_all_best.sh new file mode 100755 index 0000000..e9bfa72 --- /dev/null +++ b/SpyderScripts/minimize_all_best.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Minimize All Windows - Simplified and Improved + +osascript <