Jump to content

Change the keyboard language in custom window


Recommended Posts

Hi friends, I have a question, please.
I have created a window containing a edit box
I need to know how to change the keyboard language,
e.g :
if a user open the  script  it will be change the keyBord language   in window automatically into English
I found more examples but didn't work with me .
Note:  
 I use the windows 10 os
Please help me .
thanks in advance to all
with my Greetings and my appreciation for all users and admins

Link to comment
Share on other sites

$hWnd = GUICreate() 
; Or
$hWnd = WinGetHandle()


_WinAPI_SetKeyboardLayout ( $hWnd, $iLanguage [, $iFlags = 0] )

;~  The input locale identifier $iLanguage:
;~ 0x0436 - Afrikaans
;~ 0x041C - Albanian
;~ 0x0401 - Arabic
;~ 0x1401 - Arabic Algeria
;~ 0x3C01 - Arabic Bahrain
;~ 0x0C01 - Arabic Egypt
;~ 0x0801 - Arabic Iraq
;~ 0x2C01 - Arabic Jordan
;~ 0x3401 - Arabic Kuwait
;~ 0x3001 - Arabic Lebanon
;~ 0x1001 - Arabic Libya
;~ 0x1801 - Arabic Morocco
;~ 0x2001 - Arabic Oman
;~ 0x4001 - Arabic Qatar
;~ 0x0401 - Arabic Saudi Arabia
;~ 0x2801 - Arabic Syria
;~ 0x1C01 - Arabic Tunisia
;~ 0x3801 - Arabic U.A.E
;~ 0x2401 - Arabic Yemen
;~ 0x042B - Armenian
;~ 0x044D - Assamese
;~ 0x082C - Azeri Cyrillic
;~ 0x042C - Azeri Latin
;~ 0x042D - Basque
;~ 0x0813 - Belgian Dutch
;~ 0x080C - Belgian French
;~ 0x0445 - Bengali
;~ 0x0416 - Portuguese (Brazil)
;~ 0x0402 - Bulgarian
;~ 0x0455 - Burmese
;~ 0x0423 - Byelorussian (Belarusian)
;~ 0x0403 - Catalan
;~ 0x0C04 - Chinese Hong Kong SAR
;~ 0x1404 - Chinese Macau SAR
;~ 0x0804 - Chinese Simplified
;~ 0x1004 - Chinese Singapore
;~ 0x0404 - Chinese Traditional
;~ 0x041A - Croatian
;~ 0x0405 - Czech
;~ 0x0406 - Danish
;~ 0x0413 - Dutch
;~ 0x0C09 - English Australia
;~ 0x2809 - English Belize
;~ 0x1009 - English Canadian
;~ 0x2409 - English Caribbean
;~ 0x1813 - English Ireland
;~ 0x2009 - English Jamaica
;~ 0x1409 - English New Zealand
;~ 0x3409 - English Philippines
;~ 0x1C09 - English South Africa
;~ 0x2C09 - English Trinidad
;~ 0x0809 - English U.K.
;~ 0x0409 - English U.S.
;~ 0x3009 - English Zimbabwe
;~ 0x0425 - Estonian
;~ 0x0438 - Faeroese
;~ 0x0429 - Farsi
;~ 0x040B - Finnish
;~ 0x040C - French
;~ 0x2C0C - French Cameroon
;~ 0x0C0C - French Canadian
;~ 0x300C - French Cote d'Ivoire
;~ 0x140C - French Luxembourg
;~ 0x340C - French Mali
;~ 0x180C - French Monaco
;~ 0x200C - French Reunion
;~ 0x280C - French Senegal
;~ 0x1C0C - French West Indies
;~ 0x240C - French Congo (DRC)
;~ 0x0462 - Frisian Netherlands
;~ 0x083C - Gaelic Ireland
;~ 0x043C - Gaelic Scotland
;~ 0x0456 - Galician
;~ 0x0437 - Georgian
;~ 0x0407 - German
;~ 0x0C07 - German Austria
;~ 0x1407 - German Liechtenstein
;~ 0x1007 - German Luxembourg
;~ 0x0408 - Greek
;~ 0x0447 - Gujarati
;~ 0x040D - Hebrew
;~ 0x0439 - Hindi
;~ 0x040E - Hungarian
;~ 0x040F - Icelandic
;~ 0x0421 - Indonesian
;~ 0x0410 - Italian
;~ 0x0411 - Japanese
;~ 0x044B - Kannada
;~ 0x0460 - Kashmiri
;~ 0x043F - Kazakh
;~ 0x0453 - Khmer
;~ 0x0440 - Kirghiz
;~ 0x0457 - Konkani
;~ 0x0412 - Korean
;~ 0x0454 - Lao
;~ 0x0426 - Latvian
;~ 0x0427 - Lithuanian
;~ 0x042F - FYRO Macedonian
;~ 0x044C - Malayalam
;~ 0x083E - Malay Brunei Darussalam
;~ 0x043E - Malaysian
;~ 0x043A - Maltese
;~ 0x0458 - Manipuri
;~ 0x044E - Marathi
;~ 0x0450 - Mongolian
;~ 0x0461 - Nepali
;~ 0x0414 - Norwegian Bokmol
;~ 0x0814 - Norwegian Nynorsk
;~ 0x0448 - Oriya
;~ 0x0415 - Polish
;~ 0x0816 - Portuguese
;~ 0x0446 - Punjabi
;~ 0x0417 - Rhaeto-Romanic
;~ 0x0418 - Romanian
;~ 0x0818 - Romanian Moldova
;~ 0x0419 - Russian
;~ 0x0819 - Russian Moldova
;~ 0x043B - Sami Lappish
;~ 0x044F - Sanskrit
;~ 0x0C1A - Serbian Cyrillic
;~ 0x081A - Serbian Latin
;~ 0x0430 - Sesotho
;~ 0x0459 - Sindhi
;~ 0x041B - Slovak
;~ 0x0424 - Slovenian
;~ 0x042E - Sorbian
;~ 0x040A - Spanish (Traditional)
;~ 0x2C0A - Spanish Argentina
;~ 0x400A - Spanish Bolivia
;~ 0x340A - Spanish Chile
;~ 0x240A - Spanish Colombia
;~ 0x140A - Spanish Costa Rica
;~ 0x1C0A - Spanish Dominican Republic
;~ 0x300A - Spanish Ecuador
;~ 0x440A - Spanish El Salvador
;~ 0x100A - Spanish Guatemala
;~ 0x480A - Spanish Honduras
;~ 0x4C0A - Spanish Nicaragua
;~ 0x180A - Spanish Panama
;~ 0x3C0A - Spanish Paraguay
;~ 0x280A - Spanish Peru
;~ 0x500A - Spanish Puerto Rico
;~ 0x0C0A - Spanish Spain (Modern Sort)
;~ 0x380A - Spanish Uruguay
;~ 0x200A - Spanish Venezuela
;~ 0x0430 - Sutu
;~ 0x0441 - Swahili
;~ 0x041D - Swedish
;~ 0x081D - Swedish Finland
;~ 0x100C - Swiss French
;~ 0x0807 - Swiss German
;~ 0x0810 - Swiss Italian
;~ 0x0428 - Tajik
;~ 0x0449 - Tamil
;~ 0x0444 - Tatar
;~ 0x044A - Telugu
;~ 0x041E - Thai
;~ 0x0451 - Tibetan
;~ 0x0431 - Tsonga
;~ 0x0432 - Tswana
;~ 0x041F - Turkish
;~ 0x0442 - Turkmen
;~ 0x0422 - Ukrainian
;~ 0x0420 - Urdu
;~ 0x0843 - Uzbek Cyrillic
;~ 0x0443 - Uzbek Latin
;~ 0x0433 - Venda
;~ 0x042A - Vietnamese
;~ 0x0452 - Welsh
;~ 0x0434 - Xhosa
;~ 0x0435 - Zulu

 

Regards,
 

Link to comment
Share on other sites

Hi
I tried and it didn't work with me
can you help me to set the keybord language to the english if i open this script
please

 

 

local $HWND = GUICreate("english to arabic translator", 400, 400)
GUICtrlCreateLabel("Write the English text here: ", 50, 10, 150, 60)
local $Input = GUICtrlCreateInput("", 50, 30, 200, 60)
local $Translate = GUICtrlCreateButton("&Translate", 0, 100, 50, 50, 0x01)
local $exit = GUICtrlCreateButton("&exit", 100, 100, 50, 50)


GUISetState(@sw_show, $HWND)
while 1
switch GUIGetMSG()
case $exit
exit
EndSwitch
Wend

Link to comment
Share on other sites

Sample scripts (Bing Translator API) for English to Arabic OR Any lanuage to Arabic Translator :

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPISys.au3>

#Region ### START GUI section ### Form=
Global $hWnd = GUICreate("English to Arabic Translator", 630, 162, -1, -1)
GUICtrlCreateLabel("Write the English text here:", 10, 2, 246, 17)
Global $eInput = GUICtrlCreateEdit("", 8, 25, 250, 100, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_VSCROLL))
GUICtrlSetData(-1, "Language text!")
GUICtrlCreateLabel("وقد ترجم النص إلى العربية:", 368, 2, 252, 17, $SS_RIGHT, $WS_EX_LAYOUTRTL)
Global $eOutput = GUICtrlCreateEdit("", 368, 25, 250, 100, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_VSCROLL), $WS_EX_LAYOUTRTL)
GUICtrlSetData(-1, "")
Global $bTranslate = GUICtrlCreateButton("Translate/ترجمه", 268, 25, 88, 50, $BS_DEFPUSHBUTTON)
Global $bCopy = GUICtrlCreateButton("Copy/نسخ", 268, 88, 88, 33)
Global $labStatus = GUICtrlCreateLabel("Ready!", 10, 134, 608, 21)

GUISetState(@SW_SHOW)
#EndRegion ### START GUI section ### Form=

Global Const $iLanguage = 0x0409
_WinAPI_SetKeyboardLayout($hWnd, $iLanguage)

Global $sTextToTranslated, $sTextTranslatedToArabic

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $bCopy
            $sTextToTranslated = GUICtrlRead($eOutput)
            MsgBox(64, "Copy to clipboard", ClipPut($sTextToTranslated) ? "Text translated has copy to Cliboard" : "Copy to Cliboard ERROR", Default, $hWnd)
        Case $bTranslate
            GUICtrlSetData($labStatus, "Translating...")

            GUICtrlSetData($eOutput, "")
            $sTextToTranslated = GUICtrlRead($eInput)
            $sTextTranslatedToArabic = _TranslateEnglishToArabic($sTextToTranslated)
            GUICtrlSetData($eOutput, $sTextTranslatedToArabic)

            GUICtrlSetData($labStatus, "Done!")
    EndSwitch
    Sleep(10)
WEnd

Func _TranslateEnglishToArabic($sEnglish = "")
    Local $sTranslated = BingTranslator($sEnglish, "en", "ar")
    Return $sTranslated
EndFunc   ;==>_TranslateEnglishToArabic

Func BingTranslator($sText, $sFrom = "auto", $sTo = "en")
    Local $sClient = "http://api.microsofttranslator.com/V2/Http.svc/"
    Local $appID = 'appId=68D088969D79A8B23AF8585CC83EBA2A05A97651'
    Local $Data = BinaryToString(StringToBinary($sText, 4))
    If $sFrom == "auto" Then
        $sFrom = InetRead($sClient & 'Detect?' & $appID & "&text=" & $Data, 3)
        $sFrom = StringRegExpReplace(BinaryToString($sFrom, 4), ".*>(.*)<.*", "$1")
    EndIf
    Local $Result = InetRead($sClient & 'Translate?' & $appID & "&from=" & $sFrom & "&to=" & $sTo & "&text=" & $Data, 3)
    $Result = StringRegExpReplace(BinaryToString($Result, 4), ".*>(.*)<.*", "$1")
    Return $Result
EndFunc   ;==>BingTranslator

 

Regards,
 

Link to comment
Share on other sites

I can not edit posts!
Forum fails with Arabic!

Script fixed:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPISys.au3>

#Region ### START GUI section ### Form=
Global $hWnd = GUICreate("English to Arabic Translator", 630, 162, -1, -1)
GUICtrlCreateLabel("Write the English text here:", 10, 2, 246, 17)
Global $eInput = GUICtrlCreateEdit("", 8, 25, 250, 100, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_VSCROLL))
GUICtrlSetData(-1, "Language text!")
GUICtrlCreateLabel("Arabic Text translated:", 368, 2, 252, 17, $SS_RIGHT)
Global $eOutput = GUICtrlCreateEdit("", 368, 25, 250, 100, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_VSCROLL), $WS_EX_LAYOUTRTL)
GUICtrlSetData(-1, "")
Global $bTranslate = GUICtrlCreateButton("Translate", 268, 25, 88, 50, $BS_DEFPUSHBUTTON)
Global $bCopy = GUICtrlCreateButton("Copy", 268, 88, 88, 33)
Global $labStatus = GUICtrlCreateLabel("Ready!", 10, 134, 608, 21)

GUISetState(@SW_SHOW)
#EndRegion ### START GUI section ### Form=

Global Const $iLanguage = 0x0409
_WinAPI_SetKeyboardLayout($hWnd, $iLanguage)

Global $sTextToTranslated, $sTextTranslatedToArabic

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $bCopy
            $sTextToTranslated = GUICtrlRead($eOutput)
            MsgBox(64, "Copy to clipboard", ClipPut($sTextToTranslated) ? "Text translated has copy to Cliboard" : "Copy to Cliboard ERROR", Default, $hWnd)
        Case $bTranslate
            GUICtrlSetData($labStatus, "Translating...")

            GUICtrlSetData($eOutput, "")
            $sTextToTranslated = GUICtrlRead($eInput)
            $sTextTranslatedToArabic = _TranslateEnglishToArabic($sTextToTranslated)
            GUICtrlSetData($eOutput, $sTextTranslatedToArabic)

            GUICtrlSetData($labStatus, "Done!")
    EndSwitch
    Sleep(10)
WEnd

Func _TranslateEnglishToArabic($sEnglish = "")
    Local $sTranslated = BingTranslator($sEnglish, "en", "ar")
    Return $sTranslated
EndFunc   ;==>_TranslateEnglishToArabic

Func BingTranslator($sText, $sFrom = "auto", $sTo = "en")
    Local $sClient = "http://api.microsofttranslator.com/V2/Http.svc/"
    Local $appID = 'appId=68D088969D79A8B23AF8585CC83EBA2A05A97651'
    Local $Data = BinaryToString(StringToBinary($sText, 4))
    If $sFrom == "auto" Then
        $sFrom = InetRead($sClient & 'Detect?' & $appID & "&text=" & $Data, 3)
        $sFrom = StringRegExpReplace(BinaryToString($sFrom, 4), ".*>(.*)<.*", "$1")
    EndIf
    Local $Result = InetRead($sClient & 'Translate?' & $appID & "&from=" & $sFrom & "&to=" & $sTo & "&text=" & $Data, 3)
    $Result = StringRegExpReplace(BinaryToString($Result, 4), ".*>(.*)<.*", "$1")
    Return $Result
EndFunc   ;==>BingTranslator

 

Regards,
 

Link to comment
Share on other sites

  • 4 years later...
  • Developers
15 hours ago, illidan333 said:

How can I become a full member?

You mean you do not have the edit option under the 3 dots menu located at the right hand side of the post? 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...