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 9: | Riga 9: | ||
Dim i As Integer | Dim i As Integer | ||
+ | Dim ob As Object | ||
For Each i In X11.GetWindowProperty(X11.RootWindow, "_NET_CLIENT_LIST") | For Each i In X11.GetWindowProperty(X11.RootWindow, "_NET_CLIENT_LIST") | ||
Riga 23: | Riga 24: | ||
" " & | " " & | ||
Format(X11.GetWindowProperty(i, "_NET_WM_PID")[0], "######") & " " | Format(X11.GetWindowProperty(i, "_NET_WM_PID")[0], "######") & " " | ||
− | + | ob = X11.GetWindowProperty(i, "_NET_WM_NAME") | |
+ | If Object.IsValid(ob) Then Write ob[0] | ||
Print | Print | ||
Versione delle 10:19, 21 apr 2021
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'in;dice) nel quale è aperta ' - il PID del programma alla quale appartiene; ' - il nome; Write "&h" & Hex(i, 8) & " " & Format(X11.GetWindowProperty(i, "_NET_WM_DESKTOP")[0], "-#") & " " & Format(X11.GetWindowProperty(i, "_NET_WM_PID")[0], "######") & " " ob = X11.GetWindowProperty(i, "_NET_WM_NAME") If Object.IsValid(ob) Then Write ob[0] Print Next End