;脚本开始 → 请在这下面添加您的代码:
Opt('WinTitleMatchMode',2)
Opt('TrayIconDeBug',1)
;-------------- 取"本地连接"名称 ---------------
$objwmiservice = ObjGet('winmgmts:\\localhost\root\CIMV2')
$colitems = $objWMIService.ExecQuery ('SELECT * FROM Win32_NetworkAdapter', 'WQL', 0x10 + 0x20)
If IsObj($colitems) Then
For $objitem In $colitems
If $objitem.netconnectionid <> '' Then
$LocalLinkName=$objitem.netconnectionid
;MsgBox(262144,'',$LocalLinkName)
EndIf
Next
EndIf
;-----------------------------------------------
ShellExecute('Ncpa.Cpl')
$ConfigDir=@AppDataCommonDir&'\Microsoft\Network\Connections\Pbk'
$PhoneBook=$ConfigDir&'\RasPhone.Pbk'
$BackFile=$ConfigDir&'\RasPhone.Bak'
$NetWin='网络连接'
For $a=1 To 5000
If WinExists($NetWin,$NetWin) Then
WinSetTrans($NetWin,$NetWin,0)
ExitLoop
EndIf
Next
$Num=ControlListView($NetWin,$NetWin,'SysListView321','GetItemCount')
If $Num>=2 Then
For $i=0 To $Num
$LinkName=ControlListView($NetWin,$NetWin,'SysListView321','GetText',$i)
If $LinkName<>False And $LinkName<>$LocalLinkName Then
WinClose($NetWin,$NetWin)
$AskMsg=MsgBox(52+262144,' 询问: 请选择一个操作...','貌似您已经创建【'&$LinkName&'】过了, 重新创建吗? ',5)
If $AskMsg=7 Then
Exit
Else
FileDelete(@DesktopCommonDir&'\'&$LinkName&'.Lnk')
If FileExists($PhoneBook) Then FileCopy($PhoneBook,$BackFile,1)
FileDelete($PhoneBook)
DllCall('Shell32.Dll','None','SHChangeNotify','Int',0x08000000,'Int',0x00000000 + 0x00001000,'Ptr',0,'Ptr',0)
EndIf
EndIf
Next
EndIf
$LinkCmd='RunDll32 NetShell.Dll,StartNCW'
Run($LinkCmd)
$NextBtn='[Text:下一步(&N) >]'
$FinishBtn='[Text:完成]'
$FirstBtn='Button1'
$SeconBtn='Button2'
$UserName='您的宽带账号' ;请修改此处为您的宽带账号
$PassWord='您的宽带密码' ;请修改此处为您的宽带密码
$Title='连接向导'
$WB1='欢迎使用'
$WB2='连接到 Internet'
$WB3='您想怎样连接'
$WB4='用户名和密码'
$WB5='您在此输入'
$WB6='用户名'
$WB7='正在完成'
For $a=1 To 5000
If WinExists($Title,$WB1) Then
WinSetTrans($Title,$WB1,0)
ExitLoop
EndIf
Next
ControlClick($Title,$WB1,$NextBtn)
WinWait($Title,$WB2)
ControlClick($Title,$WB2,$NextBtn)
WinWait($Title,$WB3)
ControlCommand($Title,$WB3,$SeconBtn,'Check')
ControlClick($Title,$WB3,$NextBtn)
WinWait($Title,$WB4)
ControlCommand($Title,$WB4,$SeconBtn,'Check')
ControlClick($Title,$WB4,$NextBtn)
WinWait($Title,$WB5)
ControlSetText($Title,$WB5,'Edit1','宽带连接')
ControlClick($Title,$WB5,$NextBtn)
WinWait($Title,$WB6)
ControlSetText($Title,$WB6,'Edit1',$UserName)
ControlSetText($Title,$WB6,'Edit2',$PassWord)
ControlSetText($Title,$WB6,'Edit3',$PassWord)
ControlClick($Title,$WB6,$NextBtn)
WinWait($Title,$WB7)
ControlCommand($Title,$WB7,$FirstBtn,'Check')
ControlClick($Title,$WB7,$FinishBtn)
;-------------------- 刷新所有图标 ------------------------
$Size = DllCall('User32.Dll','Int','GetSystemMetrics','Int',11)
RegWrite('Hkcu\Control Panel\Desktop\WindowMetrics', 'Shell Icon Size', 'REG_SZ', $Size[0]+1)
DllCall('User32.Dll', 'Int', 'SendMessage', 'Hwnd', 0xFFFF, 'Int', 0x001A, 'Int', 0, 'Int', 0)
RegWrite('Hkcu\Control Panel\Desktop\WindowMetrics', 'Shell Icon Size', 'REG_SZ', $Size[0])
DllCall('User32.Dll', 'Int', 'SendMessage', 'Hwnd', 0xFFFF, 'Int', 0x001A, 'Int', 0, 'Int', 0)
;----------------------------------------------------------
If WinWait('网络配置','指定名称',2) Then WinClose('网络配置','指定名称')
WinClose($Title,$WB7)
While 1
If WinExists($NetWin) Then
WinClose($NetWin)
Else
ExitLoop
EndIf
WEnd
ShellExecute('Ncpa.Cpl')
For $a=1 To 5000
If WinExists($NetWin,$NetWin) Then
ExitLoop
EndIf
Next
Send('{F5}')
Sleep(8000)
WinClose($NetWin)