11-05-2009 02:45 AM
Hi,
I'm trying to detect if mouse button is pressed. For now I have managed detecting mouse button status using Event Structure but my code inside loop is paused then. I would like to perform code inside while loop and to have one boolen indicator saying if mouse button is pressed or not. Code inside While loop must run all the time.
I have attached vi described above.
Solved! Go to Solution.
11-05-2009 03:13 AM
11-05-2009 03:14 AM
hello...cant open your vi as it is in 8.6
can u post it in 8.5 version?
well when event structure is taken you can track the value change event of the button and at the same time code inside while loop can run.
i dont know what is there in your while loop but this is what i guess you want...
insted of or gate you will have your own code...
11-05-2009 03:30 AM - edited 11-05-2009 03:31 AM
Thanks, but I'm not sure what have you try to show me with your code. I have very large project running inside while loop. I must be able to know if left mouse button is currently pressed or not. If you press left mouse button while hovering over plot or indicator, you will see LED turning ON signaling pressed mouse button. My code inside while loop must run constantly regardles of mouse button status. I'll use information about mouse button state to disable only one small part of code inside my project.
Here is LV8.5 version.
11-05-2009 03:37 AM - edited 11-05-2009 03:37 AM
Pnt,
I'm not sure that is a option. I'm using sbRIO for signal acquisiton and I'm doing analysis and recording of signals. I think that while loop inside while loop is not a option in my case.
11-05-2009 03:43 AM
Hi,
you can use time out function.
ex attached below
11-05-2009 03:44 AM
The post before mentions to have another while loop running in parellel containing event structure to handle the user events.
11-05-2009 03:54 AM
Vsh wrote:The post before mentions to have another while loop running in parellel containing event structure to handle the user events.
Exactly.
Two loops in parallel. One for the events for mouse and one for analysis and recording of signals.
The solution shrekt has given, is a bad one, allthough it may work.
It will slow down your loop, (for 10 msec will hung).
11-05-2009 04:16 AM
I have set timeout to 1 milisecond. I think it shoul be ok. I will also try using parallel loops.
08-11-2010 04:37 AM
hi
i am working on a project to use optical mouse as a distanced logging device that is i record the mouse position as the mouse moves along a path then I make a relation between the mouse couser position in pixel with length moved by body of the mouse in mm.
Every thing is OK when I use the mouse in short ranges ( 30- 40 mm) and the crusor is in the range of the monitor but when I wana move it in about 1 meter or more which is out of the range of the monitor screen problem began
at the top of the monitor the position is fixed and it do not change anymore. For recording pixels greater than the vertical limit of the monitor I try to set the mouse position to a fix number to get the changes of the mouse position by set_crusor_pos.vi .
but it is not effective.
So I want to save the absolute changes of the mouse position even out of the range of the monitor e.i. if the mouse crouser is at the top of the monitor and if i move it upper I should record a movement in the up side direction.
I want to use my optical mouse a ruler to measure lengths in the range of 1-2 meter.
Many thanks