tengte 发表于 2009-7-6 23:02:00

回9楼:VBS程序是一种VB的脚本语言,可用记事本之类的文本编辑器编写,保存为后缀为“.vbs”的文件即可,双击即可运行。我采用这种程序的目的就是编写类似于安装程序的功能,实现在下次打开CAD时自动加载指定的LSP或FAS文件,这个VBS程序不需要在CAD中运行。如果你要在LSP程序中实现上述功能,可用7楼的方法。<br/>

tengte 发表于 2009-7-12 16:59:00

<p>之前我发的VBS程序还有一点小问题:如果CAD从来没有打开过加载应用程序的对话框,那么运行时就会发错。现我已改进了这个问题,使之作为“安装程序”更为适用。其内容如下:</p><p>Dim WS, REG, Path, Key, SubKey, Value, el, flag<br/>Set WS = WScript.CreateObject("WScript.Shell")<br/>Path = WS.CurrentDirectory &amp; "\Load.fas"<br/>Set REG = GetObject("winmgmts:\\.\root\default:StdRegProv")<br/>HKCU = &amp;H80000001<br/>HKLM = &amp;H80000002<br/>Key = "Software\Autodesk\AutoCAD"<br/>REG.GetStringValue HKCU, Key, "CurVer", Value<br/>Key = Key &amp; "\" &amp; Value<br/>REG.GetStringValue HKCU, Key, "CurVer", Value<br/>Key = Key &amp; "\" &amp; Value<br/>SubKey = "\Profiles"<br/>REG.GetStringValue HKCU, Key &amp; SubKey, "", Value<br/>SubKey = SubKey &amp; "\" &amp; Value &amp; "\Dialogs\Appload\Startup"<br/>REG.EnumValues HKCU, Key &amp; SubKey, Item, Value<br/>If IsNull(Item) Then<br/>&nbsp; REG.CreateKey HKCU, Key &amp; SubKey<br/>&nbsp; REG.SetStringValue HKCU, Key &amp; SubKey, "", "1"<br/>&nbsp; REG.SetStringValue HKCU, Key &amp; SubKey, "NumStartup", "1"<br/>&nbsp; REG.SetStringValue HKCU, Key &amp; SubKey, "1Startup", Path<br/>&nbsp; SubKey = "\Applications\AcadAppload"<br/>&nbsp; REG.CreateKey HKCU, Key &amp; SubKey<br/>&nbsp; REG.GetStringValue HKLM, Key &amp; SubKey, "DESCRIPTION", Value<br/>&nbsp; REG.SetStringValue HKCU, Key &amp; SubKey, "DESCRIPTION", Value<br/>&nbsp; REG.GetStringValue HKLM, Key &amp; SubKey, "LOADER", Value<br/>&nbsp; REG.SetStringValue HKCU, Key &amp; SubKey, "LOADER", Value<br/>&nbsp; REG.GetDWORDValue HKLM, Key &amp; SubKey, "LOADCTRLS", Value<br/>&nbsp; Value = Value or 2<br/>&nbsp; REG.SetDWORDValue HKCU, Key &amp; SubKey, "LOADCTRLS", Value<br/>&nbsp; MsgBox "成功加入自动加载列表!"<br/>Else<br/>&nbsp; REG.GetStringValue HKCU, Key &amp; SubKey, "", Value<br/>&nbsp; flag = False<br/>&nbsp; If Not IsNull(Value) Then<br/>&nbsp;&nbsp;&nbsp; Item = Value &amp; "Startup"<br/>&nbsp;&nbsp;&nbsp; REG.GetStringValue HKCU, Key &amp; SubKey, Item, Value<br/>&nbsp;&nbsp;&nbsp; If UCase(Right(Value,9))="\LOAD.FAS" Then flag = True<br/>&nbsp; End if<br/>&nbsp; IF flag Then<br/>&nbsp;&nbsp;&nbsp; MsgBox "TB Tools 已在自动加载列表中!"<br/>&nbsp; Else<br/>&nbsp;&nbsp;&nbsp; REG.GetStringValue HKCU, Key &amp; SubKey, "NumStartup", Value<br/>&nbsp;&nbsp;&nbsp; Value = CStr(CInt(Value)+1)<br/>&nbsp;&nbsp;&nbsp; Item = Value &amp; "Startup"<br/>&nbsp;&nbsp;&nbsp; REG.SetStringValue HKCU, Key &amp; SubKey, "", Value<br/>&nbsp;&nbsp;&nbsp; REG.SetStringValue HKCU, Key &amp; SubKey, "NumStartup", Value<br/>&nbsp;&nbsp;&nbsp; REG.SetStringValue HKCU, Key &amp; SubKey, Item, Path<br/>&nbsp;&nbsp;&nbsp; SubKey = "\Applications\AcadAppload"<br/>&nbsp;&nbsp;&nbsp; REG.GetDWORDValue HKCU, Key &amp; SubKey, "LOADCTRLS", Value<br/>&nbsp;&nbsp;&nbsp; Value = Value or 2<br/>&nbsp;&nbsp;&nbsp; REG.SetDWORDValue HKCU, Key &amp; SubKey, "LOADCTRLS", Value<br/>&nbsp;&nbsp;&nbsp; MsgBox "成功加入自动加载列表!"<br/>&nbsp; End if<br/>End if<br/></p>

zfsaaa 发表于 2009-8-5 09:57:00

请问按你的程序CAD2004可用,可是CAD2002就没反应,如何让他适应CAD2002或更高版本?请大侠指导,谢谢!

tengte 发表于 2009-8-5 23:19:00

高版本应该没有问题,CAD2002没有装过。不过举一反三,在注册表里查找相关的设置应该可以解决。

zfsaaa 发表于 2009-8-6 07:43:00

还有就是如何做到把(指定加载同目录下的Load.fas文件),改为(指定加载不同目录下的Load.fas文件),即我的*.VBS在D:\AA\kk.VBS,而Load.fas在C:\bb\Load.fas.请高手指导,谢谢!

5061220 发表于 2009-8-6 17:20:00

谢谢分享,感谢楼主!

tengte 发表于 2009-8-8 18:46:00

回15楼:把第3行Path = WS.CurrentDirectory &amp; "\Load.fas"<br/>改为你想要的绝对路径或相对路径就行了

liminnet 发表于 2009-8-8 20:48:00

zfsaaa 发表于 2009-8-8 21:49:00

我改了,也用了,只是有时是加载在cad2008,有时在CAD2004,怪事?这个程序最后连注册表也没加也可用,只不过是不稳定。如何解决一次性加载到CAD2002-2008所有版本?

xiaoyingzi 发表于 2011-10-15 09:07:40

tengte 你好,你的代码不能加载所有acad版本和所有配置Profiles下,我想应该要遍历注册表才行,不过不知怎么写,但vbs,一点都不会
有时间能帮忙给改下吗?
页: 1 [2] 3 4
查看完整版本: [求助]关于通过注册表自动加载FAS文件的 奇怪问题(已解决)