Snippets ( Wireless )

From AutoIt Wiki
Revision as of 06:56, 4 April 2012 by Chimaera (talk | contribs) (→‎_GetActiveSSID() ~ Author - guinness)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Please always credit an author in your script if you use their code, Its only polite.

_GetActiveSSID() ~ Author - guinness

#include <Constants.au3>

ConsoleWrite( _GetActiveSSID() & @CRLF)

Func _GetActiveSSID()
    Local $iPID = Run(@ComSpec & ' /u /c ' & 'netsh wlan show interfaces', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD), $sOutput = ''
    While 1
        $sOutput &= StdoutRead($iPID)
        If @error Then
            ExitLoop
        EndIf
        $sOutput = StringStripWS($sOutput, 7)
    WEnd

    $sReturn = StringRegExp($sOutput, '(?s)(?i)SSID\s*:\s(.*?)' & @CR, 3)
    If @error Then
        Return SetError(1, 0, '')
    EndIf
    Return $sReturn[0]
EndFunc   ;==>_GetActiveSSID