Lisp to run .exe or .html?

Discussion in 'AutoCAD' started by calpolyarc, Aug 13, 2004.

  1. calpolyarc

    calpolyarc Guest

    Is it possible to have a lisp routine that runs an .exe file? or .html? .swf? .mov? Thanks!
     
    calpolyarc, Aug 13, 2004
    #1
  2. calpolyarc

    Servo Guest


    Yep------>^C^Cshell START IEXPLORE http://sweets.construction.com;
    and---->^C^Cshell START ACRORD32 m:/cvgdgi/GENERAL/DOCUMENTS/Log-it
    HELP.pdf;

    --
    Servo
    "You gonna do something? Or just stand there and bleed?"
    tservo100 at
    ameritech dot net
    Slow, fiery death to all spammers!!!
     
    Servo, Aug 13, 2004
    #2
  3. calpolyarc

    Paul Turvill Guest

    Perhaps the (startapp ...) function is what you're looking for.
    ___

    ..swf? .mov? Thanks!
     
    Paul Turvill, Aug 13, 2004
    #3
  4. ahh, I have just what you want.

    lisp to run PDF (faster than calling explorer.exe...)

    (DEFUN CT-RUNPDF (NAME / DONE END EXE FILENAME INDEX PDFREG START STRING)
    ;TRY TO GET LOCATION OF PROGRAM
    (IF (NOT (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\Acrobat Settings\\" "AcrobatEXE"))
    (IF (AND (SETQ PDFREG (vl-registry-read "HKEY_CLASSES_ROOT\\AcroExch.Document\\shell\\Open\\command"))
    (SETQ END (vl-string-search ".EXE" (STRCASE PDFREG)))
    )
    (PROGN
    ;GET ACTUAL EXE
    (SETQ STRING (SUBSTR PDFREG 1 (+ END 4))
    DONE 0
    INDEX 1
    )
    (WHILE (AND (= DONE 0)
    (< INDEX (STRLEN STRING))
    )
    (IF (WCMATCH (SUBSTR STRING INDEX 1) "@")
    (SETQ DONE 1
    START INDEX
    )
    )
    (SETQ INDEX (+ 1 INDEX))
    )
    (SETQ EXE (SUBSTR STRING START))
    ;SAVE TO REGISTRY
    (IF (AND EXE (WCMATCH (STRCASE EXE) "*.EXE"))
    (REG-WRITE "Acrobat Settings\\" "AcrobatEXE" EXE)
    )
    )
    ;ELSE GET FROM USER
    (PROGN
    (ALERT "Could not find Acrobat Reader, please Browse for the program")
    (SETQ EXE (GETFILED "Select Acrobat Reader EXE" "C:\\PROGRAM FILES\\" "exe" 32))
    (IF (NOT EXE)
    (VL-EXIT-WITH-VALUE 1)
    )
    ;SAVE TO REGISTRY
    (IF (AND EXE (WCMATCH (STRCASE EXE) "*.EXE"))
    (REG-WRITE "Acrobat Settings\\" "AcrobatEXE" EXE)
    )
    )
    )
    ;ELSE USE REG ONE
    (SETQ EXE (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\Acrobat Settings\\" "AcrobatEXE"))
    )
    ;FIND PDF
    (IF (NOT (SETQ FILENAME (FINDFILE NAME)))
    (PROGN
    (ALERT (STRCAT "File " NAME " cannot be found."))
    (VL-EXIT-WITH-VALUE 1)
    )
    )
    ;RUN WITH ACROBAT
    (IF (NOT (FINDFILE EXE))
    (PROGN
    (ALERT "Acrobat cannot be found so file cannot be run.")
    (VL-EXIT-WITH-VALUE 1)
    )
    )
    (vl-arx-import 'Startapp)
    (STARTAPP EXE FILENAME)
    )

    Now one to run any file:

    (DEFUN C:CT-WINRUN (NAME / FILENAME )
    (IF (NOT (SETQ FILENAME (FINDFILE NAME)))
    (PROGN
    (ALERT (STRCAT "File " NAME " cannot be found."))
    (VL-EXIT-WITH-VALUE 1)
    )
    )
    (IF (NOT (FINDFILE (STRCAT (GETENV "SYSTEMROOT") "\\EXPLORER.EXE")))
    (PROGN
    (ALERT (STRCAT "Explorer cannot be found so file cannot be run."))
    (VL-EXIT-WITH-VALUE 1)
    )
    )
    (vl-arx-import 'Startapp)
    (STARTAPP (STRCAT (GETENV "SYSTEMROOT") "\\EXPLORER.EXE") FILENAME)
    )

    I am proud of the first routine, that solved the problems with explorer taking too long to open PDF's
    I compile my lisps so hence the (vl-arx-import 'Startapp)...
    The last routine is pretty generic
    enjoy

    calpolyarc <>
    |>Is it possible to have a lisp routine that runs an .exe file? or .html? .swf? .mov? Thanks!

    James Maeding
    Civil Engineer/Programmer
     
    James Maeding, Aug 13, 2004
    #4
  5. calpolyarc

    calpolyarc Guest

    Awesome, Thanks! But I am actually trying to open an .exe file, not a .pdf, can your routine be altered to do that?
     
    calpolyarc, Aug 13, 2004
    #5
  6. Hi,

    For HTM files

    (command "Browser" "Filespec") should work.

    For EXE files:
    +
    ( startapp "ProgramName" "FiletoEditSpec")

    --


    Laurie Comerford
    CADApps
    www.cadapps.com.au


    ..pdf, can your routine be altered to do that?
     
    Laurie Comerford, Aug 14, 2004
    #6
  7. calpolyarc

    ECCAD Guest

    To call and execute an .exe I use the following on a menu macro. The same thing can be done within a Lisp program:

    [Calculator - Converter]^C^C(if (findfile (strcat ec_drv "/ec/miec/convert/convert.exe"))+
    (progn (princ)(startapp (strcat ec_drv "/ec/miec/convert/convert.exe"))(princ)))

    Bob
     
    ECCAD, Aug 14, 2004
    #7
  8. You did not look at the code, the second function "CT-WINRUN" does exactly that.
    I did the pdf one because the CT-WINRUN uses explorer.exe to run the file which is slow for pdf's.

    calpolyarc <>
    |>Awesome, Thanks! But I am actually trying to open an .exe file, not a .pdf, can your routine be altered to do that?

    James Maeding
    Civil Engineer/Programmer
     
    James Maeding, Aug 16, 2004
    #8
  9. calpolyarc

    calpolyarc Guest

    Sorry James... missed it, sometimes my eyes start spinning when I see all that code. Thank you very much, your help is appreciated.
     
    calpolyarc, Aug 16, 2004
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.