首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Cocoa SplitView中嵌入外部应用程序

在Cocoa SplitView中嵌入外部应用程序
EN

Stack Overflow用户
提问于 2013-01-14 22:53:32
回答 1查看 147关注 0票数 1

我想有一个在Mac OS X下的应用程序,使我有Sublime文本2和终端(用于显示测试结果,运行grunt任务等)在同一个全屏窗口。我找不到有这种行为的应用程序,我想自己用可可拆分视图重现它。我想知道这是否可行,如果可行,我如何开始实施它

谢谢

EN

回答 1

Stack Overflow用户

发布于 2013-01-15 01:30:11

您不能从2个其他应用程序创建新应用程序。恐怕行不通。但是,您可以使用applescript轻松地根据需要定位这些窗口。

作为示例,我将使用Safari和Terminal作为我的两个应用程序。打开它们,并将它们放在屏幕上您希望它们出现的位置。我将每个窗口都打开得很大,并将它们并排放置。然后我运行这个applescript来获取它们的窗口大小和位置属性...

代码语言:javascript
复制
tell application "System Events"
    tell process "Safari"
        set safariSize to size of window 1
        set safariPosition to position of window 1
    end tell
    tell process "Terminal"
        set terminalSize to size of window 1
        set terminalPosition to position of window 1
    end tell
end tell
return {safariSize, safariPosition, terminalSize, terminalPosition}

然后,我将该脚本的结果复制/粘贴到该脚本的"theValues“变量中。现在,只要我愿意,我就可以运行这个脚本来重新创建这些窗口位置。

代码语言:javascript
复制
set theValues to {{1001, 1025}, {0, 22}, {613, 1024}, {1003, 22}}

tell application "Safari" to activate
tell application "Terminal" to activate

tell application "System Events"
    tell process "Safari"
        set size of window 1 to item 1 of theValues
        set position of window 1 to item 2 of theValues
    end tell
    tell process "Terminal"
        set size of window 1 to item 3 of theValues
        set position of window 1 to item 4 of theValues
    end tell
end tell

我希望这能有所帮助。祝好运。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14320740

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档