本帖最后由 chzj589 于 2019-10-10 13:19 编辑
这样试试
#AutoIt3Wrapper_UseX64 = n ;32位=n,64位=y
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
Global $wangka1, $lianjie1
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1 (" & @ScriptName & ")", 515, 138, 192, 124)
$GLabel1 = GUICtrlCreateLabel("网卡 :", 50, 23, 40, 22)
GUICtrlSetFont(-1, 11, 400, 0, "微软雅黑")
GUICtrlSetColor(-1, 0x990000)
$Combo1 = GUICtrlCreateCombo("", 95, 20, 375, 17);, $WS_VSCROLL)
GUICtrlSetFont(-1, 11, 400, 0, "微软雅黑")
$Input1 = GUICtrlCreateLabel("", 8, 50, 415, 22);, $WS_VSCROLL)
GUICtrlSetFont(-1, 11, 400, 0, "微软雅黑")
WMI()
GUICtrlSetData($Combo1, _ArrayToString($wangka1, "|"), $wangka1[0])
GUICtrlSetColor($Combo1, 0xFF0000)
ControlCommand($Form1, "", 'ComboBox1', "SetCurrentSelection", 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_wxwk()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Combo1
_wxwk()
EndSwitch
WEnd
Func _wxwk();获取网卡信息
$sComboRead = GUICtrlRead($Combo1)
For $i = 0 To UBound($wangka1) - 1
If $sComboRead == $wangka1[$i] Then
;GUICtrlSetData($Input1, "" & $lianjie1[$i])
$wxwk = 'Broadcom 802.11ac Network Adapter'
If GUICtrlRead($Combo1) = $wxwk Then
GUICtrlSetColor($Combo1, 0x009900)
GUICtrlSetData($Input1, $lianjie1[$i] & " = " & $wangka1[$i])
GUICtrlSetColor($Input1, 0x009900)
RunWait("notepad.exe")
Else
GUICtrlSetData($Input1, $lianjie1[$i]&" = " &$wangka1[$i])
GUICtrlSetColor($Input1, 0x990000)
EndIf
EndIf
Next
EndFunc ;==>_wxwk
Func WMI()
Local $dnsa1
$sMesStr = ""
$oLocator = ObjCreate("WbemScripting.SWbemLocator")
$oService = $oLocator.ConnectServer
$oClassSet = $oService.ExecQuery("Select * From Win32_NetworkAdapter Where NetConnectionID IS NOT NULL")
For $oClass In $oClassSet
If @error Then ExitLoop
$sMesStr = $sMesStr & "连接名:“" & $oClass.NetConnectionID() & "”" & @CRLF & _
"网卡名: “" & $oClass.Name & "”" & @CRLF
Next
$wangka1 = 0
$lianjie1 = 0
$wangka1 = StringRegExp($sMesStr, "(?<=网卡名: “)[^”]+", 3)
$lianjie1 = StringRegExp($sMesStr, "(?<=连接名:“)[^”]+", 3)
EndFunc ;==>WMI
|