From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I send keyboard combinations programatically

I currently have a labview applications that sends commands to a third party application, so I can control it through labview. The problem I am having, is that I need to send a key combination (ctrl+shift+r), but I am unable to do this through labview.

I found a post that has a discussion about how to do this, but I can't get their code to work, based on my needs.

This is the website I found, that has this code.

https://forums.ni.com/t5/LabVIEW/programmatic-keyboard-events/td-p/887997?profile.language=es

Code.JPG

0 Kudos
Message 1 of 8
(2,736 Views)

Maybe you should give your 3rd party the keyboard focus?

 

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019N3tSAE&l=en-CA

0 Kudos
Message 2 of 8
(2,728 Views)

I am already doing that, beore sending the keyboard commands.

please see the picture, to see the code that I am using.

Thanks for responding.

0 Kudos
Message 3 of 8
(2,725 Views)

Oh yeah I see of course.

 

Did you try adding a 100 ms delay after you setforegroundwindow ? Then press/hold CTRL+SHIFT+R.

0 Kudos
Message 4 of 8
(2,700 Views)

If the three key presses are being sent simultaneously, there's no guarantee you're sending CTRL + SHIFT + R. Modifier keys generally have to be pressed before pressing the letter. Instead try sequencing the CTRL, SHIFT and R key presses (in that order). You might also try setting the two modifier keys first (CTRL + SHIFT), wait maybe 50ms, then send the R key.




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
Message 5 of 8
(2,677 Views)

Be careful of the key order when pressed the combine key(CTRL+SHIFT+R).

0 Kudos
Message 6 of 8
(2,593 Views)

Not sure how that subVI works (probably SendKeys functions). If you'd use SendMessage, you can send a WM_KEYDOWN and WM_KEYUP (maybe WM_SYSKEYDOWN\UP) messages. Benefit would be that the application doesn't need to have focus.

0 Kudos
Message 7 of 8
(2,588 Views)

I agreed is better used the windows API function; If pressed combine keypad,maybe you can refer the attchment.

0 Kudos
Message 8 of 8
(2,559 Views)