A similar Windows function,SetCursorPos
, can be used to set the cursor position. TheSetCursorPos
function takes twoLONG
s. The following code defines an interface function to callSetCursorPos
.
(fli:define-foreign-function (set-cursor-position "SetCursorPos") ((x long) (y long)) :result-type bool)
For example, the cursor position can now be set to be near the top left corner by simply using the following command:
(set-cursor-position 20 20)
For a more extravagant example, define and execute the following function:
(defun test-cursor () (dotimes (x 10) (dotimes (d 300) (let ((r (/ (+ d (* 300 x)) 10.0))) (set-cursor-position (+ 300 (floor (* r (cos (/ (* d pi) 150.0))))) (+ 300 (floor (* r (sin (/ (* d pi) 150.0))))) ))))) (test-cursor)