Chinaunix首页 | 论坛 | 博客
  • 博客访问: 304802
  • 博文数量: 69
  • 博客积分: 1626
  • 博客等级: 上尉
  • 技术积分: 785
  • 用 户 组: 普通用户
  • 注册时间: 2007-01-15 19:01
文章分类

全部博文(69)

文章存档

2015年(4)

2014年(4)

2013年(3)

2012年(6)

2011年(1)

2010年(16)

2009年(8)

2008年(18)

2007年(9)

我的朋友

分类: 其他平台

2014-03-01 19:12:53

he scripts I posted above are those I used for TotalSpaces. Here are them converted for TotalSpaces2.

Get current space:

#!/usr/bin/env ruby


require 'rubygems'

require 'totalspaces2'


current_space = TotalSpaces2.current_space

puts "#{current_space}"

Switch to space:

#!/usr/bin/env ruby


require 'rubygems'

require 'appscript'

require 'totalspaces2'


kme = Appscript.app('Keyboard Maestro Engine')

dest_space = kme.variables["spaces_dest"].value.get.to_i


TotalSpaces2.move_to_space(dest_space)

Move front window to space (move the front window to the space whose number is in Keyboard Maestro's variable spaces_dest, and switch to that space):

#!/usr/bin/env ruby


require 'rubygems'

require 'appscript'

require 'totalspaces2'


kme = Appscript.app('Keyboard Maestro Engine')

dest_space = kme.variables["spaces_dest"].value.get.to_i

current_space = TotalSpaces2.current_space

windows = TotalSpaces2.window_list


if !windows.empty?

        current_space_windows = windows.select {

|window| window[:space_number] == current_space

}

        front_window = current_space_windows[0]

        TotalSpaces2.move_window_to_space(

front_window[:window_id], dest_space

)

end


TotalSpaces2.move_to_space(dest_space)

Send front window to space (send the front window to the space whose number is in Keyboard Maestro's variable spaces_dest, but don't switch to that space):

#!/usr/bin/env ruby


require 'rubygems'

require 'appscript'

require 'totalspaces2'


kme = Appscript.app('Keyboard Maestro Engine')

dest_space = kme.variables["spaces_dest"].value.get.to_i

current_space = TotalSpaces2.current_space

windows = TotalSpaces2.window_list


if !windows.empty?

        current_space_windows = windows.select {

|window| window[:space_number] == current_space

}

        front_window = current_space_windows[0]

        TotalSpaces2.move_window_to_space(

front_window[:window_id], dest_space

)

end

Note that the only change in the first two is the addition of '2' in each occurrence of 'TotalSpace', and the only difference between the last two is the last line.

阅读(1027) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~