Differenze tra le versioni di "Individuare ID e nome delle finestre attive, nonché il PID dei loro programmi con le risorse del Componente gb.desktop.x11"
Da Gambas-it.org - Wikipedia.
Riga 19: | Riga 19: | ||
' ''- il nome;''</font> | ' ''- il nome;''</font> | ||
− | If TypeOf(X11.GetWindowProperty(i, "_NET_WM_DESKTOP")) <> gb. | + | If TypeOf(X11.GetWindowProperty(i, "_NET_WM_DESKTOP")) <> gb.Null Then |
Write "&h" & Hex(i, 8) & " " & | Write "&h" & Hex(i, 8) & " " & | ||
Format(X11.GetWindowProperty(i, "_NET_WM_DESKTOP")[0], "-#") & " " & | Format(X11.GetWindowProperty(i, "_NET_WM_DESKTOP")[0], "-#") & " " & |
Versione delle 16:28, 24 set 2023
Usando alcune risorse della Classe statica "X11" del Componente "gb.desktop.x11" è possibile ottenere di ciascuna finestra aperta:
- l'identificativo (ID);
- il desktop (numero d'indice) nel quale è aperta;
- il PID del programma alla quale essa appartiene;
- il nome della finestra.
Di seguito un possibile codice:
Public Sub Form_Open() Dim i As Integer Dim ob As Object For Each i In X11.GetWindowProperty(X11.RootWindow, "_NET_CLIENT_LIST") ' Di ciascuna finestra aperta mostra in console: ' - l'ID (in esadecimale); ' - il desktop (numero d'indice) nel quale è aperta; ' - il PID del programma alla quale appartiene; ' - il nome; If TypeOf(X11.GetWindowProperty(i, "_NET_WM_DESKTOP")) <> gb.Null Then Write "&h" & Hex(i, 8) & " " & Format(X11.GetWindowProperty(i, "_NET_WM_DESKTOP")[0], "-#") & " " & Format(X11.GetWindowProperty(i, "_NET_WM_PID")[0], "######") & " " Endif ' Potrebbero esserci finestre, come messaggi di errore dal sistema, che non posseggono nome, quindi lo verifica: ob = X11.GetWindowProperty(i, "_NET_WM_NAME") If Object.IsValid(ob) Then Write ob[0] Print Next End