Created
May 18, 2014 19:25
-
-
Save patrickwelker/dbc90c39659c4cdc8538 to your computer and use it in GitHub Desktop.
AppleScript for guessing the text editor you currently use. It's intended to be used in Keyboard Maestro. Read more here: http://rocketink.net/2014/05/upload-to-gist.html.
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 activeEditorsList to {} | |
| set appList to {"nvALT", "FoldingText", "Byword", "Mou", "Sublime Text", "MultiMarkdown Composer"} | |
| -- Generate variable with running apps | |
| tell application "System Events" | |
| set activeProcesses to (name of every process) | |
| end tell | |
| -- Generate list of running text editors | |
| repeat with appName in appList | |
| if appName is in activeProcesses then | |
| set end of activeEditorsList to appName | |
| end if | |
| end repeat | |
| --return activeEditorsList | |
| set editorCount to count activeEditorsList | |
| if editorCount = 1 then | |
| return item 1 of activeEditorsList as text | |
| else if editorCount > 1 then | |
| activate | |
| return choose from list activeEditorsList | |
| else | |
| return "cancel" | |
| end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment