Snippets ( Wireless ): Difference between revisions

From AutoIt Wiki
Jump to navigation Jump to search
 
m (Edited snippet to conform to template Snippet Header.)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<div class="center" style="width:auto; margin-left:auto; margin-right:auto;">'''Please always credit an author in your script if you use their code, Its only polite.'''</div>
__TOC__
===== <blockquote style="background-color:white; padding:1em; border:2px solid #8FBC8F">''' _GetActiveSSID() ~ Author - [http://www.autoitscript.com/forum/user/35302-guinness/ guinness] '''</blockquote> =====
[[category:Snippets]]
 
{{Snippet Credit Header}}
 
== _GetActiveSSID ==
 
{{Snippet Header
| AuthorURL = 35302-guinness
| AuthorName = guinness
}}


<syntaxhighlight lang="autoit">
<syntaxhighlight lang="autoit">

Latest revision as of 19:19, 16 November 2012


Please always credit an author in your script if you use their code. It is 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