|
楼主 |
发表于 2011-4-12 08:05:34
|
显示全部楼层
回复 10# republican #include <Constants.au3>
;#NoTrayIcon
#include <GuiListView.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <array.au3>
Opt("GUIOnEventMode", 1)
DIM $x=0,$m=0
$GUI=GUICreate("Wireless Network Connection",820,400,-1,-1)
$Label_01=GUICtrlCreateLabel("Wireless Network Connection",10,20,800,40,0x01)
$Button_01=GUICtrlCreateButton("Refresh",10,370,150,20)
$Button_02=GUICtrlCreateButton("Exit",660,370,150,20)
$Lv=GUICtrlGetHandle(GUICtrlCreateListView("",10,50,800,315, BitOR($LVS_REPORT,$LVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE))
_GUICtrlListView_SetExtendedListViewStyle($Lv,BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT,$LVS_EX_SUBITEMIMAGES))
_GUICtrlListView_AddColumn($Lv, "", 20)
_GUICtrlListView_AddColumn($Lv, "SSID",90,2)
_GUICtrlListView_AddColumn($Lv, "Network type",100,2)
_GUICtrlListView_AddColumn($Lv, "Authentication",100,2)
_GUICtrlListView_AddColumn($Lv, "Encryption",90,2);
_GUICtrlListView_AddColumn($Lv, "BSSID",80,2)
_GUICtrlListView_AddColumn($Lv, "Signal",60,2)
_GUICtrlListView_AddColumn($Lv, "Radio type",95,2)
_GUICtrlListView_AddColumn($Lv, "Channel",80,2)
GUICtrlSetBkColor($Label_01, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($Button_01,"_Refresh")
GUICtrlSetOnEvent($Button_02,"_EXIT")
GUISetOnEvent($GUI_EVENT_CLOSE,"_EXIT")
GUISetOnEvent($GUI_EVENT_MINIMIZE,"_MINIMIZE")
GUISetOnEvent($GUI_EVENT_RESTORE,"_RESTORE")
GUISetState()
GUISetState(@SW_SHOW)
Func tt()
$foo = Run(@ComSpec & " /c " & "netsh wlan show networks mode=bssid", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($foo)
$line = StdoutRead($foo)
$a_Arr1=StringRegExp($line,"(?:SSID\s?\d+\s?:\s*)([\w.]+)",3)
$a_Arr2=StringRegExp($line,"(?:Authentication\s*:\s*)([\w.]+.*)",3)
$a_Arr3=StringRegExp($line,"(?:Encryption\s*:\s*)([\w.]+.*)",3)
$a_Arr4=StringRegExp($line,"(?:Network type\s*:\s*)([\w.]+)",3)
$a_Arr5=StringRegExp($line,"(?:Radio type\s*:\s*)([\w.]+)",3)
$a_Arr6=StringRegExp($line,"(?:Channel\s*:\s*)([\w.]+)",3)
$a_Arr7=StringRegExp($line,"(?:Signal\s*:\s*)([\w.]+\%)",3)
$a_Arr8=StringRegExp($line,"(?:BSSID\s?)([\d]+)",3)
for $i = 0 to UBound($a_Arr1) - 1
_GUICtrlListView_AddItem($Lv,$x+1,$x)
_GUICtrlListView_AddSubItem($Lv,$x,$a_Arr1[$i],1)
_GUICtrlListView_AddSubItem($Lv,$x,$a_Arr3[$i],4)
_GUICtrlListView_AddSubItem($Lv,$x,$a_Arr2[$i],3)
_GUICtrlListView_AddSubItem($Lv,$x,$a_Arr4[$i],2)
$x=$x+1
next
For $n=0 To UBound($a_Arr8) - 1
If $a_Arr8[$n] =2 And $a_Arr8[$n+1] <>3 Then
_GUICtrlListView_InsertItem($Lv,"",$n)
EndIf
If $a_Arr8[$n] =2 And $a_Arr8[$n+1] = 3 Then
_GUICtrlListView_InsertItem($Lv,"",$n)
_GUICtrlListView_InsertItem($Lv,"",$n+1)
EndIf
Next
for $j = 0 to UBound($a_Arr8) - 1
_GUICtrlListView_AddSubItem($Lv,$m,$a_Arr5[$j],7)
_GUICtrlListView_AddSubItem($Lv,$m,$a_Arr6[$j],8)
_GUICtrlListView_AddSubItem($Lv,$m,$a_Arr7[$j],6)
_GUICtrlListView_AddSubItem($Lv,$m,$a_Arr8[$j],5)
$m=$m+1
Next
EndFunc
While 1
sleep(10)
WEnd
func _EXIT()
Exit
EndFunc
func _MINIMIZE()
GUISetState(@SW_MINIMIZE)
EndFunc
func _RESTORE()
GUISetState(@SW_RESTORE)
EndFunc
func _Refresh()
;_GUICtrlListView_CancelEditLabel($Lv)
;Global Const $WM_SETREDRAW = 0xB
;_SendMessage($Lv,$WM_SETREDRAW,0,0)
;GUICtrlSendMsg($Lv, $LVM_DELETEALLITEMS, 0, 0)
;_GUICtrlListView_DeleteAllItems($Lv)
;_GUICtrlListView_RegisterSortCallBack($Lv)
;_GUICtrlListView_EndUpdate($Lv)
_GUICtrlListView_DeleteAllItems($Lv)
tt()
_GUICtrlListView_EndUpdate($Lv)
;tt()
;Next
EndFunc
贴上源码~~
代码里$Lv=GUICtrlGetHandle(GUICtrlCreateListView("",10,50,800,315, BitOR($LVS_REPORT,$LVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE))
不就是你说的~~ |
|