Skip to content

Instantly share code, notes, and snippets.

@OKsign
Created August 1, 2018 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OKsign/47decaf33ac21b5d545864aac5c540f0 to your computer and use it in GitHub Desktop.
Save OKsign/47decaf33ac21b5d545864aac5c540f0 to your computer and use it in GitHub Desktop.
set Replace_Me to "abc"
-- user input (up to 10 names)
set nameList to {"", "", "", "", "", "", "", "", "", ""}
-- user input (up to 10)
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
tell application "System Events"
set activeApp to (get name of first process where it is frontmost)
end tell
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")
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
end if -- if switch is 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment