Xcode 4:我可以通过 AppleScript 获取当前活动文件的路径吗? [英] Xcode 4 : Can I get a path to the currently active file via AppleScript?

查看:31
本文介绍了Xcode 4:我可以通过 AppleScript 获取当前活动文件的路径吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个自定义的 xcode4 行为来使用 Perforce 检查当前的活动文件.我知道我可以编写一个自定义行为以在按下一个键时运行(例如,F1)我希望该自定义行为启动一个 AppleScript(或任何类型的脚本)来识别Xcode 中当前活动"的源文档,获取其路径,并尝试通过 Perforce 将其检出.

I am trying to write a custom xcode4 behavior to check out the current active file with Perforce. I know I can write a custom behavior to run when hit a key (e.g., F1) I'd like that custom behavior to launch an AppleScript (or any kind of script for that matter) that discerns the currently "active" source document in Xcode, get its path, and attempt to check it out via Perforce.

据我所知 AppleScript 是获取目标文档的最佳方式,因为它可以轻松导航 Xcode DOM.鉴于此,DOM 本身就是一个迷宫.

As far as I can tell AppleScript is the best way to get to the target document as it can navigate the Xcode DOM easily. Given that, the DOM itself is a maze.

这能做到吗?

推荐答案

是.

tell application "Xcode"
    set CurrentActiveDocument to document 1 whose name ends with (word -1 of (get name of   window 1))
    set WhatYouWant to path of CurrentActiveDocument
end tell

这篇关于Xcode 4:我可以通过 AppleScript 获取当前活动文件的路径吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆