Created
August 2, 2018 14:11
-
-
Save OKsign/d28db21458401cedf7fa4fdd2729b236 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
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
end tell | |
delay 0.03 | |
set Replace_Me to "abc" | |
-- user input (up to 20) - based on active app name | |
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 | |
-- 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} | |
delay 0.03 | |
repeat with i from 1 to 20 | |
if (item i of nameList) is not Replace_Me then | |
if activeApp is item 5 of (item i of nameList) then | |
delay 0.02 | |
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 0.03 | |
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 | |
else | |
set GoList to 1 | |
end if -- activeApp is item 5 of (item i of nameList) | |
else | |
set GoList to 1 | |
exit repeat | |
end if -- (item i of nameList) is not Replace_Me | |
end repeat | |
if GoList is 1 then -- Choose from list | |
set Replace_Me to "abc" | |
-- user input (up to 10 names) - list | |
set nameList to {"", "", "", "", "", "", "", "", "", ""} | |
-- user input (up to 10) - list | |
set SizPos1 to Replace_Me | |
set SizPos2 to Replace_Me | |
set SizPos3 to Replace_Me | |
set SizPos4 to Replace_Me | |
set SizPos5 to Replace_Me | |
set SizPos6 to Replace_Me | |
set SizPos7 to Replace_Me | |
set SizPos8 to Replace_Me | |
set SizPos9 to Replace_Me | |
set SizPos10 to Replace_Me | |
-- end of user input | |
set nameList2 to {} | |
repeat with i from 1 to count nameList | |
if {nameList's item i} does not contain "" then | |
set nameList2's end to nameList's item i | |
end if | |
end repeat | |
delay 0.7 | |
set PickName to (choose from list nameList2 with prompt "Set Size and Position to..." with title "Script 14.1") | |
if PickName is not false then | |
delay 0.02 | |
if (item 1 of PickName) is (item 1 of nameList) then | |
tell application "System Events" | |
set position of window 1 of process activeApp to {item 1 of SizPos1, item 2 of SizPos1} | |
delay 0.03 | |
set size of window 1 of process activeApp to {item 3 of SizPos1, item 4 of SizPos1} | |
return | |
end tell | |
end if | |
if (item 1 of PickName) is (item 2 of nameList) then | |
tell application "System Events" | |
set position of window 1 of process activeApp to {item 1 of SizPos2, item 2 of SizPos2} | |
delay 0.03 | |
set size of window 1 of process activeApp to {item 3 of SizPos2, item 4 of SizPos2} | |
return | |
end tell | |
end if | |
if (item 1 of PickName) is (item 3 of nameList) then | |
tell application "System Events" | |
set position of window 1 of process activeApp to {item 1 of SizPos3, item 2 of SizPos3} | |
delay 0.03 | |
set size of window 1 of process activeApp to {item 3 of SizPos3, item 4 of SizPos3} | |
return | |
end tell | |
end if | |
if (item 1 of PickName) is (item 4 of nameList) then | |
tell application "System Events" | |
set position of window 1 of process activeApp to {item 1 of SizPos4, item 2 of SizPos4} | |
delay 0.03 | |
set size of window 1 of process activeApp to {item 3 of SizPos4, item 4 of SizPos4} | |
return | |
end tell | |
end if | |
if (item 1 of PickName) is (item 5 of nameList) then | |
tell application "System Events" | |
set position of window 1 of process activeApp to {item 1 of SizPos5, item 2 of SizPos5} | |
delay 0.03 | |
set size of window 1 of process activeApp to {item 3 of SizPos5, item 4 of SizPos5} | |
return | |
end tell | |
end if | |
if (item 1 of PickName) is (item 6 of nameList) then | |
tell application "System Events" | |
set position of window 1 of process activeApp to {item 1 of SizPos6, item 2 of SizPos6} | |
delay 0.03 | |
set size of window 1 of process activeApp to {item 3 of SizPos6, item 4 of SizPos6} | |
return | |
end tell | |
end if | |
if (item 1 of PickName) is (item 7 of nameList) then | |
tell application "System Events" | |
set position of window 1 of process activeApp to {item 1 of SizPos7, item 2 of SizPos7} | |
delay 0.03 | |
set size of window 1 of process activeApp to {item 3 of SizPos7, item 4 of SizPos7} | |
return | |
end tell | |
end if | |
if (item 1 of PickName) is (item 8 of nameList) then | |
tell application "System Events" | |
set position of window 1 of process activeApp to {item 1 of SizPos8, item 2 of SizPos8} | |
delay 0.03 | |
set size of window 1 of process activeApp to {item 3 of SizPos8, item 4 of SizPos8} | |
return | |
end tell | |
end if | |
if (item 1 of PickName) is (item 9 of nameList) then | |
tell application "System Events" | |
set position of window 1 of process activeApp to {item 1 of SizPos9, item 2 of SizPos9} | |
delay 0.03 | |
set size of window 1 of process activeApp to {item 3 of SizPos9, item 4 of SizPos9} | |
return | |
end tell | |
end if | |
if (item 1 of PickName) is (item 10 of nameList) then | |
tell application "System Events" | |
set position of window 1 of process activeApp to {item 1 of SizPos10, item 2 of SizPos10} | |
delay 0.03 | |
set size of window 1 of process activeApp to {item 3 of SizPos10, item 4 of SizPos10} | |
return | |
end tell | |
end if | |
end if -- PickName is not false | |
set switch to 0 | |
if switch is 1 then | |
-- script: get size and position of window | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
end tell | |
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 PosSize to "{" & pos1 & ", " & pos2 & ", " & siz1 & ", " & siz2 & "}" | |
delay 1 | |
set the clipboard to PosSize | |
delay 0.5 | |
display dialog "Done!" with title "Get Size and Position of Window" | |
end tell | |
-- end of script: get size and position of window | |
-- script: Get Active App Name + Size and Position of Window | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
end tell | |
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 AppPosSize to "{" & pos1 & ", " & pos2 & ", " & siz1 & ", " & siz2 & ", " & "\"" & activeApp & "\"" & "}" | |
delay 1 | |
set the clipboard to AppPosSize | |
delay 0.5 | |
display dialog "Done!" with title "Get Active App Name + Size and Position of Window" | |
end tell | |
-- end of script: Get Active App Name + Size and Position of Window | |
end if -- if switch is 1 | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment