如果我打开了几个OS-X Terminal.app窗口,如何将一个终端窗口移动到另一个空间?
我很高兴使用任何脚本或编程语言来实现这一目标,但更喜欢AppleScript或调用标准框架。
(请注意,这只是移动应用程序not all windows的一个窗口。)
答案 0 :(得分:8)
在Objective-C / C中使用私人调用,非正式列出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:它们可能会中断。
答案 1 :(得分:1)
根据cobbal的回答,代码移植到ruby:
require 'dl';
wid = 2004
dl = DL::dlopen('/System/Library/Frameworks/ApplicationServices.framework/ApplicationServices')
_CGSDefaultConnection = dl.sym("_CGSDefaultConnection", 'I');
CGSMoveWorkspaceWindowList = dl.sym("CGSMoveWorkspaceWindowList", 'IIiII');
con = _CGSDefaultConnection.call();
CGSMoveWorkspaceWindowList.call(con[0], wid, 1, 4);