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

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

问题描述

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



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



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

解决方案

在Objective-C / C中使用私有调用, =http://www.cocoadev.com/index.pl?CoreGraphicsPrivate =nofollow noreferrer>此处

  #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();

//用窗口编号替换2004
//查看链接获取这个数字的详细信息
// 2004刚刚发生了一个窗口我打开测试
CGSWindow wids [] = {2004};

//用目标空间数替换4
CGSMoveWorkspaceWindowList(con,wids,1,4);

return 0;
}

标准警告适用于未记录的API: >

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

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.)

解决方案

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;
}

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

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

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