ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Possible to change keyboard input language programmatically ?

Solved!
Go to solution

Hi to all! So as the title says, if somebody has 2 or more input languages installed in Windows is there any way in LabVIEW to get the current language and change that to the preferred one? I have a string control which needs to accept only english characters to avoid problems

0 Kudos
Message 1 of 9
(7,341 Views)

Language bar => settings => Advanced Key Settings, create a shortcut for English.  For example Ctrl+Shift+0.

Simulate a keyboard press, and send it your window.

image.png

 

George Zou
0 Kudos
Message 2 of 9
(7,268 Views)

Another option could be to filter your input to the control by using the "key down?" event.

0 Kudos
Message 3 of 9
(7,248 Views)

Thanks, zoo.I agree that this would be an easy solution but it's kind of personal one. I don't think it would be convenient for deployment of an application

0 Kudos
Message 4 of 9
(7,228 Views)

Can we assume English (US) is installed?

 

George Zou
0 Kudos
Message 5 of 9
(7,210 Views)

Use Windows API post a message (WM_INPUTLANGUAGECHNAGEREQUEST = 0x50) to the window:

PostMessage(hWnd, 0x50, 0, 0x0409);

 

0x0409 is US English.

 

 

George Zou
Message 6 of 9
(7,191 Views)
Solution
Accepted by topic author blackfinger

For those who are not familiar Windows API, try this llb.

 

George Zou
Message 7 of 9
(7,157 Views)

Hello Zou,

 

thank you for posting Inpullanguage.llb.

Although in my case Set InputLanguage.vi doesn't seem to work. Keyboard layout wouldn't switch when I execute it.

Enumerate InputLanguages.vi and Get Default InputLanguage.vi work just fine.

 

I wonder if it could be caused by some Windows background service not running?

In VI i'm working on I need to set ENG-US keyboard layout to avoid mistakes as user inputs data.

 

My set is as follows:

LabView 2020 full 32-bit

Windows 10 Pro x64

 

0 Kudos
Message 8 of 9
(3,651 Views)

The demo vi works fine on my Windows 11 with LabVIEW 2021.

 

image.pngimage.png

 

George Zou
0 Kudos
Message 9 of 9
(3,577 Views)