怎么让下拉菜单中显示出两块网卡?
我修改合成了个更改IP的软件
可以自动读取存储的MAC地址更改IP,
可是我不会做倒记时自动启动的按钮。
网卡如果有两块,也显示不出来,
可不可以选一个网卡改这个网卡的IP,
而不是网卡选择只是摆设啊
高手帮我看看代码错在哪里了?
或者有什么好的建议,谢谢
阿剑 QQ148798
#Region ;**** 参数创建于 AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=E:\down\ico\血战缅甸.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseAnsi=y
#AutoIt3Wrapper_Res_Comment=自动修改IP工具
#AutoIt3Wrapper_Res_Description=GHOST自动工具 阿剑制作 QQ:148798
#AutoIt3Wrapper_Res_Fileversion=0.0.0.1
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=GHOST自动工具 阿剑制作 QQ:148798
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Region AutoIt3Wrapper 编译参数
;#AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer% ;自定义资源段
;#AutoIt3Wrapper_Run_Tidy= ;脚本整理
;#AutoIt3Wrapper_Run_Obfuscator= ;代码迷惑
;#AutoIt3Wrapper_Run_AU3Check= ;语法检查
;#AutoIt3Wrapper_Run_Before= ;运行前
;#AutoIt3Wrapper_Run_After= ;运行后
#EndRegion AutoIt3Wrapper 编译参数设置完成
#cs ____________________________________
AutoIt 版本: 3.2.10.0(第一版)
脚本作者:
Email:
QQ/TM:
脚本版本:
脚本功能:
#ce _______________脚本开始_________________
#include <Array.au3>
#include <file.au3>
#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <IPAddressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiIPAddress.au3>
#include <Array.au3>
#include <Constants.au3>
#Include <GuiStatusBar.au3>
#include <GUIConstants.au3>
#include <Date.au3>
opt("TrayIconDebug",1)
Global $Secs, $Mins, $Hour, $Time
Dim $temp,$i=2
$ip_Z = "255.255.255.0"
$ip_D = "202.103.188.28"
$ip_D1 = "202.96.128.143"
$Gateway = "192.168.0.254"
if not _FileReadToArray("config.txt",$temp) Then
MsgBox(0,"错误","没有找到MAC地址对应表")
Exit
Else
endif
;;;********读取自己的MAC地址*********
RunWait(@ComSpec & " /c " & "IPCONFIG.EXE /all" & " > " & "IPINFO.TXT", @MyDocumentsDir, @SW_HIDE)
$file = FileOpen(@MyDocumentsDir&"\IPINFO.TXT", 0)
$line = FileReadLine($file,27)
$mac = stringmid($line, 45)
;MsgBox(0,"",$mac)
FileClose($file)
RunWait(@ComSpec & " /c " & "DEL.EXE IPINFO.TXT", @MyDocumentsDir, @SW_HIDE)
;;;********在MAC表中找有没有自己*******
$file1 = FileOpen("config.txt", 0)
while 1
$line3 = FileReadLine($file1,$i)
$result = StringInStr($line3, $mac)
$i=$i+1
if $result<>"" then
ExitLoop
Elseif $i>$temp[0] then
MsgBox(0,"错误","表中没有本机MAC地址数据")
endif
wend
;;;******读取MAC表中数据******
$line4 = FileReadLine($file1,$i-1)
$ip_I = stringmid($line4, 28)
;MsgBox(0,"",$ip_I)
$name = stringmid($line4, 20,6);;;这里面的5是计算机名的长度
;MsgBox(0,"",$name)
$IPX = stringmid($line4, 23,3);;;这里面的5是计算机名的长度
;****设置CScdkey****
$num=Stringright($name,3)
$CDKey = FileOpen("CScdkey.txt", 0)
If $CDKey = -1 Then
MsgBox(0, "错误", "找不到CScdkey.txt")
Exit
EndIf
;*****计算网关*****
IF $num < 240 Then
$ip_G = "192.168.0.254"
ElseIF $num < 480 Then
$ip_G = "192.168.0.254"
ElseIF $num < 720 Then
$ip_G = "192.168.0.254"
ElseIF $num < 960 Then
$ip_G = "192.168.0.254"
EndIF
;*****注册表地址*****
$lian = 2
While 1
$n_reg = RegEnumKey("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}",$lian)
$var = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\"&$n_reg&"\Parameters\Tcpip","ipaddress")
if $var = "" Then
$lian = $lian + 1
Else
ExitLoop
EndIF
Wend
$key1="HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\"&$n_reg&"\Parameters\Tcpip"
$key2="HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces\"&$n_reg
$key3="HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\"&$n_reg&"\Parameters\Tcpip"
$key4="HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Tcpip\Parameters\Interfaces\"&$n_reg
$key5="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\"&$n_reg&"\Parameters\Tcpip"
$key6="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"&$n_reg
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Ghost工具", 301, 350)
$Group1 = GUICtrlCreateGroup("", 0, 0, 298, 344)
$Group2 = GUICtrlCreateGroup("计算机名", 16, 16, 273, 49)
$name33 = GUICtrlCreateLabel("计算机名", 24, 32, 68, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$name1 = GUICtrlCreateInput("", 96, 32, 90, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$_name2 = GUICtrlCreateInput("", 192, 32, 90, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("网卡MAC", 16, 80, 273, 217)
$wk = GUICtrlCreateLabel("网卡MAC", 24, 96, 52, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$wk1 = GUICtrlCreateCombo("", 96, 96, 186, 21)
$IP = GUICtrlCreateLabel("IP地址", 24, 128, 51, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$_ipaddress = _GUICtrlIpAddress_Create($Form1, 96, 128, 186, 21)
_GUICtrlIpAddress_Set($_ipaddress, $ip_I)
;$IP2 = GUICtrlCreateInput("", 192, 128, 90, 21)
;$IP1 = GUICtrlCreateInput("", 96, 128, 90, 21)
;GUICtrlSetState(-1, $GUI_DISABLE)
;$zjym1 = GUICtrlCreateInput("", 96, 155, 90, 21)
;GUICtrlSetState(-1, $GUI_DISABLE)
;$zjym2 = GUICtrlCreateInput("", 192, 155, 90, 21)
$zjym = GUICtrlCreateLabel("子网掩码", 23, 155, 68, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$_netmask = _GUICtrlIpAddress_Create($Form1, 96, 155, 186, 24)
_GUICtrlIpAddress_Set($_netmask, $ip_Z)
$Label1 = GUICtrlCreateLabel("默认网关", 22, 182, 68, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$_gateway = _GUICtrlIpAddress_Create($Form1, 96, 182, 186, 24)
_GUICtrlIpAddress_Set($_gateway, $ip_G)
;$Gateway1 = GUICtrlCreateInput("", 96, 182, 90, 21)
;GUICtrlSetState(-1, $GUI_DISABLE)
;$Gateway2 = GUICtrlCreateInput("", 192, 182, 90, 21)
$Label2 = GUICtrlCreateLabel("DNS1", 24, 209, 47, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$_dns1 = _GUICtrlIpAddress_Create($Form1, 96, 209, 186, 24)
_GUICtrlIpAddress_Set($_dns1, $ip_D)
$Label3 = GUICtrlCreateLabel("DNS2", 24, 236, 47, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$_dns2 = _GUICtrlIpAddress_Create($Form1, 96, 236, 186, 24)
_GUICtrlIpAddress_Set($_dns2, $ip_D1)
;$DNS11 = GUICtrlCreateInput("", 96, 209, 90, 21)
;GUICtrlSetState(-1, $GUI_DISABLE)
;$DNS12 = GUICtrlCreateInput("", 192, 209, 90, 21)
;$DNS21 = GUICtrlCreateInput("", 96, 236, 90, 21)
;GUICtrlSetState(-1, $GUI_DISABLE)
;$DNS22 = GUICtrlCreateInput("", 192, 236, 90, 21)
$Label4 = GUICtrlCreateLabel("IPX号", 27, 263, 46, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$IPX1 = GUICtrlCreateInput("", 96, 263, 90, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$IPX2 = GUICtrlCreateInput("", 192, 263, 90, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("确定更改", 8, 308, 60, 25, 0)
$Button2 = GUICtrlCreateButton("写入MAC", 82, 308, 60, 25 , 0)
$Button3 = GUICtrlCreateButton("关于作者", 155, 308, 60, 25 , 0)
$Button4 = GUICtrlCreateButton("退出程序", 230, 308, 60, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output=""
$Output = $Output & "计 算 机:" & $strComputer & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled != 0", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) then
For $objItem In $colItems
$Output = $Output & "网 卡: " & $objItem.Description & @CRLF
;$strDefaultIPGateway = $objItem.DefaultIPGateway(0)
$Output = $Output & "默认网关: " & $objItem.DefaultIPGateway(0) & @CRLF
$Output = $Output & "计算机名: " & $objItem.DNSHostName & @CRLF
$strIPAddress = $objItem.IPAddress(0)
$Output = $Output & "I P地址: " & $strIPAddress & @CRLF
$strDNSServerSearchOrder = $objItem.DNSServerSearchOrder(0)
$Output = $Output & "默认 DNS: " & $strDNSServerSearchOrder & @CRLF
$strDNSServerSearchOrder = $objItem.DNSServerSearchOrder(1)
$Output = $Output & "备用 DNS: " & $strDNSServerSearchOrder & @CRLF
$strIPSubnet = $objItem.IPSubnet(0)
$Output = $Output & "子网掩码: " & $strIPSubnet & @CRLF
$Output = $Output & "MAC地址: " & $objItem.MACAddress & @CRLF
if Msgbox(1,"本机配置:",$Output) = 2 then ExitLoop
$Output=""
Next
Else
Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_NetworkAdapterConfiguration" )
Endif
GUICtrlSetData ($name1, $name)
GUICtrlSetData ($_name2, $name)
GUICtrlSetData ($wk1 , $objItem.Description & @CRLF)
;GUICtrlSetData ($Gateway1, $ip_G)
;GUICtrlSetData ($Gateway2, $ip_G)
;GUICtrlSetData ($zjym1, $ip_Z)
;GUICtrlSetData ($zjym2, $ip_Z)
;GUICtrlSetData ($dns11, $ip_D)
;GUICtrlSetData ($dns12, $ip_D)
;GUICtrlSetData ($dns21, $ip_D)
;GUICtrlSetData ($dns22, $ip_D)
GUICtrlSetData ($ipx1, $IPX)
GUICtrlSetData ($ipx2, $IPX)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button4
exit
Case $Button3
MsgBox(0,"关于","作者:阿剑 QQ148798"& @LF &"编于:2008年5月27日")
Case $Button2
FileInstall("MAC.exe", @SystemDir & "\")
RunWait("MAC.exe", @SystemDir & "\")
ProcessWaitClose(@SystemDir & "\MAC.exe")
FileDelete(@SystemDir & "\MAC.exe")
Case $Button1
$ip = _GUICtrlIpAddress_Get($_ipaddress)
$ip_Z = _GUICtrlIpAddress_Get($_netmask)
$ip_g = _GUICtrlIpAddress_Get($_gateway)
$ip_D = _GUICtrlIpAddress_Get($_dns1)
$ip_D1 = _GUICtrlIpAddress_Get($_dns2)
$computername = GUICtrlRead($_name2)
$_IPX = GUICtrlRead($ipx2)
;设置机器号
_SetComputerName($computername)
;IP设置
_SetIp($ip, $ip_Z, $ip_g)
;DNS设置
_DNS($ip_D, $ip_D1)
$CD = FileReadLine($CDKey,$num)
FileClose($CDKey)
RegWrite ("HKEY_CURRENT_USER\Software\Valve\CounterStrike\Settings\","KEY","REG_SZ",$CD)
RegWrite ("HKEY_CURRENT_USER\Software\Valve\HALF-LIFE\Settings\","KEY","REG_SZ",$CD)
DllCall("user32.dll","int","SendMessageTimeout","hwnd",65535,"int",26,"int",0,"int",0,"int",0,"int",1000,"str","dwResult")
MsgBox(0,"修改成功","各项设置请重新启动!")
EndSwitch
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;自定义函数
;自定义函数
Func _SetComputerName($_computername)
$strComputer = "localhost"
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colComputers = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For $objComputer In $colComputers
$objComputer.Rename($_computername)
Next
EndFunc ;==>_SetComputerName
Func _SetIp($_ip, $_netmask, $_gateway)
$objWMIService = ObjGet("winmgmts:\\" & "." & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled =TRUE")
$_ip = _ArrayCreate($_ip)
$_netmask = _ArrayCreate($_netmask)
$_gateway = _ArrayCreate($_gateway)
$GatewayMetric = _ArrayCreate("1")
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NwlnkIpx\Parameters", "VirtualNetworkNumber", "REG_DWORD", $_ipx)
For $objItem In $colItems
$errEnable = $objItem.EnableStatic($_ip, $_netmask)
$errGateways = $objItem.SetGateways($_gateway, $GatewayMetric)
Next
EndFunc ;==>_SetIp
Func _DNS($_dns1, $_dns2)
$objWMIService = ObjGet("winmgmts:\\" & "." & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled =TRUE")
$DNS = _ArrayCreate($_dns1, $_dns2)
For $objItem In $colItems
$strDNSServerSearchOrder = $objItem.SetDNSServerSearchOrder($DNS)
Next
EndFunc ;==>_DNS
[ 本帖最后由 wj6025 于 2008-5-31 17:57 编辑 ] |