NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to determine which keyboard key was pressed?

Solved!
Go to solution

Hello Community,

 

I am using TestStand 2017 32-bit.

 

Is there a way to determine which key was pressed on the keyboard or mouse click in a Post-Expression?

 

Thank you

0 Kudos
Message 1 of 4
(2,687 Views)

We are going to need more information. For instance, what Step type are you using? Is this a Message Popup. and you have multiple buttons and you want to know which one the user pressed?

 

Is it a code module that is called? etc...

 

If you could post an example so we see what you are trying to achieve exactly.

 

0 Kudos
Message 2 of 4
(2,639 Views)

I am using a message popup. The message popup has 2 buttons (Yes and No). I understand that I can do "Step.Result.ButtonHit" to know if Yes or No was selected, but I want to select the button with a specific key press. For example, "Y" key for yes and "N" key for n. The reason I don't want to use the enter key, because sometimes the user can be trigger happy with the enter key and skip through important messages. When it is an important message that the user needs to read, I want to make sure the user needs to use a different key press to advance passed the message popup. One thought is that I can switch the message popup active control to a dummy 3rd button, but then it looks weird.

 

I am wondering if there is a way to achieve this without having to use a code module. If not, then I'll have my answer.

0 Kudos
Message 3 of 4
(2,634 Views)
Solution
Accepted by topic author MechUnit

Ah, makes sense now. I know of no way to change the key bindings for the message popup. Usually when I do something like you are asking I just use a code module.

 

Just throwing out another idea you can do if you don't want to develop a code module. You could always change the popup to a response string that needs to be typed as either "yes" or "no". Then you would just have the step loop on itself until the conditions were made. That way it's more interactive than hitting "Enter" and they have to read to know what to enter for it to proceed. So the looping is like this :

ShockHouse_0-1591975133316.png

 

I attached the example in case you are interested.

Message 4 of 4
(2,623 Views)