Cocoa question: How to get file path for current open document for the front most application

南楼画角 提交于 2020-01-16 04:08:19

问题


I can get the front most application, how do I get the path for the front most document?


回答1:


There isn't a way to do this for any app. Apps don't always have documents. If an app supports the standard AppleScript document model, you can do it with AppleScript. For example,

tell application "TextEdit"

    set foo to the path of the first document

end tell


来源:https://stackoverflow.com/questions/5976152/cocoa-question-how-to-get-file-path-for-current-open-document-for-the-front-mos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!