07-08-2025 06:59 PM
Howdy everyone!
So I have been scratching my head for a while now and am quickly running out of hairs to pull out.
I am trying to get LabView to send virtual keys to a TeraTerm instance. I am able to bring said TeraTerm window into primary focus and send other character by means of the user32.dll and program that I have seen in countless other forum posts. I am mainly trying to send the “down arrow” key to scroll through options present in TeraTerm. In the “simulate_keystrokes” example, there is a “DOWN” option. This works fine in other programs like Notepad, but TeraTerm is receiving the number “2” as if I was pressing the key on the side numberpad. Any attempts at holding control, shift, alt, or fn keys (again using the user32.dll) and then sending the down arrow result in the same number “2” being sent, or just nothing at all.
I have seen some notes about escape-codes, but have not seen any meaningful examples of how to implement these. Any pointers on that front would also be more than welcome, along with other crazy ideas that may be floating around.
I am currently running LabView 2018 SP1 on Windows 10, and the latest version of TeraTerm.
Thanks in advance for any tips 🙂
Solved! Go to Solution.
07-09-2025 12:01 AM
Hello!
You're likely getting "2" when sending the down arrow to TeraTerm because terminal emulators expect specific escape sequences (e.g., ESC [ B for down arrow) rather than standard Windows virtual key codes. The most reliable solution is to send these escape sequences directly to the TeraTerm window using PostMessage with WM_CHAR in LabVIEW, or by having LabVIEW generate and execute a TeraTerm macro (.ttl) file. If possible, consider bypassing TeraTerm entirely and directly communicating with your device via LabVIEW's VISA functions for serial or TCP/IP communication, which is the most robust approach.
07-09-2025 03:12 AM
Great ideas! I will give the PostMessage idea a go and see what happens.
i could try a macro file, but that makes the TeraTerm window close and re-open which is a bit jarring when doing this constantly (down arrow is needed a lot). I have been working on the VISA serial read/write options , but the text that is output to the serial port is formatted to be viewed in a certain width/height terminal, otherwise it looks funny. This serial output was not chipset by me and I have no control over it, so can’t change. Text is output to three of these terminals at the same time, so the final VI would be quite large and extend past the screen in all likelihood. A possible idea for sure, but not great.
Thanks for the ideas!
07-09-2025 05:45 AM
THANK YOU SO MUCH!
I managed to get the PostMessage to work after some additional searching for correct message formatting. You have to pass the WM_CHAR value in, as well as the key code being pressed. I used the following article for the correct hex codes:
https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes?redirectedfrom=MSDN
Please see attached for the VI I made. It determines the window handler by window title, and passes that into the PostMessage function. Hopefully this can help others too.
07-09-2025 05:46 AM
Didn't take the upload last time, so here it is again...