Created
September 5, 2017 14:27
-
-
Save anonymous/93a822a7744d6073c715a41152333f9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<root> | |
<item> | |
<name>My Key 52: Minimize All Windows But...</name> | |
<item> | |
<name>...But Active Window_Hold F</name> | |
<identifier>Minimize All Windows But Active Window_Hold F</identifier> | |
<autogen> | |
--HoldingKeyToKey-- | |
KeyCode::F,ModifierFlag::NONE, | |
@begin | |
KeyCode::F, | |
@end | |
@begin | |
KeyCode::F,ModifierFlag::OPTION_L,ModifierFlag::COMMAND_L,ModifierFlag::SHIFT_L,ModifierFlag::CONTROL_L, | |
@end | |
Option::NOREPEAT, | |
</autogen> | |
</item> | |
<item> | |
<name>...But Open Windows of Active App_Hold A</name> | |
<identifier>Minimize All Windows But Open Windows of Active App_Hold A</identifier> | |
<autogen> | |
--HoldingKeyToKey-- | |
KeyCode::A,ModifierFlag::NONE, | |
@begin | |
KeyCode::A, | |
@end | |
@begin | |
KeyCode::A,ModifierFlag::OPTION_L,ModifierFlag::COMMAND_L,ModifierFlag::SHIFT_L,ModifierFlag::CONTROL_L, | |
@end | |
Option::NOREPEAT, | |
</autogen> | |
</item> | |
</item> | |
</root> | |
<!-- Script-Minimize All Windows But Active Window: | |
tell application "System Events" | |
-- update script to work with iTunes, Dictionary, fSync, Karabiner Preferences | |
display notification "Release your finger" with title "my key 52.1" | |
delay 0.5 | |
set openApps to (get name of every application process whose visible is true) | |
set activeApp to (get name of first process where it is frontmost) | |
set targetApps_1 to {} | |
repeat with i from 1 to count openApps | |
if {openApps's item i} is not in activeApp then | |
set targetApps_1's end to openApps's item i | |
end if | |
end repeat | |
delay 0.2 | |
set otherApps to {"Firefox", "VLC", "VideoSpec", "iTunes"} -- (Command + Option + M is not for minimizing all windows) | |
set otherApps_2 to {"Dictionary", "fSync", "Karabiner Preferences"} -- (Can’t get name of window 1,window doesn’t understand the “count” message) | |
set otherApps_3 to {"iTunes"} -- set new rules to unminimize active window | |
set targetApps_2 to {} | |
repeat with i from 1 to count targetApps_1 | |
if {targetApps_1's item i} is not in otherApps then | |
set targetApps_2's end to targetApps_1's item i | |
end if | |
end repeat | |
end tell | |
delay 0.2 | |
set tabApps to {"Firefox", "Google Chrome", "Safari"} | |
if activeApp is not in tabApps then | |
if activeApp is not in otherApps then | |
delay 0.2 | |
if activeApp is not in otherApps_2 then | |
delay 0.2 | |
tell application activeApp | |
activate | |
set activeWindow to (get name of front window) | |
if (count of window) is greater than 1 then | |
delay 0.2 | |
tell application "System Events" | |
keystroke "m" using {command down, option down} | |
end tell | |
end if | |
end tell | |
end if | |
end if | |
end if | |
delay 0.2 | |
if activeApp is "iTunes" then | |
tell application "iTunes" | |
activate | |
delay 0.2 | |
set activeWin to (get name of front window) | |
set iTunesWin_1 to {"Multiple Song Info", "Song Info"} -- cancel window | |
if activeWin is in iTunesWin_1 then | |
tell application "System Events" | |
key code 53 | |
end tell | |
end if | |
delay 0.2 | |
set iTunesWin_2 to (get name of every window) | |
if "MiniPlayer" is in iTunesWin_2 then -- minimize window | |
delay 0.7 | |
if "iTunes" is name of front window then | |
tell application "System Events" | |
keystroke "m" using command down | |
end tell | |
else | |
tell application "System Events" | |
tell process "iTunes" | |
delay 0.2 | |
click menu item "iTunes" of menu 1 of menu bar item "Window" of menu bar 1 | |
end tell | |
end tell | |
delay 0.9 | |
tell application "System Events" | |
delay 0.4 | |
keystroke "m" using command down | |
delay 0.4 | |
end tell | |
end if | |
set winCount to (count window) | |
if winCount is greater than 2 then -- windows: Activity,Equalizer | |
if "Activity" is in iTunesWin_2 then | |
tell application "System Events" | |
tell process "iTunes" | |
if menu item "Activity" of menu 1 of menu bar item "Window" of menu bar 1 exists then | |
delay 0.2 | |
click menu item "Activity" of menu 1 of menu bar item "Window" of menu bar 1 | |
end if | |
end tell | |
delay 0.2 | |
keystroke "m" using command down | |
end tell | |
end if | |
if "Equalizer" is in iTunesWin_2 then | |
delay 0.3 | |
if "Equalizer" is name of front window then | |
delay 0.4 | |
tell application "System Events" | |
keystroke "m" using command down | |
delay 0.4 | |
end tell | |
else | |
tell application "System Events" | |
tell process "iTunes" | |
delay 0.2 | |
click menu item "Equalizer" of menu 1 of menu bar item "Window" of menu bar 1 | |
end tell | |
end tell | |
delay 0.9 | |
tell application "System Events" | |
delay 0.4 | |
keystroke "m" using command down | |
delay 0.4 | |
end tell | |
end if | |
end if | |
end if | |
else -- "MiniPlayer" is NOT in iTunesWin_2 | |
set winCount to (count window) | |
repeat winCount times | |
delay 0.2 | |
tell application "System Events" | |
keystroke "m" using command down | |
end tell | |
end repeat | |
end if -- if "MiniPlayer" is in iTunesWin_2 | |
delay 0.2 | |
-- unminimize active window of iTunes | |
if activeWin is not in iTunesWin_1 then | |
if activeWin is not "MiniPlayer" then | |
tell application "System Events" | |
tell process "iTunes" | |
if menu item activeWin of menu 1 of menu bar item "Window" of menu bar 1 exists then | |
delay 0.5 | |
click menu item activeWin of menu 1 of menu bar item "Window" of menu bar 1 | |
end if | |
end tell | |
end tell | |
end if | |
else -- activeWin is in iTunesWin_1, set active window to "iTunes" | |
tell application "System Events" | |
tell process "iTunes" | |
if menu item "iTunes" of menu 1 of menu bar item "Window" of menu bar 1 exists then | |
delay 0.5 | |
click menu item "iTunes" of menu 1 of menu bar item "Window" of menu bar 1 | |
end if | |
end tell | |
end tell | |
end if | |
end tell | |
end if | |
delay 0.2 | |
-- if (tabApp = activeApp, count menu item) | |
if activeApp is "Safari" then | |
tell application activeApp | |
activate | |
delay 0.2 | |
set activeWindow to (get name of front window) | |
tell application "System Events" | |
tell process activeApp | |
if (count menu item of menu 1 of menu bar item "Window" of menu bar 1) > 14 then | |
delay 0.3 | |
keystroke "m" using {command down, option down} | |
end if | |
end tell | |
end tell | |
end tell | |
end if | |
if activeApp is "Google Chrome" then | |
tell application activeApp | |
activate | |
delay 0.2 | |
set activeWindow to (get name of front window) | |
tell application "System Events" | |
tell process activeApp | |
if (count menu item of menu 1 of menu bar item "Window" of menu bar 1) > 19 then | |
delay 0.3 | |
keystroke "m" using {command down, option down} | |
end if | |
end tell | |
end tell | |
end tell | |
end if | |
if activeApp is "Firefox" then | |
tell application activeApp | |
activate | |
delay 0.2 | |
set activeWindow to (get name of front window) | |
tell application "System Events" | |
tell process activeApp | |
set menuitemCount to (count menu item of menu 1 of menu bar item "Window" of menu bar 1) | |
delay 0.3 | |
if menuitemCount > 4 then | |
repeat (menuitemCount - 3) times | |
delay 0.6 | |
keystroke "m" using command down | |
end repeat | |
end if | |
end tell | |
end tell | |
end tell | |
end if | |
-- end of if (tabApp = activeApp, count menu item) | |
delay 0.2 | |
-- unminimize active window (run 1 of 2) | |
if activeApp is not "Safari" then | |
if activeApp is not in otherApps_2 then | |
delay 0.2 | |
if activeApp is not in otherApps_3 then | |
tell application activeApp | |
activate | |
delay 0.2 | |
tell application "System Events" | |
tell process activeApp | |
if menu item activeWindow of menu 1 of menu bar item "Window" of menu bar 1 exists then | |
delay 0.5 | |
click menu item activeWindow of menu 1 of menu bar item "Window" of menu bar 1 | |
end if | |
end tell | |
end tell | |
end tell | |
end if | |
end if | |
else -- activeApp is "Safari" | |
tell application activeApp | |
activate | |
delay 0.2 | |
if length of activeWindow is greater than 28 then | |
set activeWindow_2 to text 1 thru 28 of activeWindow | |
delay 0.2 | |
tell application "System Events" | |
tell process "Safari" | |
click (menu item 1 where its name starts with activeWindow_2) of menu 1 of menu bar item "Window" of menu bar 1 | |
end tell | |
end tell | |
else | |
tell application "System Events" | |
tell process activeApp | |
if menu item activeWindow of menu 1 of menu bar item "Window" of menu bar 1 exists then | |
delay 0.5 | |
click menu item activeWindow of menu 1 of menu bar item "Window" of menu bar 1 | |
end if | |
end tell | |
end tell | |
end if | |
end tell | |
end if | |
delay 0.7 | |
-- minimize windows | |
repeat with targetApp in targetApps_2 | |
delay 0.1 | |
tell application targetApp | |
activate | |
delay 0.2 | |
tell application "System Events" | |
keystroke "m" using {command down, option down} | |
end tell | |
end tell | |
end repeat | |
delay 0.2 | |
-- minimize 'otherApps' windows | |
if (item 1 of otherApps) is in openApps then -- item 1 of otherApps | |
if (item 1 of otherApps) is not in activeApp then | |
tell application "Firefox" | |
activate | |
delay 0.3 | |
tell application "System Events" | |
tell process "Firefox" | |
set menuitemCount to (count menu item of menu 1 of menu bar item "Window" of menu bar 1) | |
delay 0.2 | |
if menuitemCount > 3 then | |
repeat (menuitemCount - 3) times | |
delay 0.7 | |
keystroke "m" using command down | |
end repeat | |
end if | |
end tell | |
end tell | |
end tell | |
end if | |
end if | |
delay 0.2 | |
if (item 2 of otherApps) is in openApps then -- item 2 of otherApps | |
if (item 2 of otherApps) is not in activeApp then | |
tell application "VLC" | |
activate | |
delay 0.2 | |
tell application "System Events" | |
tell process "VLC" | |
if menu item "Minimize All" of menu 1 of menu bar item "Window" of menu bar 1 exists then | |
delay 0.2 | |
click menu item "Minimize All" of menu 1 of menu bar item "Window" of menu bar 1 | |
end if | |
end tell | |
end tell | |
end tell | |
end if | |
end if | |
delay 0.2 | |
if (item 3 of otherApps) is in openApps then -- item 3 of otherApps | |
if (item 3 of otherApps) is not in activeApp then | |
tell application "VideoSpec" | |
activate | |
delay 0.2 | |
tell application "System Events" | |
keystroke "m" using command down | |
end tell | |
end tell | |
end if | |
end if | |
if (item 4 of otherApps) is in openApps then -- item 4 of otherApps | |
if (item 4 of otherApps) is not in activeApp then | |
tell application "iTunes" | |
activate | |
delay 0.2 | |
set activeWin to (get name of front window) | |
set iTunesWin_1 to {"Multiple Song Info", "Song Info"} -- cancel window | |
if activeWin is in iTunesWin_1 then | |
tell application "System Events" | |
key code 53 | |
end tell | |
end if | |
delay 0.2 | |
set iTunesWin_2 to (get name of every window) | |
if "MiniPlayer" is in iTunesWin_2 then | |
delay 0.7 | |
if "iTunes" is name of front window then | |
tell application "System Events" | |
keystroke "m" using command down | |
end tell | |
else | |
tell application "System Events" | |
tell process "iTunes" | |
delay 0.2 | |
click menu item "iTunes" of menu 1 of menu bar item "Window" of menu bar 1 | |
end tell | |
end tell | |
delay 0.9 | |
tell application "System Events" | |
delay 0.4 | |
keystroke "m" using command down | |
delay 0.4 | |
end tell | |
end if | |
set winCount to (count window) | |
if winCount is greater than 2 then -- windows: Activity,Equalizer | |
if "Activity" is in iTunesWin_2 then | |
tell application "System Events" | |
tell process "iTunes" | |
if menu item "Activity" of menu 1 of menu bar item "Window" of menu bar 1 exists then | |
delay 0.2 | |
click menu item "Activity" of menu 1 of menu bar item "Window" of menu bar 1 | |
end if | |
end tell | |
delay 0.2 | |
keystroke "m" using command down | |
end tell | |
end if | |
if "Equalizer" is in iTunesWin_2 then | |
delay 0.5 | |
if "Equalizer" is name of front window then | |
delay 0.4 | |
tell application "System Events" | |
keystroke "m" using command down | |
delay 0.4 | |
end tell | |
else | |
tell application "System Events" | |
tell process "iTunes" | |
delay 0.2 | |
click menu item "Equalizer" of menu 1 of menu bar item "Window" of menu bar 1 | |
end tell | |
end tell | |
delay 0.9 | |
tell application "System Events" | |
delay 0.4 | |
keystroke "m" using command down | |
delay 0.4 | |
end tell | |
end if | |
end if | |
end if | |
else -- "MiniPlayer" is NOT in iTunesWin_2 | |
set winCount to (count window) | |
repeat winCount times | |
delay 0.2 | |
tell application "System Events" | |
keystroke "m" using command down | |
end tell | |
end repeat | |
end if -- if "MiniPlayer" is in iTunesWin_2 | |
end tell | |
end if | |
end if | |
delay 0.7 | |
-- unminimize active window (run 2 of 2) | |
if activeApp is not "Safari" then | |
if activeApp is not in otherApps_2 then | |
delay 0.2 | |
if activeApp is not in otherApps_3 then | |
tell application activeApp | |
activate | |
delay 0.2 | |
tell application "System Events" | |
tell process activeApp | |
if menu item activeWindow of menu 1 of menu bar item "Window" of menu bar 1 exists then | |
delay 0.5 | |
click menu item activeWindow of menu 1 of menu bar item "Window" of menu bar 1 | |
end if | |
end tell | |
end tell | |
end tell | |
end if | |
end if | |
else -- activeApp is "Safari" | |
tell application activeApp | |
activate | |
delay 0.2 | |
if length of activeWindow is greater than 28 then | |
set activeWindow_2 to text 1 thru 28 of activeWindow | |
delay 0.2 | |
tell application "System Events" | |
tell process "Safari" | |
click (menu item 1 where its name starts with activeWindow_2) of menu 1 of menu bar item "Window" of menu bar 1 | |
end tell | |
end tell | |
else | |
tell application "System Events" | |
tell process activeApp | |
if menu item activeWindow of menu 1 of menu bar item "Window" of menu bar 1 exists then | |
delay 0.5 | |
click menu item activeWindow of menu 1 of menu bar item "Window" of menu bar 1 | |
end if | |
end tell | |
end tell | |
end if | |
end tell | |
end if | |
delay 0.4 | |
-- activate app in otherApps_2 and otherApps_3 | |
if activeApp is in otherApps_2 or activeApp is in otherApps_3 then | |
tell application activeApp | |
activate | |
end tell | |
end if | |
-- END of Script-Minimize All Windows But Active Window | |
Script-Minimize All Windows But Open Windows of Active App: | |
tell application "System Events" | |
-- update script to work with iTunes | |
display notification "Release your finger" with title "my key 52.1" | |
delay 0.2 | |
set openApps to (get name of every application process whose visible is true) | |
set activeApp to (get name of first process where it is frontmost) | |
set targetApps_1 to {} | |
repeat with i from 1 to count openApps | |
if {openApps's item i} is not in activeApp then | |
set targetApps_1's end to openApps's item i | |
end if | |
end repeat | |
delay 0.2 | |
set otherApps to {"Firefox", "VLC", "VideoSpec", "iTunes"} -- (Command + Option + M is not for minimizing all windows) | |
set targetApps_2 to {} | |
repeat with i from 1 to count targetApps_1 | |
if {targetApps_1's item i} is not in otherApps then | |
set targetApps_2's end to targetApps_1's item i | |
end if | |
end repeat | |
end tell | |
repeat with targetApp in targetApps_2 | |
delay 0.3 | |
tell application targetApp | |
activate | |
delay 0.2 | |
tell application "System Events" | |
keystroke "m" using {command down, option down} | |
end tell | |
end tell | |
end repeat | |
delay 0.2 | |
-- Minimize 'otherApps' windows | |
if (item 1 of otherApps) is in openApps then -- item 1 of otherApps | |
if (item 1 of otherApps) is not in activeApp then | |
tell application "Firefox" | |
activate | |
delay 0.3 | |
tell application "System Events" | |
tell process "Firefox" | |
set menuitemCount to (count menu item of menu 1 of menu bar item "Window" of menu bar 1) | |
delay 0.2 | |
if menuitemCount > 3 then | |
repeat (menuitemCount - 3) times | |
delay 0.7 | |
keystroke "m" using command down | |
end repeat | |
end if | |
end tell | |
end tell | |
end tell | |
end if | |
end if | |
delay 0.2 | |
if (item 2 of otherApps) is in openApps then -- item 2 of otherApps | |
if (item 2 of otherApps) is not in activeApp then | |
tell application "VLC" | |
activate | |
delay 0.2 | |
tell application "System Events" | |
tell process "VLC" | |
if menu item "Minimize All" of menu 1 of menu bar item "Window" of menu bar 1 exists then | |
delay 0.2 | |
click menu item "Minimize All" of menu 1 of menu bar item "Window" of menu bar 1 | |
end if | |
end tell | |
end tell | |
end tell | |
end if | |
end if | |
delay 0.2 | |
if (item 3 of otherApps) is in openApps then -- item 3 of otherApps | |
if (item 3 of otherApps) is not in activeApp then | |
tell application "VideoSpec" | |
activate | |
delay 0.2 | |
tell application "System Events" | |
keystroke "m" using command down | |
end tell | |
end tell | |
end if | |
end if | |
delay 0.2 | |
if (item 4 of otherApps) is in openApps then -- item 4 of otherApps | |
if (item 4 of otherApps) is not in activeApp then | |
tell application "iTunes" | |
activate | |
delay 0.2 | |
set activeWin to (get name of front window) | |
set iTunesWin_1 to {"Multiple Song Info", "Song Info"} -- cancel window | |
if activeWin is in iTunesWin_1 then | |
tell application "System Events" | |
key code 53 | |
end tell | |
end if | |
delay 0.2 | |
set iTunesWin_2 to (get name of every window) | |
if "MiniPlayer" is in iTunesWin_2 then | |
delay 0.7 | |
if "iTunes" is name of front window then | |
tell application "System Events" | |
keystroke "m" using command down | |
end tell | |
else | |
tell application "System Events" | |
tell process "iTunes" | |
delay 0.2 | |
click menu item "iTunes" of menu 1 of menu bar item "Window" of menu bar 1 | |
end tell | |
end tell | |
delay 0.9 | |
tell application "System Events" | |
delay 0.4 | |
keystroke "m" using command down | |
delay 0.4 | |
end tell | |
end if | |
set winCount to (count window) | |
if winCount is greater than 2 then -- windows: Activity,Equalizer | |
if "Activity" is in iTunesWin_2 then | |
tell application "System Events" | |
tell process "iTunes" | |
if menu item "Activity" of menu 1 of menu bar item "Window" of menu bar 1 exists then | |
delay 0.2 | |
click menu item "Activity" of menu 1 of menu bar item "Window" of menu bar 1 | |
end if | |
end tell | |
delay 0.2 | |
keystroke "m" using command down | |
end tell | |
end if | |
if "Equalizer" is in iTunesWin_2 then | |
delay 0.5 | |
if "Equalizer" is name of front window then | |
delay 0.4 | |
tell application "System Events" | |
keystroke "m" using command down | |
delay 0.4 | |
end tell | |
else | |
tell application "System Events" | |
tell process "iTunes" | |
delay 0.2 | |
click menu item "Equalizer" of menu 1 of menu bar item "Window" of menu bar 1 | |
end tell | |
end tell | |
delay 0.9 | |
tell application "System Events" | |
delay 0.4 | |
keystroke "m" using command down | |
delay 0.4 | |
end tell | |
end if | |
end if | |
end if | |
else -- "MiniPlayer" is NOT in iTunesWin_2 | |
set winCount to (count window) | |
repeat winCount times | |
delay 0.2 | |
tell application "System Events" | |
keystroke "m" using command down | |
end tell | |
end repeat | |
end if -- if "MiniPlayer" is in iTunesWin_2 | |
end tell | |
end if | |
end if | |
delay 0.7 | |
tell application activeApp | |
activate | |
end tell | |
-- END of Script-Minimize All Windows But Open Windows of Active App | |
--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment