Created
January 20, 2022 11:32
-
-
Save OKsign/be6f7ffd1d816c421beb76998c75627a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- user input - hotkey of 'all windows' in HyperSwitch | |
set hotkey to "command" -- "option" or "command" or "control" | |
-- end of user input - hotkey in HyperSwitch | |
-- user options - "lr" = left and right | "tb" = top and bottom | |
set position to "lr" | |
-- end of user options | |
set screen_w to (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution/{print $2}'") | |
set screen_h to (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution/{print $4}'") | |
set in2_screen_w to screen_w / 2 | |
set in2_screen_h to screen_h / 2 | |
--- left | |
if position is "lr" then | |
tell application "System Events" | |
set activeApp_1 to (get name of first process where it is frontmost) | |
end tell | |
tell application "System Events" | |
tell process activeApp_1 | |
set name_active_win_1 to get title of front window | |
end tell | |
end tell | |
tell application "System Events" | |
set position of window 1 of process activeApp_1 to {0, 0} | |
delay 1 | |
set size of window 1 of process activeApp_1 to {in2_screen_w, screen_h} | |
delay 0.7 | |
end tell | |
-- switch window | |
tell application "System Events" | |
if hotkey is "option" then | |
key code 48 using option down | |
delay 0.3 | |
end if | |
if hotkey is "command" then | |
key code 48 using command down | |
delay 0.3 | |
end if | |
if hotkey is "control" then | |
key code 48 using control down | |
delay 0.3 | |
end if | |
end tell | |
-- end - switch window | |
-- right | |
tell application "System Events" | |
set activeApp_2 to (get name of first process where it is frontmost) | |
end tell | |
tell application "System Events" | |
tell process activeApp_2 | |
set name_active_win_2 to get title of front window | |
end tell | |
end tell | |
tell application "System Events" | |
tell process activeApp_2 | |
set position of window name_active_win_2 to {in2_screen_w, 0} | |
delay 0.2 | |
set size of window name_active_win_2 to {in2_screen_w, screen_h} | |
delay 0.2 | |
end tell | |
end tell | |
tell application "System Events" | |
tell process activeApp_1 | |
set frontmost to true | |
delay 0.05 | |
click (menu item name_active_win_1 of menu 1 of menu bar item "Window" of menu bar 1) | |
delay 0.3 | |
end tell | |
end tell | |
display notification "Done!" with title "Script 35.1" | |
return | |
end if | |
-- top | |
if position is "tb" then | |
tell application "System Events" | |
set activeApp_1 to (get name of first process where it is frontmost) | |
end tell | |
tell application "System Events" | |
tell process activeApp_1 | |
set name_active_win_1 to get title of front window | |
end tell | |
end tell | |
tell application "System Events" | |
set position of window 1 of process activeApp_1 to {0, 0} | |
delay 1 | |
set size of window 1 of process activeApp_1 to {screen_w, in2_screen_h} | |
delay 0.7 | |
end tell | |
-- switch window | |
tell application "System Events" | |
if hotkey is "option" then | |
key code 48 using option down | |
delay 0.3 | |
end if | |
if hotkey is "command" then | |
key code 48 using command down | |
delay 0.3 | |
end if | |
if hotkey is "control" then | |
key code 48 using control down | |
delay 0.3 | |
end if | |
end tell | |
-- end - switch window | |
-- bottom | |
tell application "System Events" | |
set activeApp_2 to (get name of first process where it is frontmost) | |
end tell | |
tell application "System Events" | |
tell process activeApp_2 | |
set name_active_win to get title of front window | |
end tell | |
end tell | |
tell application "System Events" | |
tell process activeApp_2 | |
set position of window name_active_win to {0, in2_screen_h} | |
delay 0.2 | |
set size of window name_active_win to {screen_w, in2_screen_h} | |
delay 0.2 | |
end tell | |
end tell | |
tell application "System Events" | |
tell process activeApp_1 | |
set frontmost to true | |
delay 0.05 | |
click (menu item name_active_win_1 of menu 1 of menu bar item "Window" of menu bar 1) | |
delay 0.3 | |
end tell | |
end tell | |
display notification "Done!" with title "Script 35.1" | |
return | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment