Is any way how to get active connected WiFi SSID name (or IP)?
THX
SSID name
Re: SSID name
It is helpful if you tell us your OS
Or do you want a solution for all OSs
Or do you want a solution for all OSs

Re: SSID name
I have tested the following example successfully on these operating systems:
Update: Flag #PB_Program_Hide added in RunProgram() as proposed by Lord. Thank you for your hint, Lord!
- Linux Mint 19.3 'Tricia' x64 with Cinnamon and PB 6.00 x64
- MacOS 11.7.4 'Big Sur' with PB 6.01 x64
- MacOS 13.2.1 'Ventura' with PB 6.00 x64
- Raspbian 11 'Bullseye' ARM 32-Bit with PB 6.00
- Windows 10 Home x64 22H2 with PB 6.00 x86
Code: Select all
EnableExplicit
Define SSID.S
Procedure.S GetSSID()
Protected SSID.S
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
Define WiFiInterface.I
Define WiFi.I
WiFi = CocoaMessage(0, 0, "CWWiFiClient sharedWiFiClient")
WiFiInterface = CocoaMessage(0, WiFi, "interface")
SSID = PeekS(CocoaMessage(0, CocoaMessage(0, WiFiInterface, "ssid"),
"UTF8String"), -1, #PB_UTF8)
CompilerCase #PB_OS_Linux
Define ConsoleCommand.I
Define Result.S
ConsoleCommand = RunProgram("iwgetid", "-r", "",
#PB_Program_Open | #PB_Program_Read | #PB_Program_Hide)
CompilerCase #PB_OS_Windows
Define ConsoleCommand.I
Define Result.S
ConsoleCommand = RunProgram("NetSh", "WLAN show profiles", "",
#PB_Program_Open | #PB_Program_Read)
CompilerEndSelect
CompilerIf #PB_Compiler_OS <> #PB_OS_MacOS
If ConsoleCommand = 0
MessageRequester("Error",
"Sorry, getting SSID failed!",
#PB_MessageRequester_Error)
ProcedureReturn ""
Else
While ProgramRunning(ConsoleCommand)
If AvailableProgramOutput(ConsoleCommand)
Result + ReadProgramString(ConsoleCommand)
EndIf
Wend
CloseProgram(ConsoleCommand)
EndIf
CompilerEndIf
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
SSID = Result
CompilerCase #PB_OS_Windows
SSID = Trim(StringField(Result, 3, ":"))
CompilerEndSelect
ProcedureReturn SSID
EndProcedure
SSID = GetSSID()
If SSID <> ""
MessageRequester("Info", "SSID: " + SSID, #PB_MessageRequester_Info)
EndIf
Update: Flag #PB_Program_Hide added in RunProgram() as proposed by Lord. Thank you for your hint, Lord!
Last edited by Shardik on Wed Mar 22, 2023 8:50 pm, edited 1 time in total.
Re: SSID name
Please add for windows version #PB_Program_Hide as flag to RunProgram().
This will prevent the console window to flash up.
But it's just a cosmetic thing.
This will prevent the console window to flash up.
But it's just a cosmetic thing.
