那是判断发现无线网卡,运行程序。
我测试用的,你可改或注消
测试环境:WIN764位,AutoIt3\autoit3_x6 ...
明白,但是我运行这个程序找到的是VM虚拟机的网卡而不是无线网卡呢 令狐大虾 发表于 2019-10-9 20:06
明白,但是我运行这个程序找到的是VM虚拟机的网卡而不是无线网卡呢
明天再回复,要睡觉了 本帖最后由 chzj589 于 2019-10-10 13:19 编辑
令狐大虾 发表于 2019-10-9 20:06
明白,但是我运行这个程序找到的是VM虚拟机的网卡而不是无线网卡呢
这样试试
#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)
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
chzj589 发表于 2019-10-10 09:45
这样试试
#AutoIt3Wrapper_UseX64 = n ;32位=n,64位=y
谢谢,这个是识别机子里面所有的网卡。达不到我标题的要求 令狐大虾 发表于 2019-10-10 15:26
谢谢,这个是识别机子里面所有的网卡。达不到我标题的要求
能识别无线网卡吗?在下拉组合框里第几行? 令狐大虾 发表于 2019-10-10 15:26
谢谢,这个是识别机子里面所有的网卡。达不到我标题的要求
这样再试试
#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)
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();获取网卡信息
$wxwk = 'Broadcom 802.11ac Network Adapter'
$wxwka =$wangka1
If $wxwka = $wxwk Then
GUICtrlSetColor($Combo1, 0x009900)
GUICtrlSetData($Input1, $lianjie1 & " =" & $wangka1)
GUICtrlSetColor($Input1, 0x009900)
RunWait("notepad.exe")
Else
GUICtrlSetData($Input1, $lianjie1 & " =" & $wangka1)
GUICtrlSetColor($Input1, 0x990000)
EndIf
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
好像运行不了啊,我测试了一下,不管是xp的还是win7的,总是错误。 syzeng 发表于 2019-10-10 20:14
好像运行不了啊,我测试了一下,不管是xp的还是win7的,总是错误。
执行文件试试看
chzj589 发表于 2019-10-10 17:38
这样再试试
#AutoIt3Wrapper_UseX64 = n ;32位=n,64位=y
下拉最后一项才是我的无线网卡
令狐大虾 发表于 2019-10-10 20:46
下拉最后一项才是我的无线网卡
把这个改一下
Func _wxwk();获取网卡信息
$wxwk = 'Realtek 8188GU Wireless LAN 802.11n USB NIC'
$wxwka = $wangka1
If $wxwka = $wxwk Then
GUICtrlSetColor($Combo1, 0x009900)
GUICtrlSetData($Input1, $lianjie1 & " =" & $wangka1)
GUICtrlSetColor($Input1, 0x009900)
RunWait("notepad.exe")
Else
GUICtrlSetData($Input1, $lianjie1 & " =" & $wangka1);"未发现无线网卡---" &
GUICtrlSetColor($Input1, 0x990000)
EndIf
EndFunc ;==>_wxwk chzj589 发表于 2019-10-10 20:57
把这个改一下
Func _wxwk();获取网卡信息
$wxwk = 'Realtek 8188GU Wireless LAN 802.11n USB...
运行后跳出
Local $colItems = ""
Local $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter")
If IsObj($colItems) Then
For $objItem In $colItems
If StringInStr($objItem.netconnectionID, "无线") Then ;如果连接中包含“无线”,认定有无线网卡,执行。。。。。。
MsgBox(0, 0, "找到无线网卡")
EndIf
Next
EndIf 令狐大虾 发表于 2019-10-10 21:20
运行后跳出
18楼就解决问题了,只是你没有点击下拉组合框里的内容。
把第20行改为:
ControlCommand($Form1, "", 'ComboBox1', "SetCurrentSelection", 3)
就能直接判断存在无线网卡 本帖最后由 令狐大虾 于 2019-10-11 20:22 编辑
raeast 发表于 2019-10-11 01:12
Local $colItems = ""
Local $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
$colItems =...
谢谢,简单易行!
我用的是win10,无线改为WLAN就可以了。不过for命令下好像不能用else就是检测不到则退出那样
chzj589 发表于 2019-10-11 07:15
18楼就解决问题了,只是你没有点击下拉组合框里的内容。
把第20行改为:
ControlCommand($Form1, "", ' ...
嗯,换后很完美显示出来了。
页:
1
[2]