3.3.1.6 版的 Koda 或“GuiIPAddress.au3”文件无法正常编译(有截图)——已解决
本帖最后由 ahkang 于 2009-12-16 12:33 编辑问题表现为:用 3.3.1.6 版自带的 Koda 设计器制作好 IP 输入框的界面,未编译时运行正常,一旦编译后则会出现没有 IP 地址输入框的现象,换回 3.3.1.1 “GuiIPAddress.au3”编译后则又会出现 IP 地址顺序错乱的奇怪现象,同样希望老大们关注一下……
编译前运行截图……
编译后运行截图……
在重新 SVN 下载替换若干文件后,竟奇迹般地正常了!后来想了一下,也许是 AutoItSC.Bin 文件的关系吧?我曾经就报告过 SysTray UDF 的问题,因此也就替换了旧版的 AutoItSC.Bin 文件,不想又和 GuiIPAddress.au3 过不去,但愿问题如此……有高人不吝赐教一下,我想真正的搞清楚问题究竟在哪?在没有弄清事实真相之前,我暂且这么认为了。
已解决,如图!
源码贴出来吧!
这样大家才能知道错在哪啊 本帖最后由 ahkang 于 2009-12-16 13:06 编辑
源码贴出来吧!
这样大家才能知道错在哪啊
xlcwxl 发表于 2009-12-16 12:13 http://www.autoitx.com/images/common/back.gif
附源码如下(很乱且没有规范变量名,随意乱整的,不准笑喔……)#ce _______________脚本开始_________________
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;特殊对话框图标参数
;308 警告图标 按钮:是/否, 默认按钮:否 ║ 276 错误图标 按钮:是/否, 默认按钮:否
;305 警告图标 按钮:确定/取消 默认按钮:取消 ║ 273 错误图标 按钮:确定/取消 默认按钮:取消
;292 询问图标 按钮:是/否, 默认按钮:否 ║ 324 信息图标 按钮:是/否, 默认按钮:否
;289 询问图标 按钮:确定/取消 默认按钮:取消 ║ 321 信息图标 按钮:确定/取消 默认按钮:取消
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;脚本开始 请在这下面添加您的代码:
#InClude <File.Au3>
#InClude <Process.Au3>
#InClude <Acn_Net.Au3>
Global $W=@DesktopWidth
Global $H=@DesktopHeight
Global $X=$W/2
Global $Y=$H/2
Global $File=@TempDir&'\LocalIPInfo.Txt'
Global $InfoFile=@TempDir&'\IPInfo.InI'
Global $ComLineSet='IpConfig /All>'&$File
Global $ComLineIP='NetSh InterFace IP Show Address >'&$File
Global $ComLineDns='NetSh InterFace IP Show Dns >'&$File
Global $CardCtrl = @SystemDir & '\DeVcon.Dll'
Global $DevEnable=$CardCtrl&' Enable =Net Pci\*'
Global $DevDisable=$CardCtrl&' Disable =Net Pci\*'
Global $DevRestart=$CardCtrl&' Restart =Net Pci\*'
Global $Entry='接口'
Global $RepIP='IP地址'
Global $StrIP='IP 地址'
Global $ReadIP='I P 地址'
Global $StrYm='子网掩码'
Global $StrWg='默认网关'
Global $Computer='计算机名'
Global $Section='本机 IP 信息'
Global $ConnectName='连接名称'
Global $WmiFile='WmiPrvse.eXe'
Global $ComputerName='Host Name'
Global $WriteSection='[本机 IP 信息]'
Global $WriteIP='I P 地址='
Global $WriteYm='子网掩码='
Global $WriteWg='默认网关='
MouseMove($W+20,$H+20,0)
ToolTip('正在尝试获取本机 IP 相关数据,请耐心等待片刻...',$X,$Y,'正在初始化程序,获取本机信息,请稍候...',1,6)
If Not FileExists($CardCtrl) Then FileInstall('DeVcon.Dll',$CardCtrl,1)
;---------- 启用网卡 ----------
RunWait($DevEnable,'',@Sw_Hide)
_RunDOS($ComLineSet)
FileSetAttrib($File,'+Sh')
If FileExists($InfoFile) Then
FileSetAttrib($InfoFile,'-Rsh')
FileDelete($InfoFile)
EndIf
$i=1
While 1
$i=$i+1
$s=FileReadLine($File,$i)
If StringInStr($s,$ComputerName) Then
FileWriteLine($InfoFile,$WriteSection)
FileWriteLine($InfoFile,StringReplace(StringReplace(StringReplace(StringReplace($s,$ComputerName,$Computer),' ',''),'.',''),':','='))
FileSetAttrib($File,'-Rsh')
FileDelete($File)
FileSetAttrib($InfoFile,'-R+Sh')
ExitLoop
EndIf
WEnd
_RunDOS($ComLineIP)
FileSetAttrib($File,'+Sh')
For $i=2 To 10
$s=FileReadLine($File,$i)
If StringInStr($s,$Entry) Then
FileWriteLine($InfoFile,$ConnectName&StringTrimLeft(StringTrimRight($s,5),4))
EndIf
If StringInStr($s,$StrIP) Then
FileWriteLine($InfoFile,$WriteIP&StringReplace(StringRight($s,15),' ',''))
EndIf
If StringInStr($s,$StrYm) Then FileWriteLine($InfoFile,$WriteYm&StringReplace(StringRight($s,15),' ',''))
If StringInStr($s,$StrWg) Then FileWriteLine($InfoFile,$WriteWg&StringReplace(StringRight($s,15),' ',''))
If $s='' Then
If ProcessExists($WmiFile) Then ProcessClose($WmiFile)
FileSetAttrib($File,'-Rsh')
FileDelete($File)
ExitLoop
EndIf
Next
_RunDOS($ComLineDns)
FileSetAttrib($File,'+Sh')
Global $StrDns='DNS'
Global $Drop='.'
Global $MainDns='首选 DNS='
Global $SecoDns='备用 DNS='
Global $ZhuDns='首选 DNS'
Global $SubDns='备用 DNS'
For $i=2 To 10
$s=FileReadLine($File,$i)
If StringInStr($s,$StrDns) And StringInStr($s,$Drop) Then
FileWriteLine($InfoFile,$MainDns&StringReplace(StringRight($s,15),' ',''))
FileWriteLine($InfoFile,$SecoDns&StringReplace(StringRight(FileReadLine($File,$i+1),15),' ',''))
EndIf
If $s='' Then
If ProcessExists($WmiFile) Then ProcessClose($WmiFile)
FileSetAttrib($File,'-Rsh')
FileDelete($File)
ExitLoop
EndIf
Next
Global $IPAddress=IniRead($InfoFile,$Section,$ReadIP,'')
Global $SubMask=IniRead($InfoFile,$Section,$StrYm,'')
Global $DefaultGateway=IniRead($InfoFile,$Section,$StrWg,'')
Global $ComputerName=IniRead($InfoFile,$Section,$Computer,'')
Global $MainDNS=IniRead($InfoFile,$Section,$ZhuDns,'')
Global $SecoDNS=IniRead($InfoFile,$Section,$SubDns,'')
If FileExists($InfoFile) Then
FileSetAttrib($InfoFile,'-Rsh')
FileDelete($InfoFile)
EndIf
#InClude <ButtonConstants.Au3>
#InClude <EditConstants.Au3>
#InClude <GUIConstantsEx.Au3>
#InClude <GuiIPAddress.Au3>
#InClude <StaticConstants.Au3>
#InClude <WindowsConstants.Au3>
#Region ### START Koda GUI section ### Form=d:\我的文档\setip.kxf
$Form1_1 = GUICreate('本机 IP 快速设置器 程序设计: 木咱中学电教组', 228, 252, Default, Default, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel('I P 地址:', 28, 32, 55, 17)
$IPAddressBox = _GUICtrlIpAddress_Create($Form1_1,85,31,113,17)
_GUICtrlIpAddress_Set($IPAddressBox,$IPAddress)
$Label2 = GUICtrlCreateLabel('子网掩码:', 27, 57, 55, 17)
$SubMaskBox = _GUICtrlIpAddress_Create($Form1_1,85,56,113,17)
_GUICtrlIpAddress_Set($SubMaskBox,$SubMask)
$DefaultWG = _GUICtrlIpAddress_Create($Form1_1, 85, 82, 113, 17)
_GUICtrlIpAddress_Set($DefaultWG,$DefaultGateway)
$Label4 = GUICtrlCreateLabel('首选 DNS:', 27, 109, 57, 17)
$FirstDNS = _GUICtrlIpAddress_Create($Form1_1, 85, 108, 113, 17)
_GUICtrlIpAddress_Set($FirstDNS,$MainDNS)
$Label5 = GUICtrlCreateLabel('备用 DNS:', 27, 135, 57, 17)
$SecondDNS = _GUICtrlIpAddress_Create($Form1_1, 85, 134, 113, 17)
_GUICtrlIpAddress_Set($SecondDNS,$SecoDNS)
$Label6 = GUICtrlCreateLabel('计算机名:', 28, 162, 55, 17)
$HostNameBox=GUICtrlCreateInput('',85,159,113,21)
GUICtrlSetTip($HostNameBox,'标准的计算机名称可以包含有字母'& _
'(a-z, A-Z)、数字(0-9)和连字符(-),'&@Cr& _
'但不能含有空格或句号(.)。注意:计算机名很有可能'& _
'不完全是纯数字!','您好! 请在此处设置您希望设置的计算机名...',1)
GUICtrlSetData($HostNameBox,$ComputerName)
$Group1 = GUICtrlCreateGroup('本机 IP 信息', 16, 8, 195, 190)
GUICtrlCreateGroup('', -99, -99, 1, 1)
$Label3 = GUICtrlCreateLabel('默认网关:', 28, 83, 55, 17)
$Button1 = GUICtrlCreateButton('运用更改 [&A]', 16, 210, 89, 27)
$Button2 = GUICtrlCreateButton('放弃退出 [&X]', 120, 210, 89, 27)
GUISetState(@Sw_Show)
#EndRegion ### END Koda GUI section ###
Global $HostName
Global $IpADD
Global $SubMask
Global $GateWay
Global $DNS1
Global $DNS2
Global $Num
Global $IPX
Global $WinTitle='本机 IP 快速设置'
Global $WinText=$Computer
Opt('TrayIconDeBug',1)
ToolTip('')
MouseMove($X,$Y,0)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Gui_Event_Close
Exit
Case $Button2
Exit
Case $Button1
$IpADD=ControlGetText($WinTitle,$WinText,$IPAddressBox)
$CheckIP=StringSplit($IpADD,'.')
$Num=$CheckIP
If $Num <2 Then
WinSetState($WinTitle,$WinText,@Sw_MiniMize)
MsgBox(48+262144,'不好意思, IP 地址数据不对!','您应该输入 2 — 255 之间的任意数字! 即将返回... ',5)
WinActivate($WinTitle,$WinText)
ControlSetText($WinTitle,$WinText,'Edit1','')
ControlFocus($WinTitle,$WinText,'Edit1')
Else
$SubMask=ControlGetText($WinTitle,$WinText,$SubMaskBox)
$GateWay=ControlGetText($WinTitle,$WinText,$DefaultWG)
$DNS1=ControlGetText($WinTitle,$WinText,$FirstDNS)
$DNS2=ControlGetText($WinTitle,$WinText,$SecondDNS)
$ComputerName=ControlGetText($WinTitle,$WinText,$HostNameBox)
If $Num < 10 Then
$Num='-0'&$Num
Else
$Num='-'&$Num
EndIf
#Cs
If $Num <10 Then
$ComputerName=StringTrimRight($ComputerName,4)
ElseIf $Num <100 Then
$ComputerName=StringTrimRight($ComputerName,5)
ElseIf $Num >100 Then
$ComputerName=StringTrimRight($ComputerName,6)
EndIf
#Ce
;If Not StringIsDigit($HostName) And StringIsDigit($HostName) <> $Num Then
$Computer=StringSplit($ComputerName,'-')
$ComputerName=$Computer
$HostName=$ComputerName&$Num
;EndIf
_SetIPAddress()
Exit
EndIf
EndSwitch
WEnd
Func _SetIPAddress()
$Output=''
$Output = $Output&'计 算 机:'&$HostName&@CrLf
$Output = $Output&'=========================================='&@CrLf
$OutLine = '************************************ '
$DengHao = ' =========== '
WinSetState($WinTitle,$WinText,@Sw_Hide)
If MsgBox(260+262144,' 您即将设置 IP 数据: ',$OutLine&@Cr&@Cr&'计算机名:'&$DengHao& _
$HostName&@Cr&@Cr&'I P 地址:'&$DengHao&$IpADD&@Cr&@Cr& _
'子网掩码:'&$DengHao&$SubMask&@Cr&@Cr&'默认网关:'&$DengHao& _
$GateWay&@Cr&@Cr&'首选 DNS:'&$DengHao&$DNS1&' '&@Cr&@Cr& _
'备用 DNS:'&$DengHao&$DNS2&@Cr&@Cr&'★ 貌似您即重置 IP 数据,确定继续吗? ')=7 Then
Exit
EndIf
ToolTip('正在尝试使用您刚才提交的数据写入本机 IP 设置, 请稍候...',$X,$Y,'正在尝试设置本机 IP 相关数据,马上就 OK...',1,6)
_WMI_SetNetworkAdapterInfo($HostName,$IpADD,$SubMask,$GateWay,$DNS1,$DNS2,$IPX)
Sleep(2000)
_Set_Computer_Name()
EndFunc
Func _Set_Computer_Name()
ToolTip('正在为您设置本机【计算机名】, 请稍候...',$X,$Y,'正在设置本机的【计算机名】...',1,6)
$SetKey1 = 'Hklm\System\ControlSet001\'
$CtrlKey = 'Hklm\System\CurrentControlSet\'
$Return = RegWrite ($SetKey1&'Control\ComputerName\ComputerName', 'ComputerName', 'REG_SZ', $HostName)
RegWrite ($SetKey1&'Services\Tcpip\Parameters', 'NV Hostname', 'REG_SZ', $HostName)
RegWrite ($SetKey1&'Services\Tcpip\Parameters', 'Hostname', 'REG_SZ', $HostName)
RegWrite ($CtrlKey&'Control\ComputerName\ComputerName', 'ComputerName', 'REG_SZ', $HostName)
RegWrite ($CtrlKey&'Services\Tcpip\Parameters', 'NV Hostname', 'REG_SZ', $HostName)
RegWrite ($CtrlKey&'Services\Tcpip\Parameters', 'Hostname', 'REG_SZ', $HostName)
$str1=stringregexp($HostName,'.*(.{3})',1)
RegWrite ( 'Hklm\System\CurrentControlSet\Services\NwlnkIpx\Parameters' ,'VirtualNetworkNumber', 'REG_DWORD', '0x'&$str1 )
Sleep(2000)
Return $Return
EndFunc ;_SetComputerName修改计算机名 我这里没出错。
你自己鼓捣出来的“bug”吧? SVN是3.3.1.7 衷心感谢高手们的关注!问题已经解决了,并且已经开始尝鲜 3.1.1.7 新版了,目前暂时没有发现问题。 我这里运行楼主的也没出错我的版本是3.3.5.3的
但我运行 _GUICtrlIpAddressCreate这句出错是不是函数改了呢我得看帮助去了
页:
[1]