08-30-2020 10:10 PM - edited 08-30-2020 10:55 PM
I have a simple program to simulate keystrokes in LabVIEW.
As shown in the image, if I press the bottom right button, it generates a string "Hello" in the string field.
However, I'm only able to make the key focus on the string field I created("Output" in the image).
I want to have my key focus on places such as a text file, google search engine, or generally any other place.
Not sure how to start this. I will appreciate any suggestions.
I have also attached the code underneath. Thanks in advance!
This LabVIEW code is based on https://forums.ni.com/t5/Example-Code/Programmatically-Simulate-Key-Strokes-in-LabVIEW/ta-p/3521756
Solved! Go to Solution.
08-31-2020 07:26 AM
The only way to key focus on things outside of LabVIEW, to my knowledge, would be to simulate mouse clicks using System Exec. This isn't dynamic at all though. You tell the mouse to go to (x, y) pixel location on screen and then click. If the search bar isn't there, nothing works. If you change your screen resolution, nothing works. If your computer is randomly crapping out for some reason and the click doesn't register, well...
If you don't mind me asking, what are you trying to do with this?
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
08-31-2020 07:41 AM - edited 08-31-2020 07:54 AM
Thanks for the reply!
I am currently trying to send key commands to control an external game in "UNITY".
I originally thought it doesn't work is because the key couldn't focus on UNITY but now I think about it this might not be the problem.
Now, I am thinking that I am probably only controlling Window's keyboard. And the UNITY app uses a completely different keyboard API.
So instead of sending ASCII code to Window's keyboard API, I need to find how I can send it to UNITY'S keyboard API.
Not sure If I'm in the correct direction, but this is where I am stuck now. Trying to find UNITY's Keyboard API.