aqEnvironment.IsLanguageSupported Method

Applies to TestComplete 15.63, last modified on April 23, 2024

Description

The IsLanguageSupported method is used to determine whether support for the specified language is installed on your computer.

Declaration

aqEnvironment.IsLanguageSupported(Locale)

Locale [in]    Required    Integer    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Locale

Language ID. For example, the language ID of US English is 0409 (in hexadecimal), German - 0407 (in hexadecimal), French - 040C (in hexadecimal), and so on. For the full list of language ID values, refer to [MS-LCID]: Windows Language Code Identifier (LCID) Reference, section 2.2 "LCID Structure".

Result Value

If support for the specified language is installed on the computer, the method returns True, otherwise - False.

Example

The code below demonstrates how you can check whether the desired language is supported by your system before setting it as the current keyboard layout for the NOTEPAD process.

JavaScript, JScript

function IsLanguageSupportedExample()
{
  WshShell.Run("notepad.exe", SW_NORMAL);
  var wNotepad = Sys.Process("notepad");
  var EditForm = wNotepad.Window("Notepad").Window("Edit");

  // US English
  var LangID = 0x409;
  var LocaleID = "00000409";

  if (aqEnvironment.IsLanguageSupported(LangID))
  {
    aqEnvironment.SetKeyboardLayout(wNotepad.Id, LocaleID);
    EditForm.Keys("Hello");
  }
  else
  {
    Log.Message("The specified language is not supported.");
  }
}

Python

def IsLanguageSupportedExample():
  WshShell.Run("notepad.exe", SW_NORMAL)
  wNotepad = Sys.Process("notepad")
  EditForm = wNotepad.Window("Notepad", "Untitled - Notepad", 1).Window("Edit", "", 1)

  # US English
  LangId = 0x409
  LocaleId = "00000409"

  if aqEnvironment.IsLanguageSupported(LangId):
    aqEnvironment.SetKeyboardLayout(wNotepad.Id, LocaleId)
    EditForm.Keys("Hello")
  else:
    Log.Message("The specified language is not supported.")

VBScript

Sub IsLanguageSupportedExample
  Dim wNotepad, EditForm, LangID, LocaleID

  Call WshShell.Run("notepad.exe", SW_NORMAL)
  Set wNotepad = Sys.Process("notepad")
  Set EditForm = wNotepad.Window("Notepad").Window("Edit")

  ' US English
  LangId = &H409
  LocaleId = "00000409"

  If (aqEnvironment.IsLanguageSupported(LangID)) Then
    Call aqEnvironment.SetKeyboardLayout(wNotepad.Id, LocaleID)
    Call EditForm.Keys("Hello")
  Else
    Call Log.Message("The specified language is not supported.")
  End If
End Sub

DelphiScript

procedure IsLanguageSupportedExample;
var wNotepad, EditForm, LangID, LocaleID;
begin
  WshShell.Run('notepad.exe', SW_NORMAL);
  wNotepad := Sys.Process('notepad');
  EditForm := wNotepad.Window('Notepad').Window('Edit');

  // US English
  LangID := $409;
  LocaleID := '00000409';

  if aqEnvironment.IsLanguageSupported(LangID) then
  begin
    aqEnvironment.SetKeyboardLayout(wNotepad.Id, LocaleID);
    EditForm.Keys('Hello');
  end
  else
    Log.Message('The specified language is not supported.');
end;

C++Script, C#Script

function IsLanguageSupportedExample()
{
  WshShell["Run"]("notepad.exe", SW_NORMAL);
  var wNotepad = Sys["Process"]("notepad");
  var EditForm = wNotepad["Window"]("Notepad")["Window"]("Edit");

  // US English
  var LangID = 0x409;
  var LocaleID = "00000409";

  if (aqEnvironment["IsLanguageSupported"](LangID))
  {
    aqEnvironment["SetKeyboardLayout"](wNotepad["Id"], LocaleID);
    EditForm["Keys"]("Hello");
  }
  else
  {
    Log["Message"]("The specified language is not supported.");
  }
}

See Also

GetKeyboardLayout Method
SetKeyboardLayout Method
Keys Method
Keys Action
Simulating Keystrokes

Highlight search results