LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate a mouse down with a key.

Hello.

Im programming a embedded system running on linux.

Since the system does have a mouse but no mouse buttons I would like to generate a mouse down when, for instance, the key 'j' is pressed.

Is this possible in LabView linux?

Thanks.


Best regards

Andreas Beckman
0 Kudos
Message 1 of 7
(3,262 Views)
Hello!

It is not completely trivial how to achieve this. You say the computer uses a mouse without any buttons and would like to trigger a mouse down event with a key instead. I have a few questions:

1) When you press this key I suppose that you want it to work just like a mouse with buttons would, in other words when your cursor are over a button and you press your mouse button the button on the GUI will be pressed and generate a mouse down event, correct?

2) How will you keep track of where on the GUI you are and if your cursor is over an object or not? By using the 'mouse enter' event?

Please give me more information on what you are trying to achieve and how you would like it to work.

Regards,
Jimmie A.
Applications Engineer, National Instruments
Regards,
Jimmie Adolph
Systems Engineering Manager, National Instruments Northern European Region

Message 2 of 7
(3,221 Views)
Hi again.

1. Yes. When i press a designated key (like a,b or c) I want to generate a mouse down in order to press
a butto or something else, in the gui.

2. Since the system has a mouse just not a mousebutton I guess this wont be a problem.
Or I just dont get the question.

Thanks for your time.

Best regards

Andreas Beckman
0 Kudos
Message 3 of 7
(3,201 Views)
Hello!

More questions from my side!

1. When you press this designated key, should it be the same key for all buttons or a for button 1, b for button 2 and so on?
2. If you have different keys for the buttons on the GUI that will work fine, but if you use the same button you must likely want to check where your cursor is, in other words to check if it is over a specific button and if it is then you can press the key to generate a 'mouse down' event. If it is not over a button you cannot generate a 'mouse down' event.

Regards,
Jimmie A.
Applications Engineer, National Instruments
Regards,
Jimmie Adolph
Systems Engineering Manager, National Instruments Northern European Region

Message 4 of 7
(3,184 Views)
Hello.

Thanks for the quick reply.

I would like just one key to act as mouse1, for all control buttons on the front panel.

A "key2mouse1" converter so to say.

Thanks

Best regards

Andreas
0 Kudos
Message 5 of 7
(3,178 Views)
If you have LabVIEW 7.1, you can do the following.

Use an event structure to capture the keystroke you want to map to mouse down. When the event occurs, use the VIs in the Advanced->Input Device Control palette to query the mouse for its position. Use this position and a look-up table to fire a user event to effect the mouse press (e.g. push a button). You will probably be making heavy use of property nodes to do all this. Note that booleans cannot have Mechanical Action equal to Latch When Pressed or Latch When Released if you use locals or property nodes to set their state. This will necessitate your code performing the initialization and latch code. This is easy with the event structure, but it is a “gotcha” you need to watch out for.

If you have LabVIEW 7.0 or earlier, you may need to call into a system shared library or use the picture control or some other method to get the mouse coordinates. You can search the net for possibilities - here is one.

If you have LabVIEW 6.1 or earlier, you cannot use user events, so substitute a queue driven task handler for your “user events.” You may want to do that, anyway, as it efficiently separates your tasks from your events - something all easily-maintained GUIs do.

Finally, if you use LabVIEW 6.0 or earlier, you will need to poll for the keystroke event, since there is no event structure. About every 50ms should do it. You will get reasonable response without killing your CPU.
0 Kudos
Message 6 of 7
(3,168 Views)
Hello again,

I believe the method DFGray described in his post is the most convenient one in this case. You could most likely do it in other ways as well, but the solution he mentioned has been used before.

Regards,
Jimmie A.
Applications Engineer, National Instruments
Regards,
Jimmie Adolph
Systems Engineering Manager, National Instruments Northern European Region

0 Kudos
Message 7 of 7
(3,145 Views)