怎么把账号密码写入非模拟方式创建的宽带连接中实现自动拨号?
用非模拟方式创建了一个rasphone.pbk但是用户名密码怎么写进去呢?
用户名密码是保存在HKEY_LOCAL_MACHINE\SECURITY\Policy\Secrets中的吧? 提供解决办法的我给加分 试试我的代码行不,我只做了简单的测试,具体的还得你自己做。#NoTrayIcon;无托盘图标
HotKeySet("{ESC}","quit");ESC 退出
Global $TimeStart=TimerInit();程序启动时间戳, 用于检测本程序运行时间. 运行时间超过1分钟自动退出.
Global $PbkName=IniRead("Cfg.ini","SET","PbkFileName","") ;以下及句是读取配置文件的.
Global $LinkType=IniRead("Cfg.ini","SET","Linktype","")
Global $User=IniRead("Cfg.ini","SET","User","")
Global $Pass=IniRead("Cfg.ini","SET","Pass","")
$dll = DllOpen("user32.dll");以下3句是启动定时器的代码
$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$TimerDLL = DllCall($dll, "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 200, "ptr", DllCallbackGetPtr($Timer))
RunPbk();调用运行PBK文件的函数
While 1
Sleep(100)
WEnd
Func RunPbk()
ShellExecute(@ScriptDir&"\"&$PbkName)
ProcessWait("rasphone.exe")
$Title=WinGetTitle("网络连接")
;设置连接类型从下拉列表中选中需要的类型
ControlCommand ($Title,"","ComboBox1","ShowDropDown", "")
Sleep(100)
ControlSetText($Title,"","ComboBox1",$LinkType)
ControlCommand ($Title,"","ComboBox1","HideDropDown", "")
;点连接
ControlClick($Title,"","Button1","Left",1)
;等待连接窗口出现
WinWait("连接")
$LinkTitle=WinGetTitle("连接")
;设置用户名
ControlSetText($LinkTitle,"","Edit1",$User)
;设置密码
ControlSetText($LinkTitle,"","Edit2",$Pass)
ControlClick($LinkTitle,"","Button4","Left",1)
EndFunc
Func quit();退出,关闭定时器, 释放回调函数指针,关闭DLL
ProcessClose("rasphone.exe")
DllCall($dll, "int", "KillTimer", "hwnd", 0, "uint", $TimerDLL)
DllCallbackFree($Timer)
DllClose($dll)
Exit
EndFunc
Func Timer($hWnd, $uiMsg, $idEvent, $dwTime);定时器检测错误,对程序进行异常处理
If WinExists("连接到 "&$LinkType&" 时出错","错误 691") Then
MsgBox(16,"错误!","请检查用户名和密码是否正确!")
quit()
EndIf
If WinExists("连接到 "&$LinkType&" 时出错","错误 800") Then
MsgBox(16,"错误!","请检查VPN服务器是否可以到达!")
quit()
EndIf
If WinExists("连接到 "&$LinkType&" 时出错","错误 629") Then
MsgBox(16,"错误!","请检查用户名和密码是否正确!")
quit()
EndIf
;运行时间超过1分钟自动退出
If TimerDiff($TimeStart)>60000 Then quit()
EndFunc
附件中有完整的测试代码和建立的PBK、配置文件。
楼上的是基于模拟方式的,有没有静默的方法呢? 收到.学习了,!!! 学习了!!... 本帖最后由 KLU3K 于 2010-7-11 18:47 编辑
这个界面什么命令能调出?
dllcall ?
直接 explorer.exe ::{BA126AD7-2166-11D1-B1D0-00805FC1270E} 是无效的。 Dim $lj="宽带连接"
Run(@SystemDir & "\rasphone.exe -h "&$lj )
页:
[1]