【问题标题】:Selecting a file in Xcode using Applescript使用 Applescript 在 Xcode 中选择文件
【发布时间】:2014-05-15 14:44:50
【问题描述】:

我想打开一个 Xcode 项目并使用 applescript 在项目导航器中选择 Xcode 项目 (.xcodeproj)。 我为Finder尝试了以下代码 sn-p 并且我能够选择文件。

tell application "Finder" to select file "README.txt" of folder "Image" of folder "Downloads" of home

我想在 Xcode 中做同样的事情。我尝试了以下 sn-ps,但我无法在 Xcode 项目导航器中选择文件。如何在 Xcode 中使用applescript 选择文件

tell application "Xcode"
open file "Users:xxxxx:Downloads:Project1:Project1.xcodeproj"
    tell application "System Events" to tell process "Xcode"
    select file "README.txt" of folder "Project1" of folder "Downloads" of home
    end tell
end tell 

 tell application "Xcode" to select file "README.txt" of folder "Project1" of folder "Downloads" of home

【问题讨论】:

    标签: ios xcode5 applescript


    【解决方案1】:

    让 Xcode 打开单个文件。然后您可以更新导航器窗格。这是代码(您可能需要调整文件路径和延迟间隔):

    tell application "Xcode"
        activate
        -- open project 
        open file "Users:xxxxxx:Downloads:Project1:"
        delay 0.2
        -- open individual file
        open file "Users:xxxxxx:Downloads:Project1:Project1:README.txt"
    end tell
    delay 0.1
    tell application "System Events"
        tell process "Xcode"
            -- Move focus to next area, the individual file
            keystroke "`" using {command down, option down}
            delay 0.1
            -- Reveal in Project Navigator
            keystroke "j" using {command down, shift down}
        end tell
    end tell
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-17
      • 1970-01-01
      • 1970-01-01
      • 2021-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多