Author Topic: Is it possible to add lsp/vlx into startup suite by coding?  (Read 2178 times)

0 Members and 1 Guest are viewing this topic.

kozmos

  • Newt
  • Posts: 114
Is it possible to add lsp/vlx into startup suite by coding?
« on: October 13, 2023, 05:26:04 AM »
The startup suite files are stored in profile Registry and I have tried to add the file in registry. however, the file will not showup in startup suite, as well as being auto-loaded at startup. Any clue or solutions?



Following is what I have come so far:
Code - Auto/Visual Lisp: [Select]
  1. (Defun StartUp-MainKey ()
  2.   (strcat "HKEY_CURRENT_USER\\"
  3.           (vlax-product-key)
  4.           "\\Profiles\\"
  5.           (getvar "CPROFILE")
  6.           "\\Dialogs\\Appload\\Startup"
  7.   )
  8. )
  9.  
  10. (Defun StartUp-Check (fnn / IDX KEY RTN VAL)
  11.   (setq key (StartUp-MainKey)
  12.         idx 1
  13.   )
  14.   (repeat (atoi (vl-registry-read key "NumStartup"))
  15.     (and (setq val (vl-registry-read
  16.                      key
  17.                      (strcat (itoa idx) "Startup")
  18.                    )
  19.          )
  20.          (setq rtn (cons (strcase val) rtn))
  21.     )
  22.     (setq idx (1+ idx))
  23.   )
  24.   (if (and (= (type fnn) 'str) (vl-position (strcase fnn) rtn))
  25.     fnn
  26.     rtn
  27.   )
  28. )
  29. (Defun StartUp-Add (fnn / KEY NUM VAL)
  30.   (and (= (type fnn) 'STR)
  31.        (setq fnn (findfile fnn))
  32.        (null (vl-position
  33.                (setq fnn (strcase fnn))
  34.                (StartUp-Check t)
  35.              )
  36.        )
  37.        (setq key (StartUp-MainKey)
  38.              num (vl-registry-read key "NumStartup")
  39.        )
  40.        (progn
  41.          (vl-registry-write
  42.            key
  43.            "NumStartup"
  44.            (if (equal num "0")
  45.              "1"
  46.              (itoa (+ 1 (atoi num)))
  47.            )
  48.          )
  49.          (vl-registry-write
  50.            key
  51.            (strcat (if (equal num "0")
  52.                      "1"
  53.                      (itoa (+ 1 (atoi num)))
  54.                    )
  55.                    "Startup"
  56.            )
  57.            fnn
  58.          )
  59.          (setq key (strcat "HKEY_CURRENT_USER\\"
  60.                            (vlax-product-key)
  61.                            "\\Applications\\AcadAppload"
  62.                    )
  63.          )
  64.          (vl-registry-write
  65.            key
  66.            "LOADCTRLS"
  67.            (if (setq val (vl-registry-read key "LOADCTRLS"))
  68.              (Boole 7 val 2)
  69.              15
  70.            )
  71.          )
  72.        )
  73.   )
  74. )
  75.  
« Last Edit: October 13, 2023, 05:30:21 AM by kozmos »
KozMos Inc.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Is it possible to add lsp/vlx into startup suite by coding?
« Reply #1 on: October 13, 2023, 05:35:58 AM »
Why not just use the acaddoc.lsp?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8717
  • AKA Daniel
Re: Is it possible to add lsp/vlx into startup suite by coding?
« Reply #2 on: October 13, 2023, 05:50:07 AM »
Can lispers use Bundles? Seems like it would be easy enough to generate the xml


kozmos

  • Newt
  • Posts: 114
Re: Is it possible to add lsp/vlx into startup suite by coding?
« Reply #3 on: October 13, 2023, 07:25:52 AM »
Why not just use the acaddoc.lsp?
There used to be a lsp "virus" here, so some anti-virus programs here may erase acad.lsp and acaddoc.lsp even it is in full text content.
KozMos Inc.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Is it possible to add lsp/vlx into startup suite by coding?
« Reply #4 on: October 13, 2023, 08:02:01 AM »
Can lispers use Bundles? Seems like it would be easy enough to generate the xml

Yes  :-)

kozmos

  • Newt
  • Posts: 114
Re: Is it possible to add lsp/vlx into startup suite by coding?
« Reply #5 on: October 13, 2023, 08:19:31 AM »
Can lispers use Bundles? Seems like it would be easy enough to generate the xml

Yes  :-)

I will give this way a try.
KozMos Inc.

kozmos

  • Newt
  • Posts: 114
Re: Is it possible to add lsp/vlx into startup suite by coding?
« Reply #6 on: October 13, 2023, 10:17:55 AM »
I found the reason, must restart AutoCAD to make it work.  :yay!:
KozMos Inc.

BIGAL

  • Swamp Rat
  • Posts: 1417
  • 40 + years of using Autocad
Re: Is it possible to add lsp/vlx into startup suite by coding?
« Reply #7 on: October 13, 2023, 08:24:30 PM »
With Autocad and Bricscad if you have custom mnu you can have a corresponding mnl which has the files you want to load on startup. Note LT 2024 does not support MNL.

Code: [Select]
(load "delete client image-3")
(load "shortcuts")

Do you need help to make a bundle they are very easy to make just need 1 to see how they are done.
A man who never made a mistake never made anything

kozmos

  • Newt
  • Posts: 114
Re: Is it possible to add lsp/vlx into startup suite by coding?
« Reply #8 on: October 13, 2023, 11:28:45 PM »
With Autocad and Bricscad if you have custom mnu you can have a corresponding mnl which has the files you want to load on startup. Note LT 2024 does not support MNL.

Code: [Select]
(load "delete client image-3")
(load "shortcuts")

Do you need help to make a bundle they are very easy to make just need 1 to see how they are done.

Thanks for the help, however, bundle right now is not very suitable for my situation as my program has it's own folder structure and user will be needing to visit files there, I know I can put all folder inside ApplicationPlugin but it is kind of too deep for users to access. Another reason of not using bundle is because my program is still trying to support AutoCAD down to 2010. Maybe in the future when it can stop supporting CAD V2014 and lower, I will try to migrate using bundle. I also have done some basic research and agree it is very simple to make Bundle.
Again, thanks for the offer of help.
KozMos Inc.

BIGAL

  • Swamp Rat
  • Posts: 1417
  • 40 + years of using Autocad
Re: Is it possible to add lsp/vlx into startup suite by coding?
« Reply #9 on: October 14, 2023, 06:42:58 PM »
I write my client code to look for a directory, one of the things you can do as a install is use a zip file, you can unzip and force to unpack to a known directory, handy when sending mnu's, bitmaps, code etc.

Code: [Select]
(vl-load-com)
(vl-mkdir "c:\\CAD-TOOLS")

(setq filename (getfiled "Select the File \"Cad tools 12-09-2023\"" "" "ZIP" 16))

; unzip
(startapp (strcat "powershell -command Expand-Archive -Path '" filename "' -DestinationPath 'C:/CAD-TOOLS' -FORCE"))
(alert "programs unzipped to C:/CAD-TOOLS")
A man who never made a mistake never made anything

kozmos

  • Newt
  • Posts: 114
Re: Is it possible to add lsp/vlx into startup suite by coding?
« Reply #10 on: October 14, 2023, 10:28:04 PM »
Right, I also used ZIP file to install my program. share with you my code to unzip the zip file using Shell.Application, there will be no popup window.

Code - Auto/Visual Lisp: [Select]
  1. (Defun EXTRACTZIP (ZIP DIR DEL / FSO SRC TAR)
  2.   (and (null DIR)
  3.        (setq DIR (vl-filename-mktemp))
  4.        (vl-mkdir DIR)
  5.   )
  6.   (and (findfile ZIP)
  7.        (vl-file-directory-p DIR)
  8.        (setq FSO (vlax-create-object "Shell.Application")
  9.              TAR (vlax-invoke-method FSO "NameSpace" DIR)
  10.        )
  11.        (setq SRC (vlax-invoke-method FSO "NameSpace" ZIP)
  12.              SRC (vlax-invoke SRC "Items")
  13.        )
  14.        (vlax-invoke-method TAR "CopyHere" SRC 20)
  15.   )
  16.   (and DEL (vl-file-delete ZIP))
  17.   (and FSO (vlax-release-object FSO))
  18. )
  19.  
KozMos Inc.

kozmos

  • Newt
  • Posts: 114
Re: Is it possible to add lsp/vlx into startup suite by coding?
« Reply #11 on: October 14, 2023, 10:56:10 PM »
Can lispers use Bundles? Seems like it would be easy enough to generate the xml

Yes  :-)
Regading using bundle, I have a question. After install bundle, if the user wants to have access to his original CAD environment without the bundle, is it possible? How to do it? Can we control AutoCAD to autoload a particular bundle just in a single CAD profile settings?
KozMos Inc.