For related content, see:
http://www.theswamp.org/index.php?topic=58729.0http://www.theswamp.org/index.php?topic=58730.0Regarding the message loop of the WINDOWS system, you can search online and refer to the literature.
All software in the WINDOWS system interacts with the system through the message loop. When we press the keyboard or move the mouse, the WINDOWS system will send the message to AUTOCAD, and AUTOCAD will accept the message processing and return the information to the system.
The system keyboard message received by AUTOCAD can be intercepted through the hook related functions of ARX. After the application process, the message can continue to be passed to AUTOCAD for subsequent operations, or it can be intercepted so that AUTOCAD does not know that this "message" has come, and AUTOCAD can also You cannot continue to respond to messages and operate.
The general hook function is defined as follows:
BOOL HOOK(MSG *pMsg)
{
switch(pMsg->message){
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
if(...)
{
return TRUE; // TRUE intercepts the message and does not allow AUTOCAD to continue processing.
}
break;
}
return FALSE; // Return FALSE, AUTOCAD can continue to accept the message
}
Can A/VLISP also intercept message processing? No, LISP does not provide such a function.
The above operations are completed through the custom functions provided by the XDRX API to LISP.
The "hook" related functions provided by the API are:
xdrx-hook-register
xdrx-hook-enable
xdrx-hook-status
xdrx-hook-remove
xdrx-hook-tracemouse
xdrx-hook-block-messageloop
xdrx-system-keystate
xdrx-system-ctrl-down
xdrx-system-ctrl-shift-down
xdrx-system-ctrl-alt-shift-down
xd::hook:register
xd::hook:enable
xd::hook:remove
The function of the xdrx-hook-block-messageloop function is equivalent to the return TRUE mentioned above, and the termination message is continued to AUTOCAD.
The typical hook callback function structure of LISP is as follows:
(defun hook
(hwnd msg wparam lparam time pos
) ;|
hwnd -- window handle
msg --- message
wparam -- main parameter
lparam ---- second parameter
time ------- time of occurrence
pos ------- mouse screen coordinates
|;
(cond ((= msg WM_KEYUP
) ; key up )
((= msg WM_KEYDOWN) ;Key pressed
)
((= msg WM_SYSKEYDOWN)) ;System key pressed
((= msg WM_CHAR)
)
((= msg WM_MOUSEWHEEL) ; Turn the wheel
)
((= msg WM_LBUTTONUP) ;The left mouse button pops up
)
((= msg WM_LBUTTONDOWN) ;Left mouse button pressed
)
((= msg WM_LBUTTONDBLCLK) ;Double left mouse button click
)
((= msg WM_RBUTTONUP) ; Right mouse button pops up
)
((= msg WM_RBUTTONDOWN) ;Right mouse button pressed
)
((= msg WM_RBUTTONDBLCLK) ;right mouse button double click
)
((= msg WM_MBUTTONUP) ;Middle mouse button pops up
)
((= msg WM_MBUTTONDOWN) ;Middle mouse button pressed
)
((= msg WM_MBUTTONDBLCLK) ;Middle mouse button double click
)
((= msg WM_MOUSEMOVE) ;mouse movement
)
((= msg WM_PAINT) ;Screen drawing
)
((= msg WM_HOTKEY) ;Hotkey
)
((= msg WM_INPUT) ;Input
)
((= msg WM_VSCROLL) ;Screen scrolling
)
)
)
The password input box should display *****, which cannot be realized in ordinary LISP. The XDRX API provides a powerful HOOK injection function. It uses the HOOK technology of the API to intercept keyboard messages, monitor the WINDOWS system WM_CHAR messages, truncate the message processing, and The entered characters become *, and the actual input is saved in a variable for subsequent processing by our program.
The animation below demonstrates that the entered password is displayed in the text box below.
OPENDCL dialog box is used.
The text box below displays the characters being entered, and the dialog box above displays them encrypted with *.

'("YWt6A0QTAABH5cGQBuK7KCcxLS9u4OwsMN5uW2TVd3d4Inzo23bIQtYP9cxdZGFKX+oz2y7cdrtp"
"Ak7vunlhMvL3gH5hIm3pulnpurblQb5hHlwWAk1QquetrAWRqZvIUqzlBQXBRZmysudNjbOnbiPy"
"xJS3OXPK6WTX92a1k6JqEOCADqhvD26v2XzcPIBpPxtdcdCZ331KNgB07OkPkvXpK4aHBWPBe4ZH"
"uunpD301fYKQqViUBiDuURNWVGSJz8L3Gz2Cy+C5BQc6QYGJF/PzgkO+EQBgTbYMUQGJFxP/hoZA"
"wHuZ7SXCG9svXHFXeZsvgrkYjPEv5lCvVjEvYdcKN2xh3DDs7TJBSz3w24lR0i6jWSliRLoNi2mO"
"Wp4sHYDSloVyjFd1oKgxs2qfC4qsRtGZTCEtpKN/1N4wZN1tAiHed8CFVrqx1WJ1i7TO3wMAf4Zb"
"npn+Af0xb75Q+WuBTxxa9KpzVDZ6Jhwq70iekQYN8vfaahbgzbJSNGN3y6WOwfChokzZOr1kohMp"
"ZTFwDO484lK0c3W1eY0xPoB2jh2+cX+djDz3PruOdp6vujxijWzGTrZRfMB3iGhsFfOfOx3CoOYR"
"TgFAzy9PIneNwWWAFgf0hLZdy4pX10ji95u5muP4wjnOtcxLBzxVlFeqpU220zy+HWhjkAioIrCJ"
"B8O7XwBBvLEfLNFzpXWc5ddwQ9zZZAKjErZxdpBMjnG/o3gAVYbVu3EsRXIH57ZFckJcxmsU0HMO"
"RZ5ovg0eEWm6uyJtatH3HHNNqzoUcCKYYJHa2kMIoMBLpgMDzAhW16rOapOMfjVtNW81azUNxwf6"
"W/Zb9FvyW/Bq/gf36u894BTHVzFD8GpqH7SlxUyg8FzuLE6x71ySVrsqaVMa0/WDigGVnGShEPfw"
"RRBglDzjnLPxDg1DuvNYXIN87ajQYeomDieEGKC162kVljlnNz1BstepuQbmA2YmhTBsygbES2Ux"
"JafNF1D1TrW4NrMkShK3IL0XYN+wPpp4fx1koX0CUKUd7R/D+dMx7mI4hJd08SaNkEcaj6/t8/Fs"
"ZUe2MLbPsPjnFV+tlX7l5oVpTsno5ebFNQ7Q4wZdTq0MRc1hkuRmziKOY84lc5VOT5xGJ2eP855D"
"vmYgvisegUMebf0UuKNw8i0dtgGwGkBnlodjnpE0Z05+gCRnz0YDtBuctHlqmbRcc5PGrIBiz/Sn"
"JFBm16dQBQ3eGCEYFMhFB9Io49KLt32VUL03Ojmi0HANFnbAmvjuPT2M2xA2piwotHWm/M47Kz9C"
"7knOG1/xmq68Apck5mNp050XkUYnx5Bem6hsA9cknEQP27HoVZuJcVpWEJ8="
)
)
(defun c:xd_password#OnInitialize
(/) (dcl-Control-SetFocus xd_password_1)
)
(defun c:xd_password_1#OnSetFocus
(/) (dcl-Control-SetFocus xd_password_1)
)
(defun c:xd_password_1#OnKeyUp
(Character RepeatCount Flags
/) (dcl-Control-SetText xd_password_2 (xdrx_string_left result resultlen))
)
(defun _hook
(hwnd msg wparam lparam ti pos
) (cond ((= msg WM_CHAR
) ;Capture key characters ;|
VK_BACK=8,
VK_RETURN=13,
VK_ESCAPE=27,
VK_SPACE=32
...
|;
(/= code 13)
(/= code 27)
)
)
(xdrx_hook_put_param 42 589825)
)
)
(if (and (= code
8) (> resultlen
0)) (setq resultlen
(1- resultlen
) result
(xdrx_string_left result resultlen
)) )
)
)
)
(xdrx_begin)
(xd::hook:register "_hook" t "password hook");Register the hook function named "password hook"
(dcl-project-import odcl-data "123456")
(dcl-form-show xd_password)
(xd::hook:remove "_hook")
(xdrx_end)
)
=============
The above LISP code uses the XDRX-API, which can be downloaded from
https://github.com/xdcad/XDrx-API and is updated at any time.
The XDRX API encapsulates AcDb, AcEd, AcGe, AcBr... C++ library, using C++ methods to develop LISP programs.Thousands of Lisp functions are available.
Modify message