Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

about grread

3 REPLIES 3
Reply
Message 1 of 4
salman_nsr
703 Views, 3 Replies

about grread

Using Autolisp I want to write code which differentiates between the

still and moving state of mouse. I have written a number of test codes to

do the task. One of them is given below, I have used the grread function.

So far I am not able to achieve the goal. In the following program I have

tried to display state of mouse on command line, i.e. if it is moving or still.

But even if I continueusly move the mouse the output of the program is like this



mouse is moving

mouse is still

mouse is moving

mouse is still

.
.
.
.


Which I do not understand why, if the mouse is continueusly moving the program

should only display mouse is moving and not the other message. Please guide.



(defun c:tst()


(setq coor nil) ; To store coordinates returned by grread.

(setq code nil) ; To store the integer code returned by grread.



(while(/= code 3)

(setq input(grread t))

(setq code(car input))


; If input is being read for first time.

(if(= nil coor)

(progn

(setq coor(cadr input))

)


(progn

(setq newCoor(cadr input))

(if(equal newCoor coor)

(progn

(princ "mouse is still\n")

)

(progn

(princ "mouse is moving\n")

(setq coor newCoor)

)

)

)

)


)

)


Secondly, according to help of grread we can pass a number of arguments. I want to use grread such that it works only

when I move the mouse or If I press a keyboard key. is it possible to do that if so what arguments values we need to pass it.

I think if we use (grread T) it returns the cursor coordinates with return code 5 even if we do not move mouse.
3 REPLIES 3
Message 2 of 4
thatcadguy
in reply to: salman_nsr

Two things are likely...

1) Moving the mouse triggers grread, but not moving the mouse enough doesn't actually change the coordinates, due to rounding
2) Might need to slow down how often (grread) is called

Either way, it doesn't look like you can fix it. I tried inserting a delay and it doesn't really help. Sorry.

Regards, Jake
___________________________
http://thatcadguy.blogspot.com/
Message 3 of 4
Anonymous
in reply to: salman_nsr

Hi,

My two cents:

I'm afraid that for such ambitious task, grread is too primitive a tool.
Most probably it will take something like .NET and some Windows API
function(s) in order to control the mouse the way you want it.

Regards

--
Humans are born with a wide horizon.
As time goes by, the horizon narrows and
narrows, until it becomes a point of view.


a écrit dans le message de news:
6271274@discussion.autodesk.com...
Using Autolisp I want to write code which differentiates between the

still and moving state of mouse. I have written a number of test codes to

do the task. One of them is given below, I have used the grread function.

So far I am not able to achieve the goal. In the following program I have

tried to display state of mouse on command line, i.e. if it is moving or
still.

But even if I continueusly move the mouse the output of the program is like
this



mouse is moving

mouse is still

mouse is moving

mouse is still

..
..
..
..


Which I do not understand why, if the mouse is continueusly moving the
program

should only display mouse is moving and not the other message. Please guide.



(defun c:tst()


(setq coor nil) ; To store coordinates returned by grread.

(setq code nil) ; To store the integer code returned by grread.



(while(/= code 3)

(setq input(grread t))

(setq code(car input))


; If input is being read for first time.

(if(= nil coor)

(progn

(setq coor(cadr input))

)


(progn

(setq newCoor(cadr input))

(if(equal newCoor coor)

(progn

(princ "mouse is still\n")

)

(progn

(princ "mouse is moving\n")

(setq coor newCoor)

)

)

)

)


)

)


Secondly, according to help of grread we can pass a number of arguments. I
want to use grread such that it works only

when I move the mouse or If I press a keyboard key. is it possible to do
that if so what arguments values we need to pass it.

I think if we use (grread T) it returns the cursor coordinates with return
code 5 even if we do not move mouse.
Message 4 of 4
honkinberry
in reply to: salman_nsr

Here's a typical grread dynamic input loop:

(while (and (not EXITFLAG) (setq p2 (grread t 12 0)))
(cond
( (= (car p2) 5) ; tracking
) ; tracking

( (= (car p2) 2) ; keyboard
(setq p2 (cadr p2))
(cond
( (or (and (>= p2 48) (<= p2 57)) ; 0 - 9
) ; number
( (= p2 😎 ; backspace
) ; backspace
( (= p2 13) ; enter
) ; enter
) ; cond
) ; keyboard

( (= (car p2) 3) ; left-click
(setq EXITFLAG t)
) ; leftclick

( (> (car p2) 5) ; right-click
) ; rightclick
) ; cond
) ; while

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost