nacerbaaziz

Change the keyboard language in custom window

9 posts in this topic

#1 ·  Posted

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

Share this post


Link to post
Share on other sites



#3 ·  Posted

Hi again.
Dear I have a query
Do I need the title of the window or window Handle
Thank you very much

Share this post


Link to post
Share on other sites

#4 ·  Posted

$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,
 

Share this post


Link to post
Share on other sites

#5 ·  Posted

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

Share this post


Link to post
Share on other sites

#6 ·  Posted

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,
 

Share this post


Link to post
Share on other sites

#7 ·  Posted

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,
 

Share this post


Link to post
Share on other sites

#9 ·  Posted

thank you very very very very much dear for the helpful responses

Share this post


Link to post
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

  • Similar Content

    • sree161
      By sree161
      Hi,
      i have a code which generates two numeric outputs.i have to save them in excel.
      Is there any way to export them to specific cells in excel???
    • TotalAuto
      By TotalAuto
      Howdy All
      I've gone around and around in circles wasting hours trying to fix this problem to no avail so I thought I would try posting for help given there are some real smart people in this forum.
      Background
      I have 5 separate .au3 scripts that all do different basic tasks. For example:
      1.au3 = opens Chrome browser to obtain information from a specific website then closes
      2.au3 = opens an Excel workbook to run a macro then saves and closes
      3.au3 = Open two seperate workbooks and transfers data from one to the other then saves and closes
      4.au3 = .......etc
      5.au3 = .......etc
      These 5 separate scripts, doing completely different tasks, need to each run once per day at 5 different designated times within a day and then close. For example:
      1.au3 = 10am
      2.au3 = 12pm
      3.au3 = 2pm
      4.au3 = 4pm
      5.au3 = 5pm
      Problem
      I can not get these different scripts to reliably run at their designated times. When I manually run these scripts individually by using 'Go F5' they work perfectly. If I convert these scripts to an .exe and manually run each one they work about 98% of time.
      How can I schedule these different .au3 files or associated .exe files to reliably run each day at different times?
      Attempts To Fix The Issue
      1. I have tried converting each .au3 script into their own .exe file and use Window's Task Scheduler to run these .exe files at their designated time but the success rate  of running each .exe in full, to completion, without error is very low at about 30%. Things that commonly go wrong include a browser not opening but movement still continues on the desk top. Other times things just do not happen at all.
      2. I have Windows 7 64 bit and have tried creating and running both (x86) and (x64) .exe files but again reliability problems exist;
      3. I have also tried moving each .exe file to the My Documents folder as I read someone that keeping your files on your desktop ties your files to individual Windows user profiles which can cause AutoIt operating errors. Not sure if this is correct but thought I would try it anyway. It did not fix my issue.
      4. I installed a program called AlwaysUp which supposedly always reliably runs in the background and will reliably execute your AutoIt script or .exe files. Still have significant reliability issues.
      Therefore, can someone please provide advice on how I can get my 5 different .au3 files to run at 5 designated times through the day, every day, without fail? Overtime I will be creating more and more different .au3 files to run certain tasks throughout the day and do not want to create one large AutoIt file that continually runs and attempts to do all the different tasks itself.
      Any help is very appreciated.
      Thanks
      Dan
       
       
    • hugomito
      By hugomito
      Hi all,
      I built an AutoIt application that interacts with several other applications/software. Now, it's turn to interfact with Visual Studio Team Services (VSTS).
      Does anyone has a blog, demo, script to share?
      Thanks!
    • Viki
      By Viki
      This is my first time here so please dont bombard me that what a silly question I am asking!!
      I have 500 rows (A1:A500) in a spreadsheet and I just want to copy one by one row and then paste into another application and then press enter, loop should repeat this until finishes all 500 rows.
      I have looked at clipget(), clip(put() but dont know how to select next row in next turn. I also looked at Array to store but again no luck. Can some guide me please..
    • DineshPawar
      By DineshPawar
      0down votefavorite   In my current project, Excel macro open AutoIt script using a function Call Shell("location of autoit script").
      For proper functioning of AutoIt script it's need to be close parent Excel workbook, so this closing Excel action is written in AutoIt script itself.
      But as soon as AutoIt script close parent Excel workbook then script get pause and it do nothing.
      How open the AutoIt script from Excel workbook and after that parent Workbook get close?