LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use a pushbutton to access a menu item ie. CTRL P or Print Screen

Base Package of Labview
0 Kudos
Message 1 of 3
(3,301 Views)
You can simulate keystrokes for CTRL + P. That's an easy way of doing. There are bunch of examples on ni. Search specifically for keystrokes.vi or keystrokes-1.vi or search with a keyword "keystroke(s), simulate keyboard

Kudos are the best way to say thanks 🙂
0 Kudos
Message 2 of 3
(3,298 Views)
Hi Mark10!

Okay, there are a couple ways you can accomplish this. First off, you will need to use an event structure to capture when the user clicks on the pushbutton (use the "mouse down" event).

Now, there are two ways to accomplish printing the screen (code that goes inside the event structure):

1) The first way is more specific to just printing the screen (as opposed to giving you access to the menu items). You can open a reference to the VI (using the Open VI Reference.vi) and use an invoke node (using the method: Print Panel to Printer) to print the front panel of your VI.

2) The second way is a much more powerful way to access your menu items. You can actually simulate key strokes (such as CTRL->P) by using a Call Library Function Node (using the keybd_event class in the user32.dll). This functionality also gives you access to all of your menu selections because you can simulate pressing ALT followed by any other key.

See the two attached pictures below for more reference. Also, refer to the link below for more information on the keybd_event function: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/keybd_event.asp
Travis H.
LabVIEW R&D
National Instruments
Message 3 of 3
(3,287 Views)