如何以编程方式将一个 Terminal.app 窗口移动到另一个空间? [英] How can I programmatically move one Terminal.app window to another space?

查看:20
本文介绍了如何以编程方式将一个 Terminal.app 窗口移动到另一个空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我打开了多个 OS-X Terminal.app 窗口,如何将一个终端窗口移动到另一个空间?

If I have several OS-X Terminal.app windows open, how can I move one Terminal window to another space?

我很乐意使用任何脚本或编程语言来实现这一点,但更喜欢 AppleScript 或对标准框架的调用.

I'm happy to use any scripting or programming language to achieve this, but would prefer AppleScript or calls to standard frameworks.

(注意这只是移动应用程序的一个窗口不是所有窗口.)

(Note this is to move only one window of an application not all windows.)

推荐答案

在 Objective-C/C 中使用私有调用,非官方列出 这里

Using private calls in Objective-C/C, unofficially listed here

#import <Foundation/Foundation.h>

typedef int CGSConnection;
typedef int CGSWindow;

extern OSStatus CGSMoveWorkspaceWindowList(const CGSConnection connection,
                                       CGSWindow *wids,
                                       int count,
                                       int toWorkspace);
extern CGSConnection _CGSDefaultConnection(void);


int main(int argc, char **argv) {
    CGSConnection con = _CGSDefaultConnection();

    // replace 2004 with window number
    // see link for details on obtaining this number
    // 2004 just happened to be a window I had open to test with
    CGSWindow wids[] = {2004};

    // replace 4 with number of destination space
    CGSMoveWorkspaceWindowList(con, wids, 1, 4);

    return 0;
}

适用于未记录的 API 的标准警告:它们可能会被破坏.

Standard warnings apply about undocumented APIs: they are subject to breaking.

这篇关于如何以编程方式将一个 Terminal.app 窗口移动到另一个空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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