# The API move\_window\_to\_space is too ordinary,I mean it's so convenient, but not beautiful..... ;

**URL:** <https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017>\
**Category:** TotalSpaces\
**Created:** [December 3, 2014, 2:37pm UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017 "2014-12-03T14:37:01Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![duoer1982](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/duoer1982/32/32_2.png) [@duoer1982](https://discuss.binaryage.com/u/duoer1982)\
**Post date:** [December 3, 2014, 2:37pm UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/1 "2014-12-03T14:37:01Z")

</div>

It is so convenient to move window to other space with this API

But, I think it is too ordinary,yes, I mean it’s not beautiful… 😉 ;

Dear Stephen,  
Could you give us an amazed API, just like: A animation when the window moving to other space,  
for ex: slide window over other space

---

<div class="post-metadata">

**Author:** ![duoer1982](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/duoer1982/32/32_2.png) [@duoer1982](https://discuss.binaryage.com/u/duoer1982)\
**Post date:** [December 3, 2014, 2:39pm UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/2 "2014-12-03T14:39:41Z")

</div>

share my script , I use Alfred APP to run this script when press the hotkey F1

#!/usr/bin/ruby  
require 'totalspaces2’  
current\_space = TotalSpaces2.current\_space  
windows = TotalSpaces2.window\_list  
case current\_space  
when 1  
dest\_space = 2  
when 2  
dest\_space = 1  
when 3  
dest\_space = 4  
when 4  
dest\_space = 3  
else  
end  
if !windows.empty?  
current\_space\_windows = windows.select {  
|window| window[:space\_number] == current\_space  
}  
if current\_space\_windows[1]  
TotalSpaces2.move\_window\_to\_space(  
current\_space\_windows[0][:window\_id], dest\_space  
)  
TotalSpaces2.set\_front\_window(current\_space\_windows[1][:window\_id])  
elsif current\_space\_windows[0]  
TotalSpaces2.move\_window\_to\_space(  
current\_space\_windows[0][:window\_id], dest\_space  
)  
end  
end

---

<div class="post-metadata">

**Author:** ![duoer1982](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/duoer1982/32/32_2.png) [@duoer1982](https://discuss.binaryage.com/u/duoer1982)\
**Post date:** [December 10, 2014, 1:39pm UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/3 "2014-12-10T13:39:08Z")

</div>

Dear Stephen …

---

<div class="post-metadata">

**Author:** ![stephen](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/stephen/32/2286_2.png) [@stephen](https://discuss.binaryage.com/u/stephen)\
**Post date:** [December 11, 2014, 7:47pm UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/4 "2014-12-11T19:47:20Z")

</div>

Oh hi… I’m sorry I somehow missed your request.

I suppose there could be an API like move\_window\_and\_change\_to\_space that would do the same as when you move a window with the hotkey. Is that what you wish for?

---

<div class="post-metadata">

**Author:** ![duoer1982](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/duoer1982/32/32_2.png) [@duoer1982](https://discuss.binaryage.com/u/duoer1982)\
**Post date:** [December 12, 2014, 2:01pm UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/5 "2014-12-12T14:01:10Z")

</div>

No, I just want to move windows to other space without switching space at the same time;

for example: A message received when I am writing email, and I need to reply this message right now,  
and then I would throw away the msg window to other window after done this;

```
                It's COOL?
```

---

<div class="post-metadata">

**Author:** ![duoer1982](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/duoer1982/32/32_2.png) [@duoer1982](https://discuss.binaryage.com/u/duoer1982)\
**Post date:** [December 12, 2014, 2:09pm UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/6 "2014-12-12T14:09:43Z")

</div>

I wanna animation when the window moving to other space but not disappeared immediately when I press hotkey;

I wish the window sliding to other space when I press hotkey “F1”

---

<div class="post-metadata">

**Author:** ![duoer1982](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/duoer1982/32/32_2.png) [@duoer1982](https://discuss.binaryage.com/u/duoer1982)\
**Post date:** [December 12, 2014, 2:10pm UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/7 "2014-12-12T14:10:10Z")

</div>

#!/usr/bin/ruby  
require ‘totalspaces2’

current\_space = TotalSpaces2.current\_space  
windows = TotalSpaces2.window\_list  
if current\_space \< 4  
dest\_space = current\_space + 1  
else  
dest\_space = 1  
end

if !windows.empty?  
current\_space\_windows = windows.select {  
|window| window[:space\_number] == current\_space  
}  
if current\_space\_windows[0]  
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  
end  
end

---

<div class="post-metadata">

**Author:** ![stephen](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/stephen/32/2286_2.png) [@stephen](https://discuss.binaryage.com/u/stephen)\
**Post date:** [December 13, 2014, 9:55am UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/8 "2014-12-13T09:55:47Z")

</div>

Ok, that’s clear, thanks. I will think about it. Possibly the API could offer control of the position of the window, so you could do whatever animation you want yourself.

---

<div class="post-metadata">

**Author:** ![duoer1982](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/duoer1982/32/32_2.png) [@duoer1982](https://discuss.binaryage.com/u/duoer1982)\
**Post date:** [December 13, 2014, 1:27pm UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/9 "2014-12-13T13:27:04Z")

</div>

Oh，haha，Thank you!  
Could you give me a beta version ASAP, I could not wait to test the feature！

And I will parade this perfect feature to my friends!

---

<div class="post-metadata">

**Author:** ![duoer1982](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/duoer1982/32/32_2.png) [@duoer1982](https://discuss.binaryage.com/u/duoer1982)\
**Post date:** [December 19, 2014, 5:02am UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/10 "2014-12-19T05:02:17Z")

</div>

Dear Stephen，I am so sorry for bothering you every few days, but I think I can not wait, I am a fanatic fans of TS!

---

<div class="post-metadata">

**Author:** ![stephen](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/stephen/32/2286_2.png) [@stephen](https://discuss.binaryage.com/u/stephen)\
**Post date:** [December 19, 2014, 8:48am UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/11 "2014-12-19T08:48:51Z")

</div>

I’ll add it when I can, be a little patient! 🙂

---

<div class="post-metadata">

**Author:** ![duoer1982](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/duoer1982/32/32_2.png) [@duoer1982](https://discuss.binaryage.com/u/duoer1982)\
**Post date:** [December 27, 2014, 3:00pm UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/12 "2014-12-27T15:00:56Z")

</div>

My Dear Stephen！！！！！！！！！！！！！

---

<div class="post-metadata">

**Author:** ![stephen](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/stephen/32/2286_2.png) [@stephen](https://discuss.binaryage.com/u/stephen)\
**Post date:** [December 29, 2014, 2:09pm UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/13 "2014-12-29T14:09:25Z")

</div>

Sorry, busy with other priorities. I will get to your API change, please wait a little.

---

<div class="post-metadata">

**Author:** ![duoer1982](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/duoer1982/32/32_2.png) [@duoer1982](https://discuss.binaryage.com/u/duoer1982)\
**Post date:** [December 29, 2014, 11:50pm UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/14 "2014-12-29T23:50:06Z")

</div>

😄，TKS very much!

Could I try it before the new year?

---

<div class="post-metadata">

**Author:** ![stephen](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/stephen/32/2286_2.png) [@stephen](https://discuss.binaryage.com/u/stephen)\
**Post date:** [December 30, 2014, 10:44am UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/15 "2014-12-30T10:44:47Z")

</div>

Definitely before Chinese new year 🙂

---

<div class="post-metadata">

**Author:** ![duoer1982](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/duoer1982/32/32_2.png) [@duoer1982](https://discuss.binaryage.com/u/duoer1982)\
**Post date:** [December 30, 2014, 11:31pm UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/16 "2014-12-30T23:31:22Z")

</div>

Oh, it’s a long time! I need a surprise gift

---

<div class="post-metadata">

**Author:** ![duoer1982](https://discuss.binaryage.com/user_avatar/discuss.binaryage.com/duoer1982/32/32_2.png) [@duoer1982](https://discuss.binaryage.com/u/duoer1982)\
**Post date:** [January 16, 2015, 3:51pm UTC](https://discuss.binaryage.com/t/the-api-move-window-to-space-is-too-ordinary-i-mean-its-so-convenient-but-not-beautiful/3017/17 "2015-01-16T15:51:14Z")

</div>

require ‘totalspaces2’

current\_spaces = TotalSpaces2.current\_space  
windows = TotalSpaces2.window\_list  
if current\_spaces \< 4  
dest\_space = current\_spaces + 1  
else  
dest\_space = 1  
end

if !windows.empty?  
current\_space\_windows = windows.select {  
|window| window[:space\_number] == current\_spaces  
}  
end

if 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,10){|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  
2.times{TotalSpaces2.move\_window(  
current\_space\_windows[0][:window\_id],xpos, ypos)}  
end
