For information on using the WINDOWS message loop in LISP, see:
http://www.theswamp.org/index.php?topic=58729.0Sometimes if you want your program not to be terminated by ESC, you can temporarily block the ESC key. The following code demonstrates how to define a hook (HOOK)
The following code is a switch command, which masks and releases ESC and is executed alternately. You can also modify VK_ESCAPE to other key codes to block other keys.
The hook function defined is:
Intercept the WM_KEYDOWN message. If the ESC key is pressed, the corresponding keyboard code is VK_ESCAPE (27), interrupt the message loop, and prevent AUTOCAD from knowing that this key press occurred.
(defun _mask
-esc
(hwnd msg wparam lparam ti pos
) (cond ((= msg WM_KEYDOWN
);;Keyboard press message (xdrx_hook_block_messageloop t)
)
)
)
)
Implementation code (Switch Command): (defun _mask
-esc
(hwnd msg wparam lparam ti pos
) (if (= code VK_ESCAPE
);;if ESC (xdrx_hook_block_messageloop t);;Block the message and let ACAD take over
)
)
)
)
(xdrx_begin)
(xd::hook:register "_mask-esc" nil "Mask ESC");Register hook function
(if (not #xd_hook_mask_esc
) (xd::hook:enable "_mask-esc" t);;Hook function enabled
(setq #xd_hook_mask_esc t
) )
(xd::hook:enable "_mask-esc" nil);;Hook function disabled
(setq #xd_hook_mask_esc
nil) )
)
(xdrx_end)
)
=============
The above LISP code uses the XDRX-API, which can be downloaded from
https://github.com/xdcad/XDrx-APIThe XDRX API encapsulates AcDb, AcEd, AcGe, AcBr... C++ library, using C++ methods to develop LISP programs.Thousands of Lisp functions are available.
Modify message.