CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products []
CZ | EN | DE
Login or
  Visitors: 9352

CAD tip CAD tip # 14006:

Question CAD 
 %  platform  category 
Q - question

Universal MsgBox in AutoLISP.

A - answer Using hybrid scripting, you can prepare a universal MsgBox function for AutoLISP, with optional buttons, icons and auto-dismiss feature (after N seconds). This function will work in both full AutoCAD and in AutoCAD LT (2024+).

;Universal MessageBox - see ;(msgbox "Message" "Title" Mode[0..5 + icon 16/23/48/64] AutoDismiss[secs or 0]) (defun MsgBox (message title options time / WshShell) (if (not title)(setq title "AutoCAD")) (if (not options)(setq options 0)) ; plain msgbox, OK (if (not time)(setq time 0)) ; no auto-dismiss (if (setq WshShell (vlax-create-object "WScript.Shell")) ; full ACAD: (vlax-invoke WshShell 'Run (strcat "mshta.exe vbscript:close(CreateObject(\"WScript.Shell\").Popup(\"" message "\"," (itoa time) ",\"" title "\"," (itoa options) "))") ) ; else LT: (startapp (strcat "mshta.exe vbscript:close(CreateObject(\"WScript.Shell\").Popup(\"" message "\"," (itoa time) ",\"" title "\"," (itoa options) "))")) ) (if WshShell (vlax-release-object WshShell)) )

Then use e.g.:

(MsgBox "Hello world! Are you ready?" nil 33 4)

100% *  CAD 
26.1.2024    2356×  
Prices - CAD eShop:
applies to: AutoCAD · AutoCAD LT 2024 ·

See also:
Tip 14027:3D heart from the heart.
Tip 13960:Fermat's spiral in AutoCAD.
Tip 13847:Pringles in AutoCAD - a hyperbolic paraboloid.
Tip 13822:Fast layer visibility toggle ON/OFF.
Tip 13737:Formatting leading zeros in AutoCAD fields (and automatic field update).

Back   All CAD Tips

Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD:    OS:    Categ: 
Text:  FAQ glossary   

Use Google Earth images in your AutoCAD projects with the Plex.Earth Tools More info

Please use these tips at your own risk.
Arkance Systems is not responsible for possible problems that may occur as a result of using any of these tips.