I would like to write a small utility that moves a window from one space to another in OS X Lion. I don't care if the utility is written in AppleScript or Objective-C. What I can't seem to figure out is given a window, how can I move it to a different space. I've seen lots of helpful information in this thread, but nothing about how to actually move the window. If anybody has any thoughts or ideas, I'd appreciate hearing them. Thanks.
If you are using objective-c calls, then moving between spaces in 10.7 is actually the same as 10.6 except for one issue. Space ID's were index based in 10.6, but based on something else (not quite a GUID) in 10.7.
If you have a window already in the correct space, the solutions in this question will work (I'm using it in csshX). You can get the space ID with CGSGetWindowWorkspace, and then set it on another window using CGSMoveWorkspaceWindowList.
Now if you don't have the space id - e.g. you just want to move the window to the 2nd space - then I'm as stumped as you are. I'm looking for the linkage between the space id and the index number. (Will update this answer if I find it)
Finally, you mention the App Store in the comment above - this will not be suitable since the CGS* calls use undocumented private frameworks which will get you rejected.
kCGWindowWorkspace
changes between logins. –
Latchstring You will need to use a custom library, which can be found here http://macscripter.net/viewtopic.php?id=23453, however I'm not sure what kind of support it has in lion.
© 2022 - 2024 — McMap. All rights reserved.