Differenze tra le versioni di "Individuare ID e nome delle finestre attive con le risorse del Componente gb.desktop"
Da Gambas-it.org - Wikipedia.
Riga 42: | Riga 42: | ||
Dim dw As DesktopWindow | Dim dw As DesktopWindow | ||
− | For | + | For Each dw To Desktop.Windows |
− | With dw | + | With dw |
− | + | Print Hex(.Id), .Name, .VisibleName | |
− | Print Hex(.Id), .VisibleName | ||
End With | End With | ||
Next | Next |
Versione delle 16:24, 11 ott 2023
Se intendiamo conoscere il numero identificativo (ID) e il titolo di tutte le finestre presenti sul desktop, possiamo adottare il seguente codice con la Classe Desktop del Componente gb.desktop:
Public Sub Button1_Click() Dim b As Byte For b = 0 To Desktop.Windows.Count - 1 With Desktop.Windows[b] Print Hex(.Id, 8), .VisibleName End With Next End
oppure:
Public Sub Button1_Click() For Each i As Integer In Desktop.FindWindow(Null, Null, Null) With Desktop Print Hex(i), .Windows.FromHandle(i).VisibleName End With Next End
oppure:
Public Sub Button1_Click() Dim i As Integer For b As Byte = 0 To Desktop.FindWindow(Null, Null, Null).Max With Desktop i = .FindWindow(Null, Null, Null)[b] Print i, Hex(i, 8), .Windows.FromHandle(i).VisibleName End With Next End
Usando la combinazione della Classe Desktop del Componente gb.desktop e della Classe DesktopWindow del Componente gb.desktop.x11
Public Sub Button1_Click() Dim b As Byte Dim dw As DesktopWindow For Each dw To Desktop.Windows With dw Print Hex(.Id), .Name, .VisibleName End With Next End
o anche:
Public Sub Button1_Click() Dim wid As Integer Dim dw As DesktopWindow For Each wid In Desktop.FindWindow(Null, Null, Null) With dw = New DesktopWindow(wid) ' Vediamo di ciascuna finestra sia il numero dell'ID (in esadecimale) che il Nome: If Not IsNull(.VisibleName) Then Print Hex(.Id), .VisibleName End With Next End