[Gambas-user] New to Gambas - coding question how to find the active window on an Ubuntu 7.10 desktop

José Luis Redrejo jredrejo at ...626...
Sun Jan 20 19:32:05 CET 2008


2008/1/20, Khos <kim.hoskin at ...1073...>:
>
>
> Hi Jose,
>
> I emailed you direct but if there is anyone else who can provide input
> that
> would be great. Am I correct in thinking that your 2 lines of code:
> SHELL "xwininfo -name \"" & title & "\"| grep \"Window id\" " to result1
>   'result1=xwininfo: Window id: 0x3201eca "title"
>
> Will give me the active window's title on the Ubuntu desktop (any
> app/window)?


Only the first line, the second one is commented. It was just a comment for
me to remember the
returning value of xwininfo. Here you have an example of how it works if you
execute it in a terminal:

jose at ...1836...:~$ xwininfo -name "monitor - Gambas II"| grep "Window id"
xwininfo: Window id: 0x3c0000c "monitor - Gambas II"


Does xwininfo program give all the info(ID/Title etc) that the mouse is
> hovering over?
>


if you take a look to "man xwininfo" you will see that you have to pass it
the window name or the window id and it will return all the data about the
window. You can also use it just clicking on the selected window to get all
the information. The way I use it in this code is passing the window name to
get the window id, as the Embedder control needs the window id. I know the
window name because it's launched using shell from the same application.
Depending on your needs you have to choose between the different options to
use xwininfo.

Regards.
José L.



More information about the User mailing list