我怎么能编程1 Terminal.app窗口移动到另一个空间? [英] How can I programatically move one Terminal.app window to another space?

查看:374
本文介绍了我怎么能编程1 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?

我很高兴地使用任何脚本或编程语言来实现这一点,但将preFER的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.

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

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