Keyborad Language as per AX User Language


Can I somehow change system keyboard language as per my AX user Language.

For Example if my AX user language is Spanish

My keyboard language also should change to spanish.

Question is through which method I get access to keyboard language which I can use for writting code.

Thanks & Regards\



You can use :


In order to change the language based upon your logic you can write the above code.

If you want to change keyboard layout in Windows, use can use WinAPI function ActivateKeyboardLayout. Because it’s not supported directly in AX, you have to implement it in WinAPI class by yourself (or you could encapsulate it in a .NET library with the help of pinvoke).

Hi Martin,

Thanks for the help.

can you please help me to elaborate it through code. because I tried it but not able to get the keyboard language and also not able to change keyboard language through code.

Thanks & Regards


Hi vishal,

infolog.language(); this gives user’s language and we can change user’s language through this.

But my requirement is how to get keyboard language through code.

For Example if my AX user language is Spanish

I want my keyboard language should also change to spanish.

I intended to use P/Invoke, but I found a better way. Check out this example (in X++):

System.Globalization.CultureInfo culture;
System.Windows.Forms.InputLanguage language;

    culture = System.Globalization.CultureInfo::GetCultureInfo('es-ES');
    language = System.Windows.Forms.InputLanguage::FromCulture(culture);
    // ... error handling ...

Hi Martin,

When I compile this code:


culture = System.Globalization.CultureInfo::GetCultureInfo(‘es-ES’);culture = es-ES

language = System.Windows.Forms.InputLanguage::FromCulture(culture);Language = Null & culture = es-ES

System.Windows.Forms.InputLanguage::set_CurrentInputLanguage(language);Language = Null


So it doesn’t change my keyboard language.

I am using AX-2012 R2.

I have directly tried to assign the value to language but not succeeded. kindly suggest me what should I do

It seems that you don’t have es-ES layout loaded in Windows, so you naturally can’t switch to it.

I have tried it with other languages also which are loaded in my window, but the result is same.

I successfully tested the code in Windows7 / AX2009. It works without any issue for me, the only prerequisite is to have the languages installed so you can switch between them manually. Installation of additional language is not in scope of the script.

I can’t know what exactly is the wrong in your environment - that’s up to you to debug it. If you provided more details about your configuration, it would be possible at least to test it whether it’s not an OS-related issue or so.

my system configuration is Windows7 / AX2012-R2. I will try to find out what is wrong in my environment

thanks & Regards