Last active
October 4, 2017 14:29
-
-
Save hectormethod/83a2a922b5a357696a191c45757394b9 to your computer and use it in GitHub Desktop.
[Applescript to make application window active] The toggling of the visibility is necessary to deal with some weirdness that occurs with switching applications. If you don't toggle the visibility, the window won't be the first when you switch away from and back to the application. Unfortunately, this toggling shrinks the window to the dock then …
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
| to raiseWindow of theApplicationName for theName | |
| tell the application named theApplicationName | |
| activate | |
| set theWindow to the first item of ¬ | |
| (get the windows whose name is theName) | |
| if index of theWindow is not 1 then | |
| set index to 1 | |
| set visible to false | |
| set visible to true | |
| end if | |
| end tell | |
| end raiseWindow |
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
| to raiseWindow2 of theApplicationName for theName | |
| tell the application named theApplicationName | |
| activate | |
| set theWindow to the first item of ¬ | |
| (get the windows whose name is theName) | |
| if the index of theWindow is not 1 then | |
| set the index of theWindow to 2 | |
| tell application "System Events" to ¬ | |
| tell application process theApplicationName to ¬ | |
| keystroke "`" using command down | |
| end if | |
| end tell | |
| end raiseWindow2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment