require 'totalspaces2'def alfred_move_windows(appname) wx = 0 wxy = 0 current_space = TotalSpaces2.current_space windowsall = TotalSpaces2.window_list if !windowsall.empty? no_current_windows = windowsall.select { |window| window[:space_number] != current_space } no_current_windows.each{|window| wx = wx + 1 if window[:app_name].downcase =~/#{appname}/ win_pra = (window[:frame].delete"\{\} ").split(',') xpos = win_pra[0].to_i ypos = win_pra[1].to_i off = (1920 - xpos) TotalSpaces2.move_window( window[:window_id],1920, ypos) TotalSpaces2.move_window_to_space( window[:window_id], current_space) 0.step(off,10){|n| TotalSpaces2.move_window( window[:window_id],1920-n,ypos) } if wxy == 0 wxy = wx - 1 TotalSpaces2.set_front_window(no_current_windows[wxy][:window_id]) wxy = nil end sleep 0.3 end } endend$LOAD_PATHalfred_move_windows("{query}")@@@@@@@@@@@@@@@@@@@@@@@@@@#!/usr/bin/rubyrequire 'totalspaces2'current_spaces = TotalSpaces2.current_spacewindows = TotalSpaces2.window_listif current_spaces dest_space = current_spaces + 1else dest_space = 1endif !windows.empty? current_space_windows = windows.select { |window| window[:space_number] == current_spaces }endif current_space_windows[0] win_pra = (current_space_windows[0][:frame].delete"\{\} ").split(',') xpos = win_pra[0].to_i ypos = win_pra[1].to_i off = (1920 - win_pra[0].to_i) 0.step(off,8){|n| TotalSpaces2.move_window( current_space_windows[0][:window_id],xpos+n,ypos) } TotalSpaces2.move_window_to_space( current_space_windows[0][:window_id],dest_space)if current_space_windows[1] TotalSpaces2.set_front_window(current_space_windows[1][:window_id])end TotalSpaces2.move_window( current_space_windows[0][:window_id],xpos, ypos)end 09-04 06:46