[Gtk-sharp-list] P/invoke to get window text

Tobias Kappé tobias.kappe at gmail.com
Sun Aug 23 15:16:34 EDT 2009


Hey there,

I don't think you'll have any luck getting a window title through
Gtk#. Using P/Invoke on libX11 is really your best option here. May I
suggest you look at some code I contributed to IronAHK's Linux layer a
while ago:

For the signatures:
  http://code.google.com/p/ironahk/source/browse/trunk/Rusty/Linux/PlatformInvokes.cs
For usage:
  http://code.google.com/p/ironahk/source/browse/trunk/Rusty/Linux/PoliteRegister.cs

You could connect to the server, query the window tree (XQueryTree)
and obtain the window title by P/Invoking XFetchName:
  http://tronche.com/gui/x/xlib/ICC/client-to-window-manager/XFetchName.html

Hoping this was somewhat helpful,

Tobias

2009/8/17, jimevan <Seattlewonderboy at hotmail.com>:
>
> I'm working on a GUI test automation project and I need to be able to get
> the
> caption or titlebar text of a window that I did not create, and indeed may
> not even be a window created by a managed code framework. On the Windows
> platform, I'd call the GetWindowText API. However, that API obviously
> doesn't exist on other operating systems. Absent a platform-independent way
> to accomplish this (and searches have been remarkably fruitless to find
> one), is there anything in the gtk# framework that might help me? I've
> thought about possibly using p/invoke to call the X11 API directly, but that
> seems awfully low-level. Any suggestions?
> --
> View this message in context:
> http://www.nabble.com/P-invoke-to-get-window-text-tp25006934p25006934.html
> Sent from the Mono - Gtk# mailing list archive at Nabble.com.
>
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>


-- 
Groeten,

Tobias


More information about the Gtk-sharp-list mailing list