# How to get all window list and take a window top

**URL:** <https://www.ruby-forum.com/t/how-to-get-all-window-list-and-take-a-window-top/199562>\
**Category:** Ruby-Gnome 2\
**Created:** [November 24, 2010, 6:09am UTC](https://www.ruby-forum.com/t/how-to-get-all-window-list-and-take-a-window-top/199562 "2010-11-24T06:09:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 24, 2010, 6:09am UTC](https://www.ruby-forum.com/t/how-to-get-all-window-list-and-take-a-window-top/199562/1 "2010-11-24T06:09:53Z")

</div>

I write a program.I want the program have only a instance.If the  
instance exist then take the window top.

How to do it?

–  
weiwufeng [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![blackspace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@blackspace](https://www.ruby-forum.com/u/blackspace)\
**Post date:** [November 24, 2010, 11:02am UTC](https://www.ruby-forum.com/t/how-to-get-all-window-list-and-take-a-window-top/199562/2 "2010-11-24T11:02:23Z")

</div>

On 24 November 2010 13:13, blackspace [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I write a program.I want the program have only a instance.If the instance exist  
> then take the window top.
> 
> How to do it?

I have seen it done this way:  
Write a small file containing the PID of the application. You usually  
write the file in /var/run

Check to see if the file exists when the application starts. If  
it doesn’t write the file and continue. If it exists read the file.  
Then send a signal to the PID using kill.

The application should catch the signal. If it gets the signal  
it should raise the window to the top.

Unfortunately I don’t have rdoc installed on this machine to find  
the correct calls to make in ruby. Hopefully you can use this  
information  
to find the answers.

You need:

```
  - the call to get the PID of the application
  - the way to send a signal to another application (the unix

```

command is kill)  
- the way to catch the signal  
- the way to raise the window to the top (it should be in the  
Ruby-Gnome  
documentation on the window object)

Hope that helps!

```
          MikeC

```

---

<div class="post-metadata">

**Author:** ![blackspace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@blackspace](https://www.ruby-forum.com/u/blackspace)\
**Post date:** [November 24, 2010, 11:59am UTC](https://www.ruby-forum.com/t/how-to-get-all-window-list-and-take-a-window-top/199562/3 "2010-11-24T11:59:00Z")

</div>

see GtkUnique
