Xcode 4: can I get the path to the current active file through AppleScript?

I am trying to write xcode4 custom behavior to check the current active file with Perforce. I know that I can write custom behavior to trigger when a key is pressed (e.g. F1 ). I would like this user behavior to run AppleScript (or any kind of script, for that matter) that recognizes the current "active" "source document in Xcode, get its path and try to check it through Perforce.

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

Can this be done?

+6
source share
1 answer

Yes.

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 
+6
source

Source: https://habr.com/ru/post/914269/


All Articles