Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. -- user input
  2. set SizePos to {227, 26, 741, 653}
  3. -- end of user input
  4. tell application "System Events"
  5. set activeApp to (get name of first process where it is frontmost)
  6. end tell
  7. if activeApp is "Google Chrome" then
  8. tell application "Google Chrome"
  9. set Chrome_winName to get title of front window
  10. end tell
  11. tell application "System Events"
  12. tell process "Google Chrome"
  13. click (menu item "Minimize" of menu 1 of menu bar item "Window" of menu bar 1)
  14. end tell
  15. end tell
  16. delay 2
  17. tell application "System Events"
  18. set position of window 1 of process activeApp to {item 1 of SizePos, item 2 of SizePos}
  19. delay 0.03
  20. set size of window 1 of process activeApp to {item 3 of SizePos, item 4 of SizePos}
  21. end tell
  22. tell application "System Events"
  23. tell process "Google Chrome"
  24. set frontmost to true
  25. delay 0.2
  26. click (menu item Chrome_winName of menu 1 of menu bar item "Window" of menu bar 1)
  27. end tell
  28. end tell
  29. delay 0.5
  30. display notification "Done!" with title "Script 25"
  31. return
  32. else
  33. tell application "System Events"
  34. set position of window 1 of process activeApp to {item 1 of SizePos, item 2 of SizePos}
  35. delay 0.03
  36. set size of window 1 of process activeApp to {item 3 of SizePos, item 4 of SizePos}
  37. delay 0.5
  38. display notification "Done!" with title "Script 25"
  39. return
  40. end tell
  41.  
  42. end if -- activeApp is "Google Chrome"
  43. set switch to 0
  44. if switch is 1 then
  45. -- script: get size and position of active window
  46. tell application "System Events"
  47. set activeApp to (get name of first process where it is frontmost)
  48. end tell
  49.  
  50. if activeApp is "Google Chrome" then
  51. tell application "Google Chrome"
  52. set Chrome_winName to get title of front window
  53. end tell
  54. tell application "System Events"
  55. tell process "Google Chrome"
  56. click (menu item "Minimize" of menu 1 of menu bar item "Window" of menu bar 1)
  57. end tell
  58. end tell
  59. delay 2
  60. tell application "System Events"
  61. set ppp to get position of window 1 of process activeApp
  62. delay 0.03
  63. set sss to get size of window 1 of process activeApp
  64. delay 0.02
  65. set pos1 to (item 1 of ppp)
  66. set pos2 to (item 2 of ppp)
  67. set siz1 to (item 1 of sss)
  68. set siz2 to (item 2 of sss)
  69. set PosSize to "{" & pos1 & ", " & pos2 & ", " & siz1 & ", " & siz2 & "}"
  70. tell application "System Events"
  71. tell process "Google Chrome"
  72. set frontmost to true
  73. delay 0.2
  74. click (menu item Chrome_winName of menu 1 of menu bar item "Window" of menu bar 1)
  75. end tell
  76. end tell
  77. delay 0.5
  78. set the clipboard to PosSize
  79. delay 0.5
  80. display dialog "Done!" with title "Get Size and Position of Active Window"
  81. end tell
  82.  
  83. else -- activeApp is not "Google Chrome"
  84. tell application "System Events"
  85. set ppp to get position of window 1 of process activeApp
  86. delay 0.03
  87. set sss to get size of window 1 of process activeApp
  88. delay 0.02
  89. set pos1 to (item 1 of ppp)
  90. set pos2 to (item 2 of ppp)
  91. set siz1 to (item 1 of sss)
  92. set siz2 to (item 2 of sss)
  93. set PosSize to "{" & pos1 & ", " & pos2 & ", " & siz1 & ", " & siz2 & "}"
  94. delay 1
  95. set the clipboard to PosSize
  96. delay 0.5
  97. display dialog "Done!" with title "Get Size and Position of Active Window"
  98. end tell
  99. end if -- activeApp is "Google Chrome"
  100. -- end of script: get size and position of window
  101. end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement