Last active
August 29, 2015 14:10
-
-
Save othercat/1cd2b3c4b17c18f55efd to your computer and use it in GitHub Desktop.
Create a new window of Safari when staying in a new Space
This file contains hidden or 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 found to 0 | |
| set resolution_wide to 1440 | |
| tell application "System Events" | |
| repeat with i from 1 to (count of window of process "Safari") | |
| set bnds to bounds of window i of application "Safari" | |
| set wide to item 3 of bnds | |
| if wide < resolution_wide then | |
| set found to 1 | |
| end if | |
| end repeat | |
| set found to count of window of process "Safari" | |
| end tell | |
| tell application "Safari" | |
| if found is 0 then | |
| make new document | |
| else | |
| set miniaturized of windows to false | |
| end if | |
| activate | |
| end tell |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fix an issue that multiple monitors will cause window counting error. need to adjust the width of internal display manually