Created
January 20, 2022 11:13
-
-
Save OKsign/24f5d7831f38535e4fd0d1c5ced348d9 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
set Replace_Me to "abc" | |
-- user input (up to 30) - position, size and name of window | |
set input1 to Replace_Me | |
set input2 to Replace_Me | |
set input3 to Replace_Me | |
set input4 to Replace_Me | |
set input5 to Replace_Me | |
set input6 to Replace_Me | |
set input7 to Replace_Me | |
set input8 to Replace_Me | |
set input9 to Replace_Me | |
set input10 to Replace_Me | |
set input11 to Replace_Me | |
set input12 to Replace_Me | |
set input13 to Replace_Me | |
set input14 to Replace_Me | |
set input15 to Replace_Me | |
set input16 to Replace_Me | |
set input17 to Replace_Me | |
set input18 to Replace_Me | |
set input19 to Replace_Me | |
set input20 to Replace_Me | |
set input21 to Replace_Me | |
set input22 to Replace_Me | |
set input23 to Replace_Me | |
set input24 to Replace_Me | |
set input25 to Replace_Me | |
set input26 to Replace_Me | |
set input27 to Replace_Me | |
set input28 to Replace_Me | |
set input29 to Replace_Me | |
set input30 to Replace_Me | |
-- end of user input | |
set nameList to {input1, input2, input3, input4, input5, input6, input7, input8, input9, input10, input11, input12, input13, input14, input15, input16, input17, input18, input19, input20, input21, input22, input23, input24, input25, input26, input27, input28, input29, input30} | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
end tell | |
delay 0.03 | |
-- add fix s15 | |
if activeApp is "Google Chrome" then | |
tell application "Google Chrome" | |
set ActiveWinName to get title of front window | |
end tell | |
-- end add fix s15 | |
else -- activeApp is not "Google Chrome" | |
tell application "System Events" | |
tell process activeApp | |
set frontmost to true | |
set ActiveWinName to get title of front window | |
end tell | |
end tell | |
end if | |
repeat with i from 1 to 30 | |
if (item i of nameList) is not Replace_Me then | |
if ActiveWinName is item 5 of (item i of nameList) then | |
delay 0.02 | |
-- add fix s15 | |
if activeApp is "Google Chrome" then | |
set Chrome_winName to ActiveWinName | |
tell application "System Events" | |
tell process "Google Chrome" | |
click (menu item "Minimize" of menu 1 of menu bar item "Window" of menu bar 1) | |
end tell | |
end tell | |
delay 2 | |
tell application "System Events" | |
set position of window 1 of process activeApp to {item 1 of (item i of nameList), item 2 of (item i of nameList)} | |
delay 1 | |
set size of window 1 of process activeApp to {item 3 of (item i of nameList), item 4 of (item i of nameList)} | |
end tell | |
tell application "System Events" | |
tell process "Google Chrome" | |
set frontmost to true | |
delay 0.2 | |
click (menu item Chrome_winName of menu 1 of menu bar item "Window" of menu bar 1) | |
end tell | |
end tell | |
delay 0.5 | |
return | |
end if -- activeApp is "Google Chrome" - do pos size | |
-- end add fix s15 | |
tell application "System Events" | |
set position of window 1 of process activeApp to {item 1 of (item i of nameList), item 2 of (item i of nameList)} | |
delay 1 | |
set size of window 1 of process activeApp to {item 3 of (item i of nameList), item 4 of (item i of nameList)} | |
return | |
end tell | |
end if -- ActiveWinName is item 5 of (item i of nameList) | |
end if -- (item i of nameList) is not Replace_Me then | |
end repeat | |
set switch to 0 | |
if switch is 1 then | |
-- script: get name of active window + size and position | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
end tell | |
tell application "System Events" | |
tell process activeApp | |
set frontmost to true | |
set mywinName to get title of front window | |
end tell | |
end tell | |
-- add fix s15 | |
if activeApp is "Google Chrome" then | |
tell application "Google Chrome" | |
set Chrome_winName to get title of front window | |
end tell | |
tell application "System Events" | |
tell process "Google Chrome" | |
click (menu item "Minimize" of menu 1 of menu bar item "Window" of menu bar 1) | |
end tell | |
end tell | |
delay 2 | |
tell application "System Events" | |
set ppp to get position of window 1 of process activeApp | |
delay 0.03 | |
set sss to get size of window 1 of process activeApp | |
delay 0.02 | |
set pos1 to (item 1 of ppp) | |
set pos2 to (item 2 of ppp) | |
set siz1 to (item 1 of sss) | |
set siz2 to (item 2 of sss) | |
set WinNamePosSize to "{" & pos1 & ", " & pos2 & ", " & siz1 & ", " & siz2 & ", " & "\"" & Chrome_winName & "\"" & "}" | |
tell application "System Events" | |
tell process "Google Chrome" | |
set frontmost to true | |
delay 0.2 | |
click (menu item Chrome_winName of menu 1 of menu bar item "Window" of menu bar 1) | |
end tell | |
end tell | |
delay 0.5 | |
set the clipboard to WinNamePosSize | |
delay 0.5 | |
display dialog "Done!" with title "Get Name of Active Window + Size and Position of Window" | |
end tell | |
return | |
-- end add fix s15 | |
else -- activeApp is not "Google Chrome" | |
tell application "System Events" | |
set ppp to get position of window 1 of process activeApp | |
delay 0.03 | |
set sss to get size of window 1 of process activeApp | |
delay 0.02 | |
set pos1 to (item 1 of ppp) | |
set pos2 to (item 2 of ppp) | |
set siz1 to (item 1 of sss) | |
set siz2 to (item 2 of sss) | |
set WinNamePosSize to "{" & pos1 & ", " & pos2 & ", " & siz1 & ", " & siz2 & ", " & "\"" & mywinName & "\"" & "}" | |
delay 0.5 | |
set the clipboard to WinNamePosSize | |
delay 0.5 | |
display dialog "Done!" with title "Get Name of Active Window + Size and Position of Window" | |
end tell | |
end if -- activeApp is "Google Chrome" | |
-- end of script: get name of active window + size and position | |
end if -- switch is 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment