Sign in to follow this  
Followers 0
MrPinkComputerShrink

Problem displaying sorted columns on tab first click

4 posts in this topic

Hello,

This is sample code from a much larger project.

Problem is the Wifi tab does not display the data on first licke.

Problem 2: the app cant be closed when the wifi tab has attention

Problem 3: the data is not alway sortable without clicking back and forth.

Win 7 or 8   Wifi card enabled and a few network visible prefered.

Any help would be great!

Scott

#include <Array.au3>
#include <AVIConstants.au3>
#include <Constants.au3>
#include <Date.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <IE.au3>
#include <Process.au3>
#include <StaticConstants.au3>
#include <String.au3>
#include <TreeViewConstants.au3>
#include <ListViewConstants.au3>
#include <ColorConstants.au3>
#include <WinAPI.au3>
#include <Inet.au3>
#include <Services.au3>
#include <NetInfo.au3>
#include <WindowsConstants.au3>
#include <GuiImageList.au3>

DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1) ; This disables 32bit applications from being redirected to syswow64 instead of system32 by default ;


ConsoleWrite ("Loaded #include Files" & @CRLF)


Global $SSID, $BSSID, $Signal, $Authentication, $Encryption

GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
ConsoleWrite ("Created Variables" & @CRLF)


DirCreate (@TempDir & "\WifiExample")
$WifiTempDir=(@TempDir & "\WifiExample")
ConsoleWrite ("Created $WifiTempDir directory at " & $WifiTempDir & @CRLF)

Call ("_WifiNetsPrep")
Call ("_WifiNets")


$Gooey = GUICreate("Sortable Wifi Tab", 770, 540)

    $Tab=GUICtrlCreateTab(10, 0, 755, 530) ; -15 x -10

        $Tab1=GUICtrlCreateTabItem("Tab 1")  ;- ==========================================================================  Status
            GUISwitch($Gooey, $Tab1)
            $font = ("Lucida Console")
            GUISetFont(9, 400,1 , $font)
            GUICtrlCreateLabel("Data on Tab 1", 30, 60)  ; Label, Dist to right, Down
            GUICtrlCreateTabItem("")
            GUISwitch($Gooey)

        $Tab2=GUICtrlCreateTabItem("Tab 2")   ;- ==========================================================================  ARP/UPnP
            GUISwitch($Gooey, $Tab2)
            $font = ("Lucida Console")
            GUISetFont(9, 400,1 , $font)
            GUICtrlCreateLabel("Data on Tab 2", 30, 60)  ; Label, Dist to right, Down
            GUICtrlCreateTabItem("")
            GUISwitch($Gooey)

        $Tab3=GUICtrlCreateTabItem("Tab 3") ; =================================================================================== PINGS
            GUISwitch($Gooey, $Tab3)
            $font = ("MS Sans Serif")
            GUISetFont(9, 400,1 , $font)
            GUICtrlCreateLabel("Data on Tab 3", 30, 60)  ; Label, Dist to right, Down
            GUICtrlCreateTabItem("")
            GUISwitch($Gooey)

        $Tab4=GUICtrlCreateTabItem("Tab 4")  ;- ==========================================================================  :1400s
            GUISwitch($Gooey, $Tab4)
            $font = ("MS Sans Serif")
            GUISetFont(9, 400,1 , $font)
            GUICtrlCreateLabel("Data on Tab 4", 30, 60)  ; Label, Dist to right, Down
            GUICtrlCreateTabItem("")
            GUISwitch($Gooey)


        $Tab5=GUICtrlCreateTabItem("Wifi")  ;- ==========================================================================  Wifi Networks
            GUISwitch($Gooey, $Tab5)
            GUICtrlCreateTabItem("")
            GUISwitch($Gooey)

GUICtrlCreateTabItem("")

GUISetState()
While 1

        Switch GUICtrlRead($Tab)
            Case $Tab
            Case 0
                ;ConsoleWrite ("1st Tab  " & @CRLF  )  ; Status
            Case 1
                ;ConsoleWrite ("2nd Tab  " & @CRLF  )  ; ARP/UPnP
            Case 2
                ;ConsoleWrite ("3rd Tab  "& @CRLF  )    ; Pings
            Case 3
                ;ConsoleWrite ("4th Tab  " & @CRLF  )   ; 1400s
            Case 4
                GUISwitch($Gooey, $Tab5)
                ;ConsoleWrite ("5th Tab  " & @CRLF  )   ;Wifis
                Call ("_SortBy")
                ConsoleWrite("SortBy Return" & @CRLF)
                GUISwitch($Gooey)

            EndSwitch

    Switch GUIGetMsg()

            Case $GUI_EVENT_CLOSE
                ConsoleWrite ("Case $GUI_EVENT_CLOSE in main loop" & @CRLF)
            DirRemove($WifiTempDir)
            Exit

    EndSwitch



Wend

Func _WifiNetsPrep()
    Local $rc = _RunDos("netsh wlan show all > " & $WifiTempDir & "WifiData.txt")
    Global $WifiData2 = $WifiTempDir & "WifiData.txt"
    ConsoleWrite( "WIfiTab $$WifiData2  " & $WifiData2)
    Local $WifiNets=FileRead($WifiData2)
    FileOpen($WifiData2, 2)
    Local $Trim1 = StringInStr($WifiNets, "SSID 1")
    $WifiNets = StringTrimLeft ($WifiNets, $Trim1 - 6)
    FileWrite($WifiData2, $WifiNets)
    FileClose($WifiData2)
    $WifiNets=FileOpen($WifiData2, 1)
    FileWriteLine ($WifiNets, "END")
    FileClose ($WifiNets)
EndFunc

Func _WifiNets()
    ConsoleWrite("Called _WifiNets()" & @CRLF)
    $WifiNets=FileOpen($WifiData2, 0)
    Local $WifiNetsParsed=FileOpen ($WifiTempDir & "WifiNetsParsed.txt", 2)

    Do
        Local $WifiNetLine = FileReadLine($WifiNets)

        Local $SSIDCheck = StringInStr ($WifiNetLine, "SSID")
        If $SSIDCheck <> 0 then FileWriteLine ($WifiNetsParsed, $WifiNetLine)


        Local $AuthenticationCheck = StringInStr ($WifiNetLine, "Authentication")
        If $AuthenticationCheck <> 0 then FileWriteLine ($WifiNetsParsed, $WifiNetLine)


        Local $EncryptionCheck = StringInStr ($WifiNetLine, "Encryption")
        If $EncryptionCheck <> 0 then FileWriteLine ($WifiNetsParsed, $WifiNetLine)


        Local $SignalCheck = StringInStr ($WifiNetLine, "Signal")
        If $SignalCheck <> 0 then FileWriteLine ($WifiNetsParsed, $WifiNetLine)

        Local $ChannelCheck = StringInStr ($WifiNetLine, "Channel")
        If $ChannelCheck <> 0 then FileWriteLine ($WifiNetsParsed, $WifiNetLine)
        If $ChannelCheck <> 0 then FileWriteLine ($WifiNetsParsed, " ")

    Until $WifiNetLine = "END"

    FileClose ("$WifiData2")
    FileWriteLine ($WifiNetsParsed, "END")
    FileClose ($WifiNetsParsed)
    $font = ("MS Sans Serif")
    GUISetFont(9, 400,1 , $font)
    Local $iListView = GUICtrlCreateListView("Detected Wifi Networks                                            ", 30, 90, 725, 430)
             _GUICtrlListView_SetColumnWidth($iListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
            $WifiNetsParsed=FileOpen ($WifiTempDir & "WifiNetsParsed.txt", 0)

            Do
                $WifiNets = FileReadLine($WifiNetsParsed)

                GUICtrlCreateListViewItem($WifiNets,$iListView)
            Until $WifiNets = "END"

EndFunc

Func _SortBy()  ;  Wifi data sort

    ConsoleWrite ("Called SortBy" & @CRLF)
    Global $g_idListView
    Local $hImage, $aIcons[3] = [0, 3, 6]
    Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)
    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)

    GUISwitch($Gooey, $Tab5)

    $g_idListView = GUICtrlCreateListView("SSID|BSSID|Channel|Signal|Authentication|Encryption", 20, 25, 730, 500, -1, $iExWindowStyle)  ;28, 25, 725, 500

    _GUICtrlListView_SetExtendedListViewStyle($g_idListView, $iExListViewStyle)

    $WifiNets=FileOpen($WifiData2, 0)

    Do
        Global $WifiNetLine = FileReadLine($WifiNets)
        Global $SSIDCheck = StringInStr ($WifiNetLine, "SSID")
        Global $AuthenticationCheck = StringInStr ($WifiNetLine, "Authentication")
        Global $EncryptionCheck = StringInStr ($WifiNetLine, "Encryption")
        Global $BSSIDCheck = StringInStr ($WifiNetLine, "BSSID")
        Global $SignalCheck = StringInStr ($WifiNetLine, "Signal")
        Global $ChannelCheck = StringInStr ($WifiNetLine, "Channel")
        If $SSIDCheck <> 0 and $BSSIDCheck = 0 Then Call ("_SSIDTrimmer")
        If $SSIDCheck <> 0 and $BSSIDCheck <> 0 Then Call ("_BSSIDTrimmer")
        If $AuthenticationCheck <> 0 then Call ("_AuthenticationTrimmer")
        If $EncryptionCheck <> 0 then Call ("_EncryptionTrimmer")
        If $SignalCheck <> 0 then Call ("_SignalTrimmer")
        If $ChannelCheck <> 0 then Call ("_ChannelTrimmer")

    Until $WifiNetLine = "END"

    GUISetState(@SW_SHOW)

    _GUICtrlListView_RegisterSortCallBack($g_idListView)
    Local $count = 0
    While 1

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $g_idListView
                ; Kick off the sort callback
                _GUICtrlListView_SortItems($g_idListView, GUICtrlGetState($g_idListView))
        EndSwitch
         Switch GUICtrlRead($Tab)

                Case $Tab                                            ;  Keeps the Wifi in this loop and out of mian loop until it losses Exit

                Case 0
                    ExitLoop
                Case 1
                    ExitLoop
                Case 2
                    ExitLoop
                Case 3
                    ExitLoop
                Case 5
                    ExitLoop
                ConsoleWrite( "$Tab in Wifi loop = " & $Tab & @CRLF)
            Exit
        EndSwitch
    WEnd

    _GUICtrlListView_UnRegisterSortCallBack($g_idListView)
    GUICtrlCreateTabItem("")
EndFunc   ;==>Example

Func _SSIDTrimmer()
    ;ConsoleWrite( @ScriptLineNumber & " Called _SSIDTrimmer()" & @CRLF)
    ;msgbox (0, "Func _SSIDTrimmer()", "We're Here Now")
    Local $Colon = StringInStr ($WifiNetLine, ":")
    $SSID = StringTrimLeft ($WifiNetLine, $Colon)
    ;Local $BSSID_WAP = 0
    ;msgbox (0, "$SSID ", $SSID)
EndFunc

Func _BSSIDTrimmer()
    ;ConsoleWrite( @ScriptLineNumber & " Called _BSSIDTrimmer()" & @CRLF)
    ;msgbox (0, "Func _BSSIDTrimmer()", "We're Here Now")
    Local $Colon = StringInStr ($WifiNetLine, ":")
    $BSSID = StringTrimLeft ($WifiNetLine, $Colon)
    ;Local $BSSID_WAP = 1
    ;msgbox (0, "$BSSID ", $BSSID)
EndFunc

Func _AuthenticationTrimmer()
    ;msgbox (0, "_SignalTrimmer()", "We're Here Now")
    Local $Colon = StringInStr ($WifiNetLine, ":")
    $Authentication = StringTrimLeft ($WifiNetLine, $Colon)
    ;msgbox (0, "$Authentication ", $Authentication)
EndFunc

Func _EncryptionTrimmer()
    ;msgbox (0, "_SignalTrimmer()", "We're Here Now")
    Local $Colon = StringInStr ($WifiNetLine, ":")
    $Encryption = StringTrimLeft ($WifiNetLine, $Colon)
    ;msgbox (0, "$Encryption ", $Encryption)
EndFunc

Func _SignalTrimmer()
    ;msgbox (0, "_SignalTrimmer()", "We're Here Now")
    Local $Colon = StringInStr ($WifiNetLine, ":")
    $Signal = StringTrimLeft ($WifiNetLine, $Colon)
    ;msgbox (0, "$Signal ", $Signal)
EndFunc

Func _ChannelTrimmer()
    ConsoleWrite( @ScriptLineNumber & " Called _ChannelTrimmer" & @CRLF)
    Local $Colon = StringInStr ($WifiNetLine, ":")
    $Channel = StringTrimLeft ($WifiNetLine, $Colon)
    $bChannel = Number ($Channel)
    ;msgbox (0, "$bChannel ", $bChannel)

    _AddRow($g_idListView, $SSID & "|" & $BSSID & "|" & $bChannel & "|" & $Signal  & "|" & $Authentication & "|" & $Encryption  )  ; Passing Data to AddRow
    ;$SSID = ""
    $BSSID = ""
    $Authentication = ""
    $Encryption = ""
    $Channel = ""
    $Signal = ""
EndFunc

Func _AddRow($hWnd, $sItem, $iPlus = 0)
                        ConsoleWrite( @ScriptLineNumber & " Called _AddRow" & @CRLF)
    Local $aItem = StringSplit($sItem, "|")
    Local $iIndex = _GUICtrlListView_AddItem($hWnd, $aItem[1], + $iPlus, _GUICtrlListView_GetItemCount($hWnd) + 9999)
    _GUICtrlListView_SetColumnWidth($hWnd, 0, $LVSCW_AUTOSIZE_USEHEADER)

    For $x = 2 To $aItem[0]
        _GUICtrlListView_AddSubItem($hWnd, $iIndex, $aItem[$x], $x - 1, $iPlus)
        _GUICtrlListView_SetColumnWidth($hWnd, $x - 1, $LVSCW_AUTOSIZE)
    Next
    ConsoleWrite( @ScriptLineNumber & " Return from _AddRow" & @CRLF)
EndFunc   ;==>_AddRow



Func _CleanUp()

    FileClose ($WifiTempDir & "WifiNetsParsed.txt")
    FileClose ($WifiTempDir & "WifiChannel.txt")

    Sleep(500)

    FileDelete ($WifiTempDir & "WifiNetsParsed.txt")
    FileDelete ($WifiTempDir & "WifiChannel.txt")

EndFunc

Share this post


Link to post
Share on other sites



Please let me know if you have trouble opening the application due to missing include files.

Share this post


Link to post
Share on other sites

I've taken your script and modified it to work the way I think you want it to. You have FAR too many usages of GUISwitch and GUICtrlCreateTabItem(""). The latter only needs to be used once when you're done creating ALL the tabs. The former only needs to be used when you want to create a control in a tab that isn't active or not the last one created.

#include <Array.au3>
#include <AVIConstants.au3>
#include <Constants.au3>
#include <Date.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <IE.au3>
#include <Process.au3>
#include <StaticConstants.au3>
#include <String.au3>
#include <TreeViewConstants.au3>
#include <ListViewConstants.au3>
#include <ColorConstants.au3>
#include <WinAPI.au3>
#include <Inet.au3>
;~ #include <Services.au3>
;~ #include <NetInfo.au3>
#include <WindowsConstants.au3>
#include <GuiImageList.au3>
Global $g_idListView = 99999
DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1) ; This disables 32bit applications from being redirected to syswow64 instead of system32 by default ;


ConsoleWrite("Loaded #include Files" & @CRLF)


Global $SSID, $BSSID, $Signal, $Authentication, $Encryption

GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
ConsoleWrite("Created Variables" & @CRLF)


DirCreate(@TempDir & "\WifiExample")
$WifiTempDir = (@TempDir & "\WifiExample")
ConsoleWrite("Created $WifiTempDir directory at " & $WifiTempDir & @CRLF)

Call("_WifiNetsPrep")
Call("_WifiNets")


$Gooey = GUICreate("Sortable Wifi Tab", 770, 540)

$Tab = GUICtrlCreateTab(10, 0, 755, 530) ; -15 x -10

$Tab1 = GUICtrlCreateTabItem("Tab 1") ;- ==========================================================================  Status
;~ GUISwitch($Gooey, $Tab1)
$font = ("Lucida Console")
GUISetFont(9, 400, 1, $font)
GUICtrlCreateLabel("Data on Tab 1", 30, 60) ; Label, Dist to right, Down
;~ GUICtrlCreateTabItem("")
;~ GUISwitch($Gooey)

$Tab2 = GUICtrlCreateTabItem("Tab 2") ;- ==========================================================================  ARP/UPnP
;~ GUISwitch($Gooey, $Tab2)
$font = ("Lucida Console")
GUISetFont(9, 400, 1, $font)
GUICtrlCreateLabel("Data on Tab 2", 30, 60) ; Label, Dist to right, Down
;~ GUICtrlCreateTabItem("")
;~ GUISwitch($Gooey)

$Tab3 = GUICtrlCreateTabItem("Tab 3") ; =================================================================================== PINGS
;~ GUISwitch($Gooey, $Tab3)
$font = ("MS Sans Serif")
GUISetFont(9, 400, 1, $font)
GUICtrlCreateLabel("Data on Tab 3", 30, 60) ; Label, Dist to right, Down
;~ GUICtrlCreateTabItem("")
;~ GUISwitch($Gooey)

$Tab4 = GUICtrlCreateTabItem("Tab 4") ;- ==========================================================================  :1400s
;~ GUISwitch($Gooey, $Tab4)
$font = ("MS Sans Serif")
GUISetFont(9, 400, 1, $font)
GUICtrlCreateLabel("Data on Tab 4", 30, 60) ; Label, Dist to right, Down
;~ GUICtrlCreateTabItem("")
;~ GUISwitch($Gooey)

$Tab5 = GUICtrlCreateTabItem("Wifi") ;- ==========================================================================  Wifi Networks
;~ GUISwitch($Gooey, $Tab5)
;~ GUICtrlCreateTabItem("")
;~ GUISwitch($Gooey)

GUICtrlCreateTabItem("")
_BuildLV()

GUISetState()
While 1

;~  Switch GUICtrlRead($Tab)
;~      Case $Tab
;~      Case 0
;~          ;ConsoleWrite ("1st Tab  " & @CRLF  )  ; Status
;~      Case 1
;~          ;ConsoleWrite ("2nd Tab  " & @CRLF  )  ; ARP/UPnP
;~      Case 2
;~          ;ConsoleWrite ("3rd Tab  "& @CRLF  )    ; Pings
;~      Case 3
;~          ;ConsoleWrite ("4th Tab  " & @CRLF  )   ; 1400s
;~      Case 4
;~          GUISwitch($Gooey, $Tab5)
;~          ;ConsoleWrite ("5th Tab  " & @CRLF  )   ;Wifis
;~          Call("_SortBy")
;~          ConsoleWrite("SortBy Return" & @CRLF)
;~          GUISwitch($Gooey)

;~  EndSwitch

    Switch GUIGetMsg()
        Case $Tab
            Switch GUICtrlRead($Tab)
                Case $Tab
                Case 0
                    ;ConsoleWrite ("1st Tab  " & @CRLF  )  ; Status
                Case 1
                    ;ConsoleWrite ("2nd Tab  " & @CRLF  )  ; ARP/UPnP
                Case 2
                    ;ConsoleWrite ("3rd Tab  "& @CRLF  )    ; Pings
                Case 3
                    ;ConsoleWrite ("4th Tab  " & @CRLF  )   ; 1400s
                Case 4
;~                  GUISwitch($Gooey, $Tab5)
;~                  ;ConsoleWrite ("5th Tab  " & @CRLF  )   ;Wifis
;~                  Call("_SortBy")
;~                  ConsoleWrite("SortBy Return" & @CRLF)
;~                  GUISwitch($Gooey)

            EndSwitch

        Case $GUI_EVENT_CLOSE
            ConsoleWrite("Case $GUI_EVENT_CLOSE in main loop" & @CRLF)
            DirRemove($WifiTempDir)
            Exit
        Case $g_idListView
            _SortBy()
    EndSwitch



WEnd

Func _WifiNetsPrep()
    Local $rc = _RunDos("netsh wlan show all > " & $WifiTempDir & "WifiData.txt")
    Global $WifiData2 = $WifiTempDir & "WifiData.txt"
    ConsoleWrite("WIfiTab $$WifiData2  " & $WifiData2)
    Local $WifiNets = FileRead($WifiData2)
    FileOpen($WifiData2, 2)
    Local $Trim1 = StringInStr($WifiNets, "SSID 1")
    $WifiNets = StringTrimLeft($WifiNets, $Trim1 - 6)
    FileWrite($WifiData2, $WifiNets)
    FileClose($WifiData2)
    $WifiNets = FileOpen($WifiData2, 1)
    FileWriteLine($WifiNets, "END")
    FileClose($WifiNets)
EndFunc   ;==>_WifiNetsPrep

Func _WifiNets()
    ConsoleWrite("Called _WifiNets()" & @CRLF)
    $WifiNets = FileOpen($WifiData2, 0)
    Local $WifiNetsParsed = FileOpen($WifiTempDir & "WifiNetsParsed.txt", 2)

    Do
        Local $WifiNetLine = FileReadLine($WifiNets)

        Local $SSIDCheck = StringInStr($WifiNetLine, "SSID")
        If $SSIDCheck <> 0 Then FileWriteLine($WifiNetsParsed, $WifiNetLine)


        Local $AuthenticationCheck = StringInStr($WifiNetLine, "Authentication")
        If $AuthenticationCheck <> 0 Then FileWriteLine($WifiNetsParsed, $WifiNetLine)


        Local $EncryptionCheck = StringInStr($WifiNetLine, "Encryption")
        If $EncryptionCheck <> 0 Then FileWriteLine($WifiNetsParsed, $WifiNetLine)


        Local $SignalCheck = StringInStr($WifiNetLine, "Signal")
        If $SignalCheck <> 0 Then FileWriteLine($WifiNetsParsed, $WifiNetLine)

        Local $ChannelCheck = StringInStr($WifiNetLine, "Channel")
        If $ChannelCheck <> 0 Then FileWriteLine($WifiNetsParsed, $WifiNetLine)
        If $ChannelCheck <> 0 Then FileWriteLine($WifiNetsParsed, " ")

    Until $WifiNetLine = "END"

    FileClose("$WifiData2")
    FileWriteLine($WifiNetsParsed, "END")
    FileClose($WifiNetsParsed)
    $font = ("MS Sans Serif")
    GUISetFont(9, 400, 1, $font)
    Local $iListView = GUICtrlCreateListView("Detected Wifi Networks                                            ", 30, 90, 725, 430)
    _GUICtrlListView_SetColumnWidth($iListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
    $WifiNetsParsed = FileOpen($WifiTempDir & "WifiNetsParsed.txt", 0)

    Do
        $WifiNets = FileReadLine($WifiNetsParsed)

        GUICtrlCreateListViewItem($WifiNets, $iListView)
    Until $WifiNets = "END"

EndFunc   ;==>_WifiNets

Func _BuildLV() ;  Wifi data sort

    ConsoleWrite("Called SortBy" & @CRLF)
;~  Global $g_idListView
    Local $hImage, $aIcons[3] = [0, 3, 6]
    Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)
    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)

    GUISwitch($Gooey, $Tab5)

    $g_idListView = GUICtrlCreateListView("SSID|BSSID|Channel|Signal|Authentication|Encryption", 20, 25, 730, 500, -1, $iExWindowStyle) ;28, 25, 725, 500

    _GUICtrlListView_SetExtendedListViewStyle($g_idListView, $iExListViewStyle)

    $WifiNets = FileOpen($WifiData2, 0)

    Do
        Global $WifiNetLine = FileReadLine($WifiNets)
        Global $SSIDCheck = StringInStr($WifiNetLine, "SSID")
        Global $AuthenticationCheck = StringInStr($WifiNetLine, "Authentication")
        Global $EncryptionCheck = StringInStr($WifiNetLine, "Encryption")
        Global $BSSIDCheck = StringInStr($WifiNetLine, "BSSID")
        Global $SignalCheck = StringInStr($WifiNetLine, "Signal")
        Global $ChannelCheck = StringInStr($WifiNetLine, "Channel")
        If $SSIDCheck <> 0 And $BSSIDCheck = 0 Then Call("_SSIDTrimmer")
        If $SSIDCheck <> 0 And $BSSIDCheck <> 0 Then Call("_BSSIDTrimmer")
        If $AuthenticationCheck <> 0 Then Call("_AuthenticationTrimmer")
        If $EncryptionCheck <> 0 Then Call("_EncryptionTrimmer")
        If $SignalCheck <> 0 Then Call("_SignalTrimmer")
        If $ChannelCheck <> 0 Then Call("_ChannelTrimmer")

    Until $WifiNetLine = "END"

    GUISetState(@SW_SHOW)

    _GUICtrlListView_RegisterSortCallBack($g_idListView)
    Local $count = 0
;~  While 1

;~      Switch GUIGetMsg()
;~          Case $GUI_EVENT_CLOSE
;~              ExitLoop
;~          Case $g_idListView
;~              ; Kick off the sort callback
;~              _GUICtrlListView_SortItems($g_idListView, GUICtrlGetState($g_idListView))
;~      EndSwitch
;~      Switch GUICtrlRead($Tab)

;~          Case $Tab ;  Keeps the Wifi in this loop and out of mian loop until it losses Exit

;~          Case 0
;~              ExitLoop
;~          Case 1
;~              ExitLoop
;~          Case 2
;~              ExitLoop
;~          Case 3
;~              ExitLoop
;~          Case 5
;~              ExitLoop
;~              ConsoleWrite("$Tab in Wifi loop = " & $Tab & @CRLF)
;~              Exit
;~      EndSwitch
;~  WEnd

;~  _GUICtrlListView_UnRegisterSortCallBack($g_idListView)
;~  GUICtrlCreateTabItem("")
EndFunc   ;==>_BuildLV
Func _SortBy()
    $Column = GUICtrlGetState($g_idListView)
    _GUICtrlListView_SortItems($g_idListView, $Column)
EndFunc   ;==>_SortBy

Func _SSIDTrimmer()
    ;ConsoleWrite( @ScriptLineNumber & " Called _SSIDTrimmer()" & @CRLF)
    ;msgbox (0, "Func _SSIDTrimmer()", "We're Here Now")
    Local $Colon = StringInStr($WifiNetLine, ":")
    $SSID = StringTrimLeft($WifiNetLine, $Colon)
    ;Local $BSSID_WAP = 0
    ;msgbox (0, "$SSID ", $SSID)
EndFunc   ;==>_SSIDTrimmer

Func _BSSIDTrimmer()
    ;ConsoleWrite( @ScriptLineNumber & " Called _BSSIDTrimmer()" & @CRLF)
    ;msgbox (0, "Func _BSSIDTrimmer()", "We're Here Now")
    Local $Colon = StringInStr($WifiNetLine, ":")
    $BSSID = StringTrimLeft($WifiNetLine, $Colon)
    ;Local $BSSID_WAP = 1
    ;msgbox (0, "$BSSID ", $BSSID)
EndFunc   ;==>_BSSIDTrimmer

Func _AuthenticationTrimmer()
    ;msgbox (0, "_SignalTrimmer()", "We're Here Now")
    Local $Colon = StringInStr($WifiNetLine, ":")
    $Authentication = StringTrimLeft($WifiNetLine, $Colon)
    ;msgbox (0, "$Authentication ", $Authentication)
EndFunc   ;==>_AuthenticationTrimmer

Func _EncryptionTrimmer()
    ;msgbox (0, "_SignalTrimmer()", "We're Here Now")
    Local $Colon = StringInStr($WifiNetLine, ":")
    $Encryption = StringTrimLeft($WifiNetLine, $Colon)
    ;msgbox (0, "$Encryption ", $Encryption)
EndFunc   ;==>_EncryptionTrimmer

Func _SignalTrimmer()
    ;msgbox (0, "_SignalTrimmer()", "We're Here Now")
    Local $Colon = StringInStr($WifiNetLine, ":")
    $Signal = StringTrimLeft($WifiNetLine, $Colon)
    ;msgbox (0, "$Signal ", $Signal)
EndFunc   ;==>_SignalTrimmer

Func _ChannelTrimmer()
    ConsoleWrite(@ScriptLineNumber & " Called _ChannelTrimmer" & @CRLF)
    Local $Colon = StringInStr($WifiNetLine, ":")
    $Channel = StringTrimLeft($WifiNetLine, $Colon)
    $bChannel = Number($Channel)
    ;msgbox (0, "$bChannel ", $bChannel)

    _AddRow($g_idListView, $SSID & "|" & $BSSID & "|" & $bChannel & "|" & $Signal & "|" & $Authentication & "|" & $Encryption) ; Passing Data to AddRow
    ;$SSID = ""
    $BSSID = ""
    $Authentication = ""
    $Encryption = ""
    $Channel = ""
    $Signal = ""
EndFunc   ;==>_ChannelTrimmer

Func _AddRow($hWnd, $sItem, $iPlus = 0)
    ConsoleWrite(@ScriptLineNumber & " Called _AddRow" & @CRLF)
    Local $aItem = StringSplit($sItem, "|")
    Local $iIndex = _GUICtrlListView_AddItem($hWnd, $aItem[1], +$iPlus, _GUICtrlListView_GetItemCount($hWnd) + 9999)
    _GUICtrlListView_SetColumnWidth($hWnd, 0, $LVSCW_AUTOSIZE_USEHEADER)

    For $x = 2 To $aItem[0]
        _GUICtrlListView_AddSubItem($hWnd, $iIndex, $aItem[$x], $x - 1, $iPlus)
        _GUICtrlListView_SetColumnWidth($hWnd, $x - 1, $LVSCW_AUTOSIZE)
    Next
    ConsoleWrite(@ScriptLineNumber & " Return from _AddRow" & @CRLF)
EndFunc   ;==>_AddRow



Func _CleanUp()

    FileClose($WifiTempDir & "WifiNetsParsed.txt")
    FileClose($WifiTempDir & "WifiChannel.txt")

    Sleep(500)

    FileDelete($WifiTempDir & "WifiNetsParsed.txt")
    FileDelete($WifiTempDir & "WifiChannel.txt")

EndFunc   ;==>_CleanUp

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

It works perfectly. I will look over the code later when I have time. You are a life saver!  Thank you!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0