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.

09-04 13:08