Created
October 2, 2018 13:05
-
-
Save thespacedoctor/e238a23dcdb82beb98de61e244ec2a60 to your computer and use it in GitHub Desktop.
[Get filepath of front window in any application] #filepath #applescript
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
| property pstrApp : "Typora" | |
| tell application "System Events" | |
| -- GET CURRENT FILEPATH FROM APP | |
| set lstProc to application processes where name contains pstrApp | |
| if lstProc is not equal to {} then | |
| try | |
| set winThoughts to front window of item 1 of lstProc | |
| on error | |
| return | |
| end try | |
| set strURL to value of (attribute "AXDocument" of winThoughts) | |
| set filepath to POSIX path of (POSIX file strURL as alias) | |
| return filepath | |
| end if | |
| end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment