[Gambas-user] Trouble with X11.GetWindowProperty()

Martin Fischer martin.fischer6 at web.de
Mon Sep 25 10:42:58 CEST 2023


> Excuse me, why don't you use the "Replace()" function ?
>
> Print Replace(X11.GetWindowProperty(winId, "WM_CLASS"), Chr(0), Space(4))
>

Hi Buddy,

you are absolutely right! I think I was so confused about the \0's
within the string that I started to think in bytes...

I replaced this complete procedure with this one:

------------------------------------------
Public Function GetWindowClass(winId As Integer) As WindowClass
     Dim wmClass As String = X11.GetWindowProperty(winId, "WM_CLASS")
     Dim classParts As String[] = Split(wmClass, Chr(0))
     Return New WindowClass([classParts[0], classParts[1]])
Catch
     Error.Raise(Subst("Could not get WM_CLASS for window &1: &2",
winId, Error.Text))
End
------------------------------------------

Thanks,
Martin


More information about the User mailing list