Ask a Question

aqEnvironment.SetKeyboardLayout always return false

gabrielg
Contributor

aqEnvironment.SetKeyboardLayout always return false

Hi

I am trying to test multiple languages in our application  and in order to do that i am trying to use the aqEnvironment.SetKeyboardLayout() method. The problem is that I get always false as the return, and i dont get to change the imput method. Even if a try the following example from the manual, the line with SetKeyboardLayout returns always false, and USEnglish is not set. 

 

Any idea what i have to do to make it work?

Thanks

 

function IsLanguageSupportedExample()
{
Win32API.WinExec("notepad.exe", SW_NORMAL);
var wNotepad = Sys.Process("notepad");
var EditForm = wNotepad.Window("Notepad", "Untitled - Notepad", 1).Window("Edit", "", 1);
var USEnglish = 0x0409;
if (aqEnvironment.IsLanguageSupported(USEnglish))
{
aqEnvironment.SetKeyboardLayout(wNotepad.Id, USEnglish)
EditForm.Keys("Hello!");
}
else
{
Log.Message("The specified language is not supported.");
}
}

3 REPLIES 3
baxatob
Community Hero

Re: aqEnvironment.SetKeyboardLayout always return false

Possibly it's a bug.

 

I am also receiving the False in any case.

 

As I can see in the sample, the aqEnvironment.SetKeyboardLayout method takes Locale parameter as an integer (hexadecimal), however in the method declaration it should be a string.

 

And aqEnvironment.GetKeyboardLayout also returns the string.

 

I was trying to use Locale as a string with SetKeyboardLayout (like "00000409"), but it also failed.

 

Let wait for SmartBear support to confirm.

 

lang.png

 

gabrielg
Contributor

Re: aqEnvironment.SetKeyboardLayout always return false

Ok thanks for your contribution

Let's wait for Smartbear to say something

UnveN
Staff

Re: aqEnvironment.SetKeyboardLayout always return false

Hello!

 

@gabrielg

The Locale parameter (despite its name) specifies the identifier of the layout to be set (as correctly stated in the help topic SetKeyboardLayout Method). The identifier is string of 8 characters composed of the hexadecimal values of language and device identifiers ("00000409" for US English). However the help topic example is not correct and uses only hex value of language id as Locale parameter thus failing the function. We should definitely correct this sample 😃

Also note that keyboard layout has no impact on the Keys method as it uses virtual keys for input. So you don't need to change the layout to input different language characters with Keys.

 

@baxatob

It is strange that SetKeyboardLayout with "00000409" as Locale did not work for you as it did for me. Also according to the screenshot provided lang = 0x0426 was used as Locale. Also please make sure that the language is supported (using IsLanguageSupported) and the device identifier (first four characters of the layout identifier string) corresponds to the layout installed in your system. If it still does not work for you please open a support ticket regarding the issue with more detailed information - we will try our best to reproduce and fix this.

 

Hope this helps.

Stanislav
SmartBear Developer
cancel
Showing results for 
Search instead for 
Did you mean: