Author Topic: Startup Analyzer (a small program)  (Read 1963 times)

0 Members and 1 Guest are viewing this topic.

autocart

  • Guest
Startup Analyzer (a small program)
« on: June 07, 2010, 03:46:58 PM »
Hello AutoLISP-community!

In case this already exits, please don't beat me. It then would be interesting to get to know other's approaches.

Anyway, I have started a small AutoLISP-program (with/req. OpenDCL) which analyzes the AutoCAD-system-settings (for the current profile) for what is being started automatically together with the AutoCAD startup. The results are displayed in a window. It is also possible to export the results to a text file.

Hereby I make the program/code available to the public for free as BTN-ware (Better Than Nothing - use at your own risk). It may be used and/or developed further. The only thing: As long as the original code is being reused (in whole or in major part) I want to be mentioned in the code as copyright-holder. Thanx.

Now a few questions to interested ones:
Did I overlook any sources which AutoCAD searches for programs to start at startup?

Is this program actually of any use to anybody? If yes, then some positive feedback would give me extra motivation to continue working on the program. Otherwise I will likely not spend to much more time on developing it any further.

Last but not least: Does anybody have any ideas of how to improve the program? If so, what is it? Thanx.

Here now (additionally to the attachment) the source code:
Code: [Select]
(defun c:StartupAnalyzer (/ STB_closeForm c:guiStartupAnalyzer_mainDialog_OnCancel c:guiStartupAnalyzer_mainDialog_OnInitialize
                            c:guiStartupAnalyzer_mainDialog_OnOK c:guiStartupAnalyzer_mainDialog_btnClose_OnClicked
                            c:guiStartupAnalyzer_mainDialog_btnExport_OnClicked
                            projectName)
 
  (vl-load-com)
 
  ; *** tests for requirements ***
  (if(not(member "OpenDCL" (vl-registry-descendents (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Applications"))))
    (progn
      (alert "Startup Analyzer:\n\nThe OpenDCL-Runtime environment is not installed. Please install the version 6.0.0.27 or higher.\n-> EXIT")
      (exit)
    )
    ; else:
    (progn
      (command "_OPENDCL") ; Load OpenDCL Runtime
      (if(or(<(dcl_getversion) 6.0) ; (and(=(dcl_getversion) 6.0) (<(atoi(substr(vl-filename-extension(vl-filename-base(dcl_getversionex))) 2)) 0))
            (and(=(dcl_getversion) 6.0) (=(atoi(substr(vl-filename-extension(vl-filename-base(dcl_getversionex))) 2)) 0)
                (<(atoi(substr(vl-filename-extension(dcl_getversionex)) 2)) 27)
            ) ; and
         ) ; or
        (progn
          (alert "Startup Analyzer:\n\nThe installed OpenDCL-Runtime environment is a version less than 6.0.0.27. Please install the version 6.0.0.27 or higher.\n-> EXIT")
          (exit)
        )
      ) ; if
    )
  ) ; if

 
  ; *** setup of variables and functions
  (setq projectName "guiStartupAnalyzer")

  (defun STB_DateTimeString(/ cd)
    (setq cd(rtos(getvar "cdate")2 6))
    (if(= 14(strlen cd)) (setq cd(strcat cd "0")))
    (strcat
      (substr cd 1 4)
      (substr cd 5 2)
      (substr cd 7 2)
      "-"
      (substr cd 10 2)
      "-"
      (substr cd 12 2)
      "-"
      (substr cd 14 2)
    )
  ) ; DateTimeString
 
  (defun STB_closeForm ()
    (dcl_Form_Close(eval(read(strcat projectName "_mainDialog"))))
  )

  (defun c:guiStartupAnalyzer_mainDialog_OnCancel (/)
    (STB_closeForm)
  )
 
  (defun c:guiStartupAnalyzer_mainDialog_OnOK (/)
    (STB_closeForm)
  )
 
  (defun c:guiStartupAnalyzer_mainDialog_OnInitialize (/ textToDisplay hkeyBase NumStartup i file lineOfText mnlfile)
    ; *** startup suite ***
    (setq textToDisplay "Defined in the Startup-Suite (Command \"Appload\"):"
          hkeyBase(strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\PROFILES\\"
                      (vla-get-ActiveProfile(vla-get-PROFILES(vla-get-preferences(vlax-get-acad-object))))
                  )
          NumStartup(atoi(VL-REGISTRY-READ(strcat hkeyBase "\\Dialogs\\Appload\\Startup") "NumStartup"))
          i 1
    ) ; setq
    (if(= 0 NumStartup)
      (setq textToDisplay(strcat textToDisplay "\r\n  There is nothing in the startup suite."))
      ; else:
      (while(<= i NumStartup)
        (setq textToDisplay(strcat textToDisplay "\r\n  " (VL-REGISTRY-READ(strcat hkeyBase "\\Dialogs\\Appload\\Startup") (strcat(itoa i)"Startup"))))
        (setq i(1+ i))
      ) ; while
    ) ; if

   
    ; *** other registry data ***
    (setq textToDisplay(strcat textToDisplay "\r\n\r\nDefined in other parts of the registry (Key \"Applications\"):")
          hkeyBase(strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Applications")
          i 0
    ) ; setq
    (foreach element(vl-registry-descendents hkeyBase)
      (if(= 2(boole 1 2(vl-registry-read(strcat hkeyBase "\\" element) "LOADCTRLS")))
        (progn
          (setq textToDisplay(strcat textToDisplay "\r\n  " (vl-registry-read(strcat hkeyBase "\\" element) "LOADER"))
                i(1+ i)
          )
        )
      ) ; if
    ) ; foreach
    (if(= i 0) (setq textToDisplay(strcat textToDisplay "\r\n  No applications are registered for loading upon AutoCAD startup.")))
   
   
    ; *** different individual files ***
    (foreach filename '("acad.lsp" "acaddoc.lsp" "acad.rx" "acad.dvb" "acad.ads")
      (setq textToDisplay(strcat textToDisplay "\r\n\r\n" filename ":"))
      (if(and(findfile filename) (setq file(open(findfile filename) "r")))
        (progn
          (while(setq lineOfText(read-line file))
            (setq textToDisplay(strcat textToDisplay "\r\n  " lineOfText))
          ) ; while
          (close file)
        )
        ; else:
        (setq textToDisplay(strcat textToDisplay "\r\n  The file has not been found."))
      ) ; if
    ) ; foreach

   
    ; *** .mnl-files ***
    (setq textToDisplay(strcat textToDisplay "\r\n\r\nTHE LAST SECTION SHOWS THE .MNL-FILES THAT WERE FOUND:"))

    (if(not(findfile(strcat(getvar "MENUNAME") ".mnl")))
      (setq textToDisplay(strcat textToDisplay "\r\nThe .mnl-file \"" (VL-FILENAME-BASE(getvar "MENUNAME")) ".mnl\" (belonging to the main .cui(x)-file \""
(VL-FILENAME-BASE(getvar "MENUNAME")) ".cui(x)\") has not been found.")
      )
      ; else:
      (progn
        (setq textToDisplay(strcat textToDisplay "\r\n" (VL-FILENAME-BASE(getvar "MENUNAME")) ".mnl (belonging to the main .cui(x)-file \""
   (VL-FILENAME-BASE(getvar "MENUNAME")) ".cui(x)\"):"))
        (if(not(setq file(open(strcat(getvar "MENUNAME") ".mnl") "r")))
          (setq textToDisplay(strcat textToDisplay "\r\n  The file \"" (VL-FILENAME-BASE(getvar "MENUNAME")) ".mnl\" could not be read."))
          ; else:
          (progn
            (while(setq lineOfText(read-line file))
              (setq textToDisplay(strcat textToDisplay "\r\n  " lineOfText))
            ) ; while
            (close file)
          )
        ) ; if
      )
    ) ; if

    (vlax-for element(vla-get-menugroups(vlax-get-acad-object))
      (if(and(/=(strcat(VL-FILENAME-directory(vla-get-menufilename element)) "\\" (VL-FILENAME-BASE(vla-get-menufilename element))) (getvar "MENUNAME"))
             (setq mnlfile(findfile(strcat(vl-filename-directory(vla-get-menufilename element)) "\\" (vl-filename-base(vla-get-menufilename element)) ".mnl")))
         ) ; and
        (progn
          (setq textToDisplay(strcat textToDisplay "\r\n\r\n" (vl-filename-base mnlfile) ".mnl:"))
          (if(not(setq file(open mnlfile "r")))
            (setq textToDisplay(strcat textToDisplay "\r\n  The file \"" (vl-filename-base mnlfile) ".mnl\" could not be opened."))
            ; else:
            (progn
              (while(setq lineOfText(read-line file))
                (setq textToDisplay(strcat textToDisplay "\r\n  " lineOfText))
              )
              (close file)
            )
          ) ; if
        )
      ) ; if
    ) ; vlax-for
   
    (dcl_Control_SetText (eval(read(strcat projectName "_mainDialog_txt1"))) textToDisplay)
  ) ; c:guiStartupAnalyzer_mainDialog_OnInitialize
 
  (defun c:guiStartupAnalyzer_mainDialog_btnClose_OnClicked (/)
    (STB_closeForm)
  )
 
  (defun c:guiStartupAnalyzer_mainDialog_btnExport_OnClicked (/ filenameToSaveTo file i)
    (if(setq filenameToSaveTo(getfiled "STB Startup Analyzer - Choose Filename for Export"
                                    (strcat "STB Startup Analyzer - " (if(="Visual LISP"(substr(ver)1 11)) "AutoCAD" "CAD") "-Profile "
                                            (vla-get-ActiveProfile(vla-get-PROFILES(vla-get-preferences(vlax-get-acad-object))))
                                            " - " (STB_DateTimeString) ".txt"
                                    )
                                    "" 5)
      ) ; setq
      (progn
        (if(setq file(open filenameToSaveTo "w"))
          (progn
            (foreach element (VL-STRING->LIST(dcl_TextBox_GetLine (eval(read(strcat projectName "_mainDialog_txt1"))) 0)) (write-char element file))
            (setq i 1)
            (repeat(1-(dcl_TextBox_GetLineCount (eval(read(strcat projectName "_mainDialog_txt1")))))
              (write-char(ascii "\n") file)
              (foreach element (VL-STRING->LIST(dcl_TextBox_GetLine (eval(read(strcat projectName "_mainDialog_txt1"))) i)) (write-char element file))
              (setq i(1+ i))
            ) ; repeat
            (close file)
            (dcl_MessageBox "Export finished." "STB Startup Analyzer - Export")
          )
          ; else:
          (dcl_MessageBox "ERROR: The file which to export to could not be opened." "STB Startup Analyzer - Export")
        ) ; if
      )
    ) ; if
  ) ; c:guiStartupAnalyzer_mainDialog_btnExport_OnClicked

 
  ; *** START ***
  (if(dcl_Project_Import '("YWt6A8oOAAB2msgEBuKTKDUxLT9qgFDoTEKqNkqQcjh63Crf0wSVvDq7+8LUPJy4+iZ0Jlf7VlbE"
"H9f3BUmEdfKxektf0Ard93UBfnXpWPwQ8k9A1pmyE0UJMC8+Va+6Ba0fwEcNIE2ZRemLp/tSDMGk"
"XzJe+2DynUqwr0b/T2I6+C5k6Q5nfcqUfgYrfyqsISjUMVz4aMZaov0o5PkW8h5hw186F8t7d+TH"
"Glo0EfYIWzbI6Zg3+hdo24NQF5ZezOC7AHKs8AAEHSRZNE3pSgdoWDXQyLbVfUodcdAgYVpirwgd"
"ymw+S2Wb9tVGpLMucLTuBTYqSzxEVzTO8zgwDGo9LqFushMPFjEtQYgdR3mt+bvSi18wVfl3GQrK"
"F9bl6APWdWgQUvNBOJkX4QT0jMILYKrSjgCvvLPbjgDqAFesjagtJD17Y6WRabURA1eCuK9/S1eM"
"BfCkgvOZ0CDj3rSO4/fkjPD44Ukq/9SonnFKLfFzqIRxewBajsq+IfvBVda2nVKFpRhrm7hgipxu"
"lLo/qmtj+wQflz9LZ8ExNtz14XE9aYF/J4L/DzLskyjWDA9LCbpvoGsG477Muqz7AkNCUo42XzCZ"
"XZlBVJoZezB2ASl7QFeO/r6pesBfjlf/mXWZmp97bfHAwQlcwMe8AwTGIJbBSYcUh56sWyR46yEs"
"xTuHyoLGAkGND3h0qZ+3nThgGAKhlhWFcXrQbIhJZgVi6rQmGyqtO/u0uwQ4CclKs6UW2kBEHYKw"
"DSLQzpXdp3KtksT2HdmP1Y9YzSG5D7KeF/Q2S3Wk+3qgX4JBbYDw5YOyZsur2DVRm7n6L8WywDEt"
"ypHT3p8IbxnJvw3iGfm/RPAwbxnp7sl1BzKaX6U+3e6FpLzTAiUmPd7kKeQbJdYyLvBnYt8iudbJ"
"DIUvSyi/OADJKWkFTiHTagNb+TdFJ6LokB8bE5SIVMlXpxiACmUn3BO6O0d50xXQFs7RBtszH8cz"
"vjmMU8430JOGNoOkzzdDdeXq7YZHpyBESKfkHu0zma9XtqtbmpM8cJnpt+j68RIVB9v2ErTd/JGh"
"S+UUn6wus6aBMcqrWCTOvwHDAX+zxLUS5BvOtsmRYd1nQaF/fDqNpA=="))
    (dcl_Form_Show(eval(read(strcat projectName "_mainDialog"))))
  )
  (princ)

) ; c:StartupAnalyzer

(princ "\n\nSTB Startup Analyzer\ncopyright June 2010 by Stephan Bartl (www.stbartl.at)\nStart with: \"STARTUPANALYZER\"")
« Last Edit: June 07, 2010, 05:37:45 PM by autocart »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Startup Analyzer (a small program)
« Reply #1 on: June 07, 2010, 04:29:53 PM »
Welcome to the Swamp and thanks for the contribution. 8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MeasureUp

  • Bull Frog
  • Posts: 465
Re: Startup Analyzer (a small program)
« Reply #2 on: June 08, 2010, 01:14:31 AM »
I just like the word - "BTN" before looking into your code.  :lol:
Thanks for your sharing.
« Last Edit: June 08, 2010, 01:31:59 AM by MeasureUp »