Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- user input
- set SizePos to {227, 26, 741, 653}
- -- end of user input
- tell application "System Events"
- set activeApp to (get name of first process where it is frontmost)
- end tell
- 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 position of window 1 of process activeApp to {item 1 of SizePos, item 2 of SizePos}
- delay 0.03
- set size of window 1 of process activeApp to {item 3 of SizePos, item 4 of SizePos}
- 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
- display notification "Done!" with title "Script 25"
- return
- else
- tell application "System Events"
- set position of window 1 of process activeApp to {item 1 of SizePos, item 2 of SizePos}
- delay 0.03
- set size of window 1 of process activeApp to {item 3 of SizePos, item 4 of SizePos}
- delay 0.5
- display notification "Done!" with title "Script 25"
- return
- end tell
- end if -- activeApp is "Google Chrome"
- set switch to 0
- if switch is 1 then
- -- script: get size and position of active window
- tell application "System Events"
- set activeApp to (get name of first process where it is frontmost)
- end tell
- 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 PosSize to "{" & pos1 & ", " & pos2 & ", " & siz1 & ", " & siz2 & "}"
- 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 PosSize
- delay 0.5
- display dialog "Done!" with title "Get Size and Position of Active Window"
- end tell
- 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 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 Active Window"
- end tell
- end if -- activeApp is "Google Chrome"
- -- end of script: get size and position of window
- end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement