A better way to find out if there is only one instance of a window is this:
[code]DestroyFunc WindowTest
AddToFunc WindowTest
I Next ($0) Next ($0) PipeRead “[ $$[w.id] = $$$$[w.id] ] && echo WindowListFunc || echo Popup MenuPlusieursFenetres”
I TestRc (NoMatch) Exec $1
WindowTest XTerm xterm[/code]
Note how the first $$[w.id] will expand after the first next, while $$$$[w.id] will expand after the second. If there only is one window matching it will be the same id in both cases.
I AddToMenu MultiWindowMenu %$[w.miniiconfile]%"$[w.class]: $[w.name]" WindowId $[w.id] WindowListFunc[/code]
I called this with for instance :
LookUpWindow Gvim gvim
This function popups a menu if there is at least one gvim or create one if not.
My only problem is that i have to click 3 times on the menus in order to close it (if i have 3 gvim). I have to click 10 times if i have 10 gvim…
How can i do to close the menu just when i click one time ?
For example : i have 4 aterm, i popup the menu, i choose one aterm by clicking on it and the menu closes.