OSX Lion AppleScript : How to get current space # from mission control?

前端 未结 7 1120
悲&欢浪女
悲&欢浪女 2020-12-07 11:09

I\'m trying to figure out how to get the current space # from mission control. Source would be helpful, but more helpful would be info on how to figure this out myself. I\

7条回答
  •  我在风中等你
    2020-12-07 11:56

    I've been poking around, and I came up with this: https://gist.github.com/1129406

    Spaces have a nonsequential ID and a sequential index (0-based). You can get the ID in two ways:

    • from public APIs (see get_space_id)
    • from the private CGS API CGSGetWorkspace

    You can set the current space by index using public APIs (though the notifications themselves are not publicly documented): see set_space_by_index

    You can set the current space by ID using private the CGS API CGSSetWorkspace.

    You cannot get the current space index directly. However, if you're always using the same set of nine spaces, you can rotate through them once using set_space_by_index, collect their IDs, and build a mapping. Then you will be able to get the current index from the ID.

提交回复
热议问题