jdhszh 发表于 2008-3-11 18:14:00

[求助]如何把程序加入启动组

<p>我是这样的,我有一个批处理生成和自动运行该批处理的程序,但程序需要调用自己写的程序,怎样用LISP语言把该程序自动放入“启动组”。</p>

caoyin 发表于 2008-3-13 12:42:00

<p>;;____________________________________________________________________________________________________<br/>;; ▓ (lt:acad-rootgroup-add filname)<br/>;; [功能] 添加路径到 AutoCAD 启动组<br/>;; [参数] filname---完整路径文件名</p><p>(defun lt:acad-rootgroup-add (filname / reg-key munstar)<br/>&nbsp; (setq reg-key (strcat "HKEY_CURRENT_USER\\" (vlax-product-key)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "<a href="file://\\Profiles\\">\\Profiles\\</a>"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (getvar "cprofile")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "<a href="file://\\Dialogs\\Appload\\Startup">\\Dialogs\\Appload\\Startup</a>"<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; munstar (vl-registry-read reg-key "NumStartup")<br/>&nbsp; )<br/>&nbsp; (if munstar<br/>&nbsp;&nbsp;&nbsp; (setq munstar (itoa (1+ (atoi munstar))))<br/>&nbsp;&nbsp;&nbsp; (setq munstar 1)<br/>&nbsp; )<br/>&nbsp; (vl-registry-write reg-key "NumStartup" munstar)<br/>&nbsp; (vl-registry-write reg-key (strcat munstar "Startup") filname)<br/>)</p>

lisp爱好者 发表于 2018-2-7 11:05:31

xshrimp 发表于 2008-3-14 13:03
;;读取LoadCtrls的值,将这个值与2作“或”运算,再写回。这样可以保证AutoCAD启动时会加载Appload.arx模块 ...

大侠第二段删除程序中缺少个之程序:gps->lst-delsame,能否上传

zj20190405 发表于 2023-4-27 10:44:26

xshrimp 发表于 2008-3-14 13:03
;;读取LoadCtrls的值,将这个值与2作“或”运算,再写回。这样可以保证AutoCAD启动时会加载Appload.arx模块 ...

老大,删除启动组缺少GPS->LST-DELSAME函数

phoenixdjq 发表于 2008-3-11 19:03:00

<p>放到acad.lsp ; acad.mnl 中都应该可以的</p>

jdhszh 发表于 2008-3-11 21:31:00

我的意思是用程序自动加入,因为我写个小程序,别人需要用又不熟悉CAD,老是叫来叫去的麻烦,有时还要楼上楼下跑,麻烦又误事,我是想让程序自动完成这一切,省去我的功夫,那位大侠指点下。先谢谢啦!

LongZT 发表于 2008-3-12 09:02:00

<p>就像二楼说的,在acad.lsp中写一条你程序的载入语句就行了.</p>

jaminth 发表于 2008-3-14 00:00:00

<p><strong><font face="Verdana" color="#61b713">caoyin,按照您提供的这几LISP试做了一遍,出现了这样一种情况,</font></strong></p><p><strong><font face="Verdana" color="#61b713">即有时能加载,有时又不能加载的怪事情!能否再检查或完善一下!?谢谢</font></strong></p>

caoyin 发表于 2008-3-14 01:22:00

这种情况我也知道,但应该不是程序问题。程序只能将相关的数据写入注册表,而无法判断CAD能否成功加载。这个在以前好像有讨论

xshrimp 发表于 2008-3-14 12:58:00

本帖最后由 作者 于 2008-3-14 13:00:44 编辑 <br /><br /> <table class="tablebody2" width="90%" border="0" style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all;"><p></p><p><tbody></tbody></p></table><table class="tablebody2" width="90%" border="0" style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all;"><p><tbody></tbody></p></table><table class="tablebody2" width="90%" border="0" style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all;"><p></p><p></p><p><tbody></tbody></p></table>

xshrimp 发表于 2008-3-14 13:03:00

<p>;;读取LoadCtrls的值,将这个值与2作“或”运算,再写回。这样可以保证AutoCAD启动时会加载Appload.arx模块。</p><p>;|<br/>cad appload.arx<br/>处理步骤<br/>1.读取NumStartup的值.<br/>&nbsp; 1.1-&gt;不存在.建立NumStartup值为0删除其他所有键值.<br/>&nbsp; 1.2-&gt;存在.从1Startup读取到NumStartupStartup的值.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.2.1-&gt;监测是否存在重复.重复的删除之.不检测文件是否存在及合法.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.2.2-&gt;其他非相关的键值全部删除.<br/>------------------------------------------------------------------------------------------------<br/>$skey "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R16.0\\ACAD-201:804\\Profiles\\&lt;&lt;未命名配置&gt;&gt;\\Dialogs\\Appload\\Startup"<br/>$akey "HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R16.0\ACAD-201:804\Applications\AcadAppload<br/>(setq appname "se.lsp")(setq appname se.lsp)<br/>(gps-&gt;appload-filepath T)<br/>(gps-&gt;appload-filepath "se.lsp")<br/>(gps-&gt;appload-filepath AppName)<br/>1. AppName 值与nstartup值相符.<br/>2. appname T返回全部自动加载的文件列表<br/>3. appname 文件名(需包含扩展名)或全部路径名.检查自动加载文件中是否含有该文件.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 有则返回该文件的全路径名或文件名<br/>|;<br/>(defun gps-&gt;appload-filepath&nbsp;&nbsp;&nbsp; (AppName / $skey i keyvalue numstartup svlst x)<br/>&nbsp; (if (member (type appname) '(STR SYM))<br/>&nbsp;&nbsp;&nbsp; (progn<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq $skey<br/>&nbsp; (strcat&nbsp; "HKEY_CURRENT_USER\\"&nbsp;&nbsp; (vlax-product-key)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "<a href="file://\\Profiles\\">\\Profiles\\</a>"<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (getvar "CPROFILE")&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "<a href="file://\\Dialogs\\Appload\\Startup">\\Dialogs\\Appload\\Startup</a>"<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq NumStartup (vl-registry-read $skey "NumStartup"))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (if (= (type NumStartup) 'STR)<br/>&nbsp;(progn<br/>&nbsp;&nbsp; (setq NumStartup (atoi NumStartup) i 1 )<br/>&nbsp;&nbsp; (repeat NumStartup<br/>&nbsp;&nbsp;&nbsp;&nbsp; (if (setq keyvalue (vl-registry-read $skey (strcat (itoa i) "Startup") ))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq svlst (append svlst (list keyvalue))&nbsp;&nbsp; i&nbsp; (1+ i)&nbsp;&nbsp; )<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq i (1+ i))<br/>&nbsp;&nbsp;&nbsp;&nbsp; )<br/>&nbsp;&nbsp; );end repeat<br/>&nbsp;&nbsp; (if svlst&nbsp;&nbsp; (setq svlst (mapcar 'strcase svlst)));end if<br/>&nbsp;)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (if svlst&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;(cond ((= T appname) svlst)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (T (car (member (strcase appname) svlst)))<br/>&nbsp;);end cond<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br/>&nbsp;&nbsp;&nbsp; )<br/>&nbsp; );end if<br/>)<br/>;|<br/>(gps-&gt;appload-deletefile "se.lsp")<br/>(gps-&gt;appload-deletefile "D:\\PROGRAM FILES\\SHLISP2006\\自编备份程序<a href="file://\\LRR\\LRR1.FAS">\\LRR\\LRR1.FAS</a>")<br/>(gps-&gt;appload-deletefile "D:\\PROGRAM FILES\\SHLISP2006\\自编备份程序<a href="file://\\LRR\\LRR2.FAS1">\\LRR\\LRR2.FAS1</a>")<br/>|;<br/>(defun gps-&gt;appload-deletefile (AppName / $skey n num svlst)<br/>(if (and (= (type appname) 'STR)&nbsp; (gps-&gt;appload-filepath AppName))<br/>&nbsp; (progn<br/>&nbsp;&nbsp;&nbsp; (setq <br/>&nbsp;&nbsp;&nbsp;&nbsp; $skey (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "<a href="file://\\Profiles\\">\\Profiles\\</a>" (getvar "CPROFILE") "<a href="file://\\Dialogs\\Appload\\Startup">\\Dialogs\\Appload\\Startup</a>")<br/>&nbsp;&nbsp;&nbsp; )<br/>&nbsp;&nbsp;&nbsp; (setq svlst (gps-&gt;lst-delsame (gps-&gt;appload-filepath T)) num 1)<br/>&nbsp;&nbsp;&nbsp; (setq svlst (vl-remove (strcase AppName) svlst))&nbsp; <br/>&nbsp;&nbsp;&nbsp; (foreach n svlst<br/>&nbsp;&nbsp;&nbsp;&nbsp; (vl-registry-write $skey (strcat (itoa num) "Startup") n)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq num (1+ num))&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; )<br/>&nbsp;&nbsp;&nbsp; (vl-registry-delete $skey (strcat (itoa num) "Startup"))<br/>&nbsp;&nbsp;&nbsp; (vl-registry-write $skey "NumStartup" (itoa (length svlst)))<br/>&nbsp;&nbsp;&nbsp; T<br/>&nbsp; )<br/>nil<br/>);end if<br/>)<br/>;;;------------------------------------------------------------------------------------------------<br/>;|<br/>(gps-&gt;appload-addfile "se.lsp")<br/>(gps-&gt;appload-addfile "D:\\PROGRAM FILES\\SHLISP2006\\自编备份程序<a href="file://\\LRR\\LRR2.FAS1">\\LRR\\LRR2.FAS1</a>")<br/>|;<br/>(defun gps-&gt;appload-addfile (AppName / $akey $skey loadctrlnum numstartup)<br/>(if (and (= (type appname) 'STR) (null (gps-&gt;appload-filepath AppName)))<br/>(progn<br/>&nbsp; (setq <br/>&nbsp;&nbsp; $skey (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "<a href="file://\\Profiles\\">\\Profiles\\</a>" (getvar "CPROFILE") "<a href="file://\\Dialogs\\Appload\\Startup">\\Dialogs\\Appload\\Startup</a>")<br/>&nbsp;&nbsp; $akey (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "<a href="file://\\Applications\\AcadAppload">\\Applications\\AcadAppload</a>" )<br/>&nbsp; )<br/>&nbsp; (setq NumStartup (vl-registry-read $skey "NumStartup"))<br/>&nbsp; (if NumStartup<br/>&nbsp;&nbsp;&nbsp; (progn<br/>&nbsp;&nbsp;&nbsp; (vl-registry-write $skey "NumStartup" (itoa (+ 1 (atoi NumStartup))))<br/>&nbsp;&nbsp;&nbsp; (vl-registry-write $skey (strcat (itoa (+ 1 (atoi NumStartup))) "Startup") AppName )<br/>&nbsp;&nbsp;&nbsp; )<br/>&nbsp;&nbsp;&nbsp; (progn<br/>&nbsp;&nbsp;&nbsp; (vl-registry-write $skey "NumStartup" "1")<br/>&nbsp;&nbsp;&nbsp; (vl-registry-write $skey "1Startup" AppName )<br/>&nbsp;&nbsp;&nbsp; )<br/>&nbsp; )<br/>&nbsp;;;读取LoadCtrls的值,将这个值与2作“或”运算,再写回。这样可以保证AutoCAD启动时会加载Appload.arx模块。<br/>&nbsp;(setq loadctrlnum (vl-registry-read $akey "LOADCTRLS"))<br/>&nbsp;(if loadctrlnum<br/>&nbsp; (vl-registry-write $akey "LOADCTRLS" (Boole 7 loadctrlnum 2))<br/>&nbsp; (vl-registry-write $akey "LOADCTRLS" 15)<br/>&nbsp;) <br/>T<br/>)<br/>nil<br/>);end if<br/>)</p>

wangph 发表于 2008-3-16 08:29:00

如果把程序<u><font color="#f70909">移出</font></u>启动组可能就没那么简单了吧,请高手给个例子。
页: [1] 2 3
查看完整版本: [求助]如何把程序加入启动组