LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Need a LabWindows/CVI function that will read a keyboard character that is stored in the keyboard buffer

I am trying to modify a LabWindows/CVI version 7.0 program running on Windows XP that I did not write.  One goal is to be able to press the ESC key during program run and have it exit the program gracefully.  The program is not too complicated; it is a test of a printed circuit board assembly that does acquisition of power supply voltage/current and programming of flash with application programs.  There are a few panels and a bunch of message popups.  I am familiar with using a callback function within a panel as I have tried the suggestion at the following link - http://forums.ni.com/ni/board/message?board.id=180&message.id=7673
It works great when the panels have focus, but the message popups continually take focus away from the panels, making this method useless.  I am hoping someone has developed a function that can read a key press from the Windows keyboard buffer.  In this way I can periodically poll the buffer for ESC key presses and then act on them. 
0 Kudos
Message 1 of 5
(3,388 Views)
You can use
SHORT GetKeyState(
  int nVirtKey   // virtual-key code
);
function of windows SDK library.
Let me know if you have trouble using this. I think I have wrote a function before. I can find it
and post it here if you need.
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 2 of 5
(3,370 Views)

virtualkey for escape is

VK_ESCAPE

or

0x1B.

Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 3 of 5
(3,371 Views)

Thanks for the tip, Sheetal.  Looks like it will take me a while to see if this will work.  If you have a function that you wrote, I would be interested in looking at it.  Thanks again.

Craig

0 Kudos
Message 4 of 5
(3,356 Views)
 do
 {
    key = GetKeyState(0x1B);    //Include windows.h on top of your file. First file.
    if((key & 0x1000) == 0x1000)   //Escape pressed
    {
              Delay(0.1);  //do your stuff here 
    }
     ProcessSystemEvents();
 }while(1);   //Replace this while loop with your own loop
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 5 of 5
(3,339 Views)