LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Detect Alt+P key press

Hi.

 

I need to programmatically enable two control keys (Alt-p and Alt-f).

They are to be enabled only during a certain part of the code and set a flag if pressed.

What are the ASCII values for Alt+p, Alt+P, Alt+f, Alt+F? (Alt+p and Alt+P are detected as the same etc.)

 

Is the following the best way to do this?:

1. Create two hidden panel control buttons AltF and AltP. (see code insert)

2. If in correct state then set flag else do nothing.

 

These are special commands to pass or fail a section of automated testing that requires user input. This will allow us to run the test remotely for troubleshooting.

 

Thanks for any advice.

 

 

0 Kudos
Message 1 of 5
(4,495 Views)

Hi,

 

what about installing a panel control callback and checking for keypress events? This way you will receive all keypress events, but you need to react only when you need it. Concerning the key codes, you can check the CVI help for keypress or key code. 

0 Kudos
Message 2 of 5
(4,492 Views)

Wolfgang,

 

Is a panel control callback the same as any panel callback?

I use numerous panels besides the main panel but I display them then hide them when required.

This panel would to be hidden from the user at all times as they cannot be aware of it and never use it. It is for remote troubleshooting only.

Is it possible to have a panel that is hidden at all times?

 

These should be the key codes: 

Ctrl+P = (VAL_MENUKEY_MODIFIER | 'P')

Ctrl+p = (VAL_MENUKEY_MODIFIER | 'p')

Ctrl+F = (VAL_MENUKEY_MODIFIER | 'F')

Ctrl+f = (VAL_MENUKEY_MODIFIER | 'f')

 

Thanks.

0 Kudos
Message 3 of 5
(4,483 Views)

1) I am sorry, I meant panel callback, referring to InstallPanelCallback (there is no panel control callback)

2) You can have a panel that is hidden as long as you wish, but hidden panels will not generate events -> you will need to install and use the panel callback of your (main) panel that receives keypress events

0 Kudos
Message 4 of 5
(4,481 Views)

If you have multiple panels in your UI, and you want to process these special keys regardless of which panel is active, then you would need to add the keypress handling code to each of their respective callbacks (or, if none of these panels have callbacks yet, then they could simply all share the same callback).

 

An easier solution might be to define a main callback (see InstallMainCallback). This callback will receive all the keypress events, regardless of which panel is the active panel.

 

Luis

0 Kudos
Message 5 of 5
(4,438 Views)