Wait For (FindSSID) Complete (Result As String)
Log("SSID: " & Result)
Sub FindSSID As ResumableSub
Dim shl As Shell
shl.Initialize("shl", "cmd", Array("/c", "netsh", "wlan", "show", "networks"))
shl.Run(-1)
Wait For shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
If Success And ExitCode = 0 Then
Dim m As Matcher = Regex.Matcher2("SSID 1\s*:\s*(.*)$", Regex.MULTILINE, StdOut)
If m.Find Then
Return m.Group(1)
End If
End If
Return ""
End Sub
Wait For (FindSSID) Complete (Result As Map)
If Result.IsInitialized then
.......
End If
Sub FindSSID As ResumableSub
Dim shl As Shell
Dim ms As Map
shl.Initialize("shl", "cmd", Array("/c", "netsh", "wlan", "show", "networks"))
shl.Run(-1)
Wait For shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
If Success And ExitCode = 0 Then
ms.Initialize
Dim dati() As String = Regex.Split(CRLF, StdOut)
For i = 0 To dati.Length-1
Dim m As Matcher = Regex.Matcher("SSID \d*\s*:\s*(.*)$", dati(i))
If m.Find Then
ms.Put(m.Match.SubString2(0,m.Match.IndexOf(":")).Trim,m.Match.SubString(m.Match.IndexOf(":")+1).Trim)
End If
Next
End If
Return ms
End Sub
netsh wlan show profile name="NETWORK" key=clear
Sub FindWiFi
Wait For (FindSSID) Complete (Result As Map)
If Result.IsInitialized Then
For i = 0 To Result.Size-1
Dim m As Map = Result.Get(Result.GetKeyAt(i))
Log(Result.GetKeyAt(i))
Log(m.Get("name"))
Log(m.Get("autentication"))
Log(m.Get("signal"))
Log(m.Get("frequency"))
Log(m.Get("channel"))
Log("----------------")
Next
End If
End Sub
Sub FindSSID As ResumableSub
Dim shl As Shell
Dim ms, mdati As Map
shl.Initialize("shl", "cmd", Array("/c", "netsh", "wlan", "show", "networks", "mode=", "Bssid"))
shl.Run(-1)
Wait For shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
If Success And ExitCode = 0 Then
ms.Initialize
Dim dati() As String = Regex.Split(Chr(10) & Chr(13), StdOut)
For i = 0 To dati.Length-1
Dim subdati() As String = Regex.Split(CRLF, dati(i))
If subdati.Length>0 Then
If subdati(1).StartsWith("SSID ") Then
mdati.Initialize
mdati.Put("name", subdati(1).SubString(subdati(1).IndexOf(":")+1).Trim)
mdati.Put("autentication", subdati(3).SubString(subdati(3).IndexOf(":")+1).Trim)
mdati.Put("signal", subdati(6).SubString(subdati(6).IndexOf(":")+1).Trim)
mdati.Put("frequency", subdati(7).SubString(subdati(7).IndexOf(":")+1).Trim)
mdati.Put("channel", subdati(8).SubString(subdati(8).IndexOf(":")+1).Trim)
ms.Put(subdati(1).SubString2(0,subdati(1).IndexOf(":")).Trim,mdati)
End If
End If
Next
End If
Return ms
End Sub