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.
(Creata pagina con "Usando alcune risorse della Classe statica "X11" del Componente "gb.desktop.x11" è possibile ottenere di ciascuna finestra aperta: <BR> - l'identificativo (ID); <BR> - il des...") |
|||
(11 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 6: | Riga 6: | ||
Di seguito un possibile codice: | Di seguito un possibile codice: | ||
− | + | Public Sub Form_Open() | |
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") | ||
<FONT Color=gray>' ''Di ciascuna finestra aperta mostra in console:'' | <FONT Color=gray>' ''Di ciascuna finestra aperta mostra in console:'' | ||
− | ' ''- l 'ID (in esadecimale);'' | + | ' ''- l'ID (in esadecimale);'' |
− | ' ''- il desktop (numero d' | + | ' ''- il desktop (numero d'indice) nel quale è aperta''; |
' ''- il PID del programma alla quale appartiene;'' | ' ''- il PID del programma alla quale appartiene;'' | ||
− | ' ''- il nome;</font> | + | ' ''- il nome;''</font> |
− | + | 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 | |
− | " " | + | <FONT Color=gray>' ''Potrebbero esserci finestre, come messaggi di errore dal sistema, che non posseggono nome, quindi lo verifica:''</font> |
− | + | ob = X11.GetWindowProperty(i, "_NET_WM_NAME") | |
− | + | If Object.IsValid(ob) Then Write ob[0] | |
+ | |||
+ | Print | ||
+ | |||
+ | Next | ||
+ | |||
+ | End | ||
+ | oppure: | ||
+ | Public Sub Button1_Click() | ||
+ | |||
+ | Dim wid As Integer | ||
+ | Dim ob As Object | ||
+ | |||
+ | For Each wid In Desktop.FindWindow("*", Null, Null) <FONT Color=gray>' ''...oppure anche:'' '''(Null, Null, Null)'''</font> | ||
+ | <FONT Color=gray>' ''Ottiene il numero identificativo della finestra, presente sulla Scrivania, di ogni programma e il PID del processo del programma:''</font> | ||
+ | ob = X11.GetWindowProperty(wid, "_NET_WM_NAME") | ||
+ | If Object.IsValid(ob) Then | ||
+ | If IsNull(X11.GetWindowProperty(wid, "_NET_WM_NAME")[0]) Then Continue | ||
+ | Print Hex(wid), X11.GetWindowProperty(wid, "_NET_WM_PID")[0], ob[0] | ||
+ | Endif | ||
Next | Next | ||
− | + | ||
− | + | End | |
Versione attuale delle 19:09, 11 ott 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
oppure:
Public Sub Button1_Click() Dim wid As Integer Dim ob As Object For Each wid In Desktop.FindWindow("*", Null, Null) ' ...oppure anche: (Null, Null, Null) ' Ottiene il numero identificativo della finestra, presente sulla Scrivania, di ogni programma e il PID del processo del programma: ob = X11.GetWindowProperty(wid, "_NET_WM_NAME") If Object.IsValid(ob) Then If IsNull(X11.GetWindowProperty(wid, "_NET_WM_NAME")[0]) Then Continue Print Hex(wid), X11.GetWindowProperty(wid, "_NET_WM_PID")[0], ob[0] Endif Next End