找回密码
 加入
搜索
查看: 1879|回复: 1

桌面创建快捷方式问题附源码

[复制链接]
发表于 2008-11-21 11:50:56 | 显示全部楼层 |阅读模式
请问下如何将图中的两个连接在桌面创建快捷方式,不用模拟按键的

[ 本帖最后由 dyljf 于 2008-12-4 11:07 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2008-12-4 11:09:20 | 显示全部楼层
帮忙看一下,如何在桌面创建快捷方式
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiIPAddress.au3>

#Region ### START Koda GUI section ### Form=
#NoTrayIcon
If @OSVersion <> "WIN_XP" Then
        MsgBox(0, "错误", "本程序只在winxp下测试通过")
        Exit
EndIf
$Form1 = GUICreate("自动创建VPN连接", 340, 240)
$Label1 = GUICtrlCreateLabel("PC机上VPN名称:", 60, 30, 140, 20)
$Input1 = GUICtrlCreateInput("", 150, 28, 120, 20)
$Label2 = GUICtrlCreateLabel("路由器VPN地址:", 60, 70, 140, 20)
$IPAddress = _GUICtrlIpAddress_Create($Form1, 150, 68, 120, 20)
$Button1 = GUICtrlCreateButton("确定", 60, 150, 65, 25, 0)
$Button2 = GUICtrlCreateButton("取消", 180, 150, 65, 25, 0)
$PbkPath = @AppDataCommonDir & "\Microsoft\Network\Connections\Pbk"
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $Button2
                        Exit
                Case $Button1
                        $InputData = GUICtrlRead($Input1)
                        If $InputData = "" Then
                                MsgBox(0, "", "请输入VPN名称")
                                ContinueLoop
                        EndIf
                        $var = IniReadSection($PbkPath & "\rasphone.pbk", $InputData)
                        If @error Then
                                vpn1()
                                ;这里差一个在桌面创建快捷方式的功能
                                        MsgBox(0, "", "VPN拔号连接创建成功")
                                Exit
                        Else
                                MsgBox(0, "", "VPN用户名已存在,请重新输入")
                                ContinueLoop
                        EndIf
        EndSwitch
WEnd
Func vpn1()
        RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RasMan\Parameters","ProhibitIPSec","REG_DWORD","1")
        $path = @AppDataCommonDir & "\Microsoft\Network\Connections\Pbk"
        $name = GUICtrlRead($Input1)
        $ip = _GUICtrlIpAddress_Get($IPAddress)
        IniWrite($path & "\rasphone.pbk", $name, "Encoding", "1")
        IniWrite($path & "\rasphone.pbk", $name, "Type", "2")
        IniWrite($path & "\rasphone.pbk", $name, "AutoLogon", "0")
        IniWrite($path & "\rasphone.pbk", $name, "UseRasCredentials", "1")
        IniWrite($path & "\rasphone.pbk", $name, "DialParamsUID", random2())
        IniWrite($path & "\rasphone.pbk", $name, "Guid", random1())
        IniWrite($path & "\rasphone.pbk", $name, "BaseProtocol", "1")
        IniWrite($path & "\rasphone.pbk", $name, "VpnStrategy", "2")
        IniWrite($path & "\rasphone.pbk", $name, "ExcludedProtocols", "0")
        IniWrite($path & "\rasphone.pbk", $name, "LcpExtensions", "1")
        IniWrite($path & "\rasphone.pbk", $name, "DataEncryption", "256")
        IniWrite($path & "\rasphone.pbk", $name, "SwCompression", "1")
        IniWrite($path & "\rasphone.pbk", $name, "NegotiateMultilinkAlways", "0")
        IniWrite($path & "\rasphone.pbk", $name, "SkipNwcWarning", "0")
        IniWrite($path & "\rasphone.pbk", $name, "SkipDownLevelDialog", "0")
        IniWrite($path & "\rasphone.pbk", $name, "SkipDoubleDialDialog", "0")
        IniWrite($path & "\rasphone.pbk", $name, "DialMode", "1")
        IniWrite($path & "\rasphone.pbk", $name, "DialPercent", "75")
        IniWrite($path & "\rasphone.pbk", $name, "DialSeconds", "120")
        IniWrite($path & "\rasphone.pbk", $name, "HangUpPercent", "10")
        IniWrite($path & "\rasphone.pbk", $name, "HangUpSeconds", "120")
        IniWrite($path & "\rasphone.pbk", $name, "OverridePref", "15")
        IniWrite($path & "\rasphone.pbk", $name, "RedialAttempts", "3")
        IniWrite($path & "\rasphone.pbk", $name, "RedialSeconds", "60")
        IniWrite($path & "\rasphone.pbk", $name, "IdleDisconnectSeconds", "0")
        IniWrite($path & "\rasphone.pbk", $name, "RedialOnLinkFailure", "0")
        IniWrite($path & "\rasphone.pbk", $name, "CallbackMode", "0")
        IniWrite($path & "\rasphone.pbk", $name, "CustomDialDll", "")
        IniWrite($path & "\rasphone.pbk", $name, "CustomDialFunc", "")
        IniWrite($path & "\rasphone.pbk", $name, "CustomRasDialDll", "")
        IniWrite($path & "\rasphone.pbk", $name, "AuthenticateServer", "0")
        IniWrite($path & "\rasphone.pbk", $name, "ShareMsFilePrint", "1")
        IniWrite($path & "\rasphone.pbk", $name, "BindMsNetClient", "1")
        IniWrite($path & "\rasphone.pbk", $name, "SharedPhoneNumbers", "0")
        IniWrite($path & "\rasphone.pbk", $name, "GlobalDeviceSettings", "0")
        IniWrite($path & "\rasphone.pbk", $name, "PrerequisiteEntry", "")
        IniWrite($path & "\rasphone.pbk", $name, "PrerequisitePbk", "")
        IniWrite($path & "\rasphone.pbk", $name, "PreferredPort", "VPN4-0")
        IniWrite($path & "\rasphone.pbk", $name, "PreferredDevice", "WAN 微型端口 (L2TP)")
        IniWrite($path & "\rasphone.pbk", $name, "PreferredBps", "0")
        IniWrite($path & "\rasphone.pbk", $name, "PreferredHwFlow", "1")
        IniWrite($path & "\rasphone.pbk", $name, "PreferredProtocol", "1")
        IniWrite($path & "\rasphone.pbk", $name, "PreferredCompression", "1")
        IniWrite($path & "\rasphone.pbk", $name, "PreferredSpeaker", "1")
        IniWrite($path & "\rasphone.pbk", $name, "PreferredMdmProtocol", "0")
        IniWrite($path & "\rasphone.pbk", $name, "PreviewUserPw", "1")
        IniWrite($path & "\rasphone.pbk", $name, "PreviewDomain", "0")
        IniWrite($path & "\rasphone.pbk", $name, "PreviewPhoneNumber", "0")
        IniWrite($path & "\rasphone.pbk", $name, "ShowDialingProgress", "1")
        IniWrite($path & "\rasphone.pbk", $name, "ShowMonitorIconInTaskBar", "1")
        IniWrite($path & "\rasphone.pbk", $name, "CustomAuthKey", "-1")
        IniWrite($path & "\rasphone.pbk", $name, "AuthRestrictions", "840")
        IniWrite($path & "\rasphone.pbk", $name, "TypicalAuth", "2")
        IniWrite($path & "\rasphone.pbk", $name, "IpPrioritizeRemote", "1")
        IniWrite($path & "\rasphone.pbk", $name, "IpHeaderCompression", "0")
        IniWrite($path & "\rasphone.pbk", $name, "IpAddress", "0.0.0.0")
        IniWrite($path & "\rasphone.pbk", $name, "IpDnsAddress", "0.0.0.0")
        IniWrite($path & "\rasphone.pbk", $name, "IpDns2Address", "0.0.0.0")
        IniWrite($path & "\rasphone.pbk", $name, "IpWinsAddress", "0.0.0.0")
        IniWrite($path & "\rasphone.pbk", $name, "IpWins2Address", "0.0.0.0")
        IniWrite($path & "\rasphone.pbk", $name, "IpAssign", "1")
        IniWrite($path & "\rasphone.pbk", $name, "IpNameAssign", "1")
        IniWrite($path & "\rasphone.pbk", $name, "IpFrameSize", "1006")
        IniWrite($path & "\rasphone.pbk", $name, "IpDnsFlags", "0")
        IniWrite($path & "\rasphone.pbk", $name, "IpNBTFlags", "1")
        IniWrite($path & "\rasphone.pbk", $name, "TcpWindowSize", "0")
        IniWrite($path & "\rasphone.pbk", $name, "UseFlags", "0")
        IniWrite($path & "\rasphone.pbk", $name, "IpSecFlags", "0")
        IniWrite($path & "\rasphone.pbk", $name, "IpDnsSuffix", "")
        IniWrite($path & "\rasphone.pbk", $name, "NETCOMPONENTS", "")
        IniWrite($path & "\rasphone.pbk", $name, "ms_server", "1")
        IniWrite($path & "\rasphone.pbk", $name, "ms_msclient", "1")
        IniWrite($path & "\rasphone.pbk", $name, "MEDIA", "rastapi")
        IniWrite($path & "\rasphone.pbk", $name, "Port", "VPN4-0")
        IniWrite($path & "\rasphone.pbk", $name, "Device", "WAN 微型端口 (L2TP)")
        FileWriteLine($path & "\rasphone.pbk", "DEVICE=vpn")
        ;IniWrite($path&"\rasphone.pbk",$name,"DEVICE","vpn")
        IniWrite($path & "\rasphone.pbk", $name, "PhoneNumber", $ip)
        IniWrite($path & "\rasphone.pbk", $name, "AreaCode", "")
        IniWrite($path & "\rasphone.pbk", $name, "CountryCode", "1")
        IniWrite($path & "\rasphone.pbk", $name, "CountryID", "1")
        IniWrite($path & "\rasphone.pbk", $name, "UseDialingRules", "0")
        IniWrite($path & "\rasphone.pbk", $name, "Comment", "")
        IniWrite($path & "\rasphone.pbk", $name, "LastSelectedPhone", "0")
        IniWrite($path & "\rasphone.pbk", $name, "PromoteAlternates", "0")
        IniWrite($path & "\rasphone.pbk", $name, "TryNextAlternateOnFail", "1")
EndFunc   ;==>vpn1

Func random1()
        Local $a[3]
        $c = ""
        For $i = 1 To 32
                $a[1] = Random(0, 9, 1)
                $a[2] = Chr(Random(Asc("A"), Asc("F"), 1))
                $b = Random(1, 2, 1)
                $c = $c & $a[$b]
        Next
        Return $c
EndFunc   ;==>random1
Func random2()
        $d = ""
        For $i = 1 To 7
                $d = $d & Random(0, 9, 1)
        Next
        Return $d
EndFunc   ;==>random2
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-15 23:57 , Processed in 0.072362 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表