Jump to content

How to restrict inputboxes to specific characters only?


Recommended Posts

I'm having trouble in making an input box where I can limit the characters that can be inputted.  Anybody have an idea how this can be done in Auto IT?

Specifically I would like to create an input field where the user would enter a MAC address.  What I would like to do is to limit the characters that can be inputted to only HEX values (A-F and 0-9 as well as the - character).  This is so that the user cannot input invalid characters. The program is going to be used by very non-technical people, so the idea is to remove as many chances for errors that we can think of.  I would also prefer to limit the field to only 17 characters, so that there is only enough space to enter the MAC address with the - character as the separator.

Thank you all in advance for any suggestions!

Link to post
Share on other sites

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * for other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2021-10-18

Link to post
Share on other sites

This should work to do it dynamically  :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

Opt("GUIOnEventMode", 1)

$hGUI = GUICreate("Test", 232, 90)
$Label = GUICtrlCreateLabel("Enter MAC address", 22, 8, 163, 17)
$input = GUICtrlCreateInput("", 22, 30, 165, 24)
GUICtrlSetLimit(-1, 17)
GUICtrlSetFont(-1, 12)
GUISetState()

GUIRegisterMsg($WM_COMMAND, '_WM_COMMAND')
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

While 1
  Sleep(10)
WEnd

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
 Local $id = BitAND($wParam, 0x0000FFFF)
 Local $code = BitShift($wParam, 16)
   If $id = $input AND $code = $EN_UPDATE Then
       Local $content = GUICtrlRead($input)
       Local $len = StringLen($content)
       Local $char = StringRight($content, 1)
       Local $mod = Mod($len, 3)
       If not (( ($mod = 1 or $mod = 2) and StringRegExp($char, '[[:xdigit:]]') ) OR _ 
           ($mod = 0 and $char = "-")) Then GUICtrlSetData($input, StringTrimRight($content, 1)) 
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

Func _Exit()
    Exit
EndFunc

 

Link to post
Share on other sites

A slight optional addition for a better look  :D

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)

   ;....

   If not (( ($mod = 1 or $mod = 2) and StringRegExp($char, '[[:xdigit:]]') ) OR _ 
           ($mod = 0 and $char = "-")) Then 
       GUICtrlSetData($input, StringTrimRight($content, 1)) 
   Else
       GUICtrlSetData($input, StringUpper($content))
   EndIf

 

Link to post
Share on other sites

Mikell,

I'm not sure what I am missing, but when I paste in your additional code, it errors out. (the original one works great!)

By the way, excuse my ignorance, but where in the code does it specifically state that only a-f and 0-9 and - are allowed?  I'm trying to figure this out, because your code is very useful, and I could see myself using it for other projects as well, where I would want to limit what characters can be inputted.  Seeing as how in other projects I might want to limit the input to a different set of characters, I would like to know how to change it.

 

 

Link to post
Share on other sites

When you create an input box you can set the length of characters, digits only, Uppercase, Center like this.

GUICtrlCreateInput Style Options

$ES_NUMBER        ==  Accepts only digits [0-9]
$ES_UPPERCASE   ==  Converts all characters to uppercase
$ES_LOWERCASE  ==  Converts all characters to lowercase
$ES_CENTER          ==  Centers text

GUICtrlSetLimit ( controlID, max , OPTIONAL min )  == so you can set a max and min character length for an input control
 

 $UserInput = GUICtrlCreateInput("", 120, 292, 161, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER,$ES_NUMBER))
  GUICtrlSetLimit($UserInput, 10) ; Limit User Input to 10 Characters, can also just use -1 instead of variable of input box if this line is directly under like here

 

 

Edited by iAmNewbe
Link to post
Share on other sites

iAmNewbe,

Thanks! that worked great!  I see that the additional code that mikell sent me was to make the MAC address always appear as uppercase, no matter how it was typed, but thanks to the style options you showed me for GUICtrlCreateInputStyle, I simply added the "$ES_UPPERCASE" style command and it now displays the MAC address always in upper case, no matter how it is typed.

 

Link to post
Share on other sites

There are more options but the rest are mainly display of the box itself those I put above are the most useful. You can also use RegEx as MuffinMan shows for more involved things but if all you want is to limit to digits only that is built in using that style option.  The manual is an important read, I think over the last two weeks I went through it like a 100 times.  

Link to post
Share on other sites
10 hours ago, GeorgeB said:

where in the code does it specifically state that only a-f and 0-9 and - are allowed?

Sorry for the lack of explanations  :>

In fact the code actually forbids the last character written if not Hex or '-' depending on the length of the string
Here it is, detailed

Local $content = GUICtrlRead($input)
; get the string length
Local $len = StringLen($content)   
; get the last character entered
Local $char = StringRight($content, 1)  
; Mod returns 1 if length=1, 2 if length=2, 0 if length=3, 1 if length=4, etc
Local $mod = Mod($len, 3) 
 
; if NOT ( Mod = 1 or 2 AND the last char is hexadecimal, or Mod = 0 AND the last char is '-' )
If not (( ($mod = 1 or $mod = 2) and StringRegExp($char, '[[:xdigit:]]') ) OR _ 
           ($mod = 0 and $char = "-")) Then 
; then remove the last char and write to the input
       GUICtrlSetData($input, StringTrimRight($content, 1)) 

; i.e. if the last character written is in 5th position, then string length = 5, Mod = 2, so this char must be hexa. If it is not then it will not be written
; and so on

:)

Edited by mikell
Link to post
Share on other sites

I was working on this a while back, wanted to make it a UDF but never put the time to write it to standards.

I used it for quite a few things however.

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

$Form1 = GUICreate("Test GUI", 618, 276, 192, 124)
$Label1 = GUICtrlCreateLabel("Test GUI", 168, 24, 47, 17)
$Button1 = GUICtrlCreateButton("Toggle Validation", 290, 24, 110, 40)
$Input1 = GUICtrlCreateInput("Max 10 Characters", 40, 72, 553, 21)
$Input2 = GUICtrlCreateInput("Numb3rs 0nly", 40, 97, 553, 21)
$Edit1 = GUICtrlCreateEdit("Max 10 Chars Numbers Only + Auto Line Break", 40, 120, 553, 105)
GUISetState(@SW_SHOW)

$iToggle = 1

While 1
 Sleep(10)
 If Mod($iToggle, 2) = 0 Then
;Example 1 Limit to 10 Characters
 _GUIRegExValidate($Input1, "(.{10})(.)", "$1")
;Example 2 Can only type numbers
 _GUIRegExValidate($Input2, "[^\d]", "")
;Example 3 Combind More Than One On Same Input limit to 10 characters, limit to numbers only, line break @ 10 characters to new line
 _GUIRegExValidate($Edit1, "(.{10})(.)", "$1" & @CRLF)
 _GUIRegExValidate($Edit1, "[^\d\r\n]", "")
 EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $iToggle = $iToggle + 1
    EndSwitch
WEnd

Func _GUIRegExValidate($sInputLabel, $sRegExCapture, $sRegExReplace)
    $Step1Read = GUICtrlRead($sInputLabel)
    $Step2Validate = StringRegExpReplace($Step1Read, $sRegExCapture, $sRegExReplace)
    If @Extended = 0 Then Return
    GUICtrlSetData($sInputLabel, $Step2Validate)
EndFunc

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
 _GUIRegExValidate($Edit1, "(.{20})(.)", "$1")
EndFunc

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By odaylton
      Text translated from Portuguese by google - please apologize for any errors
       
      First I have to thank the development team for product quality and the ease with which it is possible to develop tools with AutoIt.
       
      I am developing a series of libraries to facilitate the creation of Forms that once it is stable and comprehensive I intend to share here for autoit
      But suddenly during development an unexpected effect appeared in simple inputbox fields.
       
      Everything is working fine, however if I'm in an inputbox, don't change its selected content and move focus to another field the selected text remains blue (selected) instead of returning to normal
      See the image....

      When pricing 3x TABs all remain blue
       
      However if I change the field , when leaving its focus it behaves normally
      See the ex below:

      1) I selected “tipo Default” and pressed TAB (to test what happens)
      2) typed "TESTE" and pressed TAB
      3) I pressed TAB 2x again and the "Centralizado" field turned blue
      Note: by default, when receiving focus, the text is always automatically selected
       
      Here are some parts of the code:
      Gui  create:
      ;modifique o tamanho inicial aqui ;$Form[$Form[0][0]][1] = 600 ;largura =800 ;$Form[$Form[0][0]][2] = 600 ;Atura =600 ;$Form[$Form[0][0]][3] = "RoboAutomato - "&$NomeProjeto $Form[$Form[0][0]][0] = GUICreate($Form[$Form[0][0]][3], _ $Form[$Form[0][0]][1], $Form[$Form[0][0]][2], _ Default, Default, _ BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP, $WS_POPUP)) GUISetFont($FormFonteTam, _ ;Tamanho da Fonte $FormFonteTipo, _ ;Tipo da Fonte $FormFonteEstilo, _ ;Estilo da Fonte $FormFonteNome) ; Nome da Fonte #Region Criando ToolTip $hGUIToolTip = _GUIToolTip_Create($Form[$Form[0][0]][0], BitOR($_TT_ghTTDefaultStyle, $TTS_BALLOON)) ; balloon style tooltip #EndRegion Criando ToolTip  inputs create:
      .... InputCriar(200, 200, _ ;Coordenadas Base Default, Default, _ ;Largura e Altura automatica se negativo em função do extremo da janela "|Referencia|", _ ;Label do Input "Tudo Default ou qq diferente de 1,2,3,4: mais simples", _ ;Texto explicativo do InputBox e seu label "Teste do tipo Default", _ ;Valor Default da Input Default, _ ;0 é Defaultou define o estilo Default, _ ;Defini a forma de incerção Default=20 caracteres "CCCCCCCCCCCCCCCCCCCC" Default, _ Default, _ Default, _ ; Tipo de alinhamento em relação a Janela Default, _ ;Tamanho da Fonte Default, _ ;Tipo da Fonte Default, _ ;Estilo da Fonte Default) ; Nome da Fonte InputCriar(200, Default, _ ;Coordenadas Base Default, Default, _ ;Largura e Altura automatica se negativo em função do extremo da janela "|Canto inferior esquerdo|", _ ;Label do Input "Tipo 1: 2 linhas", _ ;Texto explicativo do InputBox e seu label "Tipo 1: 2 linhas", _ ;Valor Default da Input 1, _ ;0 é Defaultou define o estilo Default, _ ;Defini a forma de incerção Default=20 caracteres "CCCCCCCCCCCCCCCCCCCC" Default, _ Default, _ Default, _ ; Tipo de alinhamento em relação a Janela Default, _ ;Tamanho da Fonte Default, _ ;Tipo da Fonte Default, _ ;Estilo da Fonte Default) ; Nome da Fonte ..... Function InputCriar:
      Func InputCriar($InputX = Default, $InputY = Default, _ ;Coordenadas Base Canto Superior Esquerdo se não definido proxima linha e coluna $InputWidth = Default, $InputHeight = Default, _ ;Largura e Altura automatica se negativo em função do extremo da janela $InputRotulo = "", _ ;Label do Inpu $InputTip = "", _ ;Texto explicativo do InputBox e seu label $InputDefault = "", _ ;Valor Default da Input $InputAlin = Default, _ ;0 é Defaultou define o estilo $InputMascara = Default, _ ;Defini a forma de incerção Default=20 caracteres "CCCCCCCCCCCCCCCCCCCC" $InputEstilo = Default, _ $InputEstiloEx = Default, _ $InputResizing = Default, _ ; Tipo de alinhamento em relação a Janela $InputTamFonte = Default, _ ;Tamanho da Fonte $InputFonteTipo = Default, _ ;Tipo da Fonte $InputFonteEstilo = Default, _ ;Estilo da Fonte $InputFonteNome = Default) ; Nome da Fonte .... $InputEstilo = BitOR($ES_AUTOHSCROLL, _ $WS_TABSTOP) ... $InputEstiloEx = $WS_EX_CLIENTEDGE ;formato baixo relevo ... $Inputs[$Inputs[0][0]][0] = GUICtrlCreateInput($Mascara5, _ ;Default da Input $Form[$Form[0][0]][6]+$InputX, $Form[$Form[0][0]][7]+$InputY, _ ;Coordenadas Base $InputWidth, $InputHeight, _ ;Altura e largura automatica $InputEstilo, _ ;Estilo $InputEstiloEx) ;Extilo extra ... GUICtrlSetData($Inputs[$Inputs[0][0]][0], $Inputs[$Inputs[0][0]][3]) Return $Inputs[$Inputs[0][0]][0] EndFunc ;==>InputCriar sorry for not putting all the code because there are many libraries and they are in the initial stage of development
       
      What should I change to get Inputbox's behavior back to normal????
      Thank you for your attention
    • By Ascer
      Hello,
      I would like to ask if there is an GUI function that allow create control like this?

    • By XGamerGuide
      I'm trying to assign a faint text in the background to an input field that disappears after the input has started. This should have a certain color such as gray.
    • By nooneclose
      Why can I not click on either of my input fields?
      #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 730, 437, 192, 124) ;GUISetFont(14, 800, 0, "MS Sans Serif") GUISetBkColor(0xC0DCC0) Global $Label1 = GUICtrlCreateLabel("Enter your Password. UserName is auto filled", 62, 40, 604, 41, $SS_CENTER) GUICtrlSetFont(-1, 26, 800, 0, "MS Sans Serif") Global $Label2 = GUICtrlCreateLabel("User Name:", 120, 130, 604, 31, $SS_LEFT) GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif") Global $Label3 = GUICtrlCreateLabel("Password:", 135, 210, 604, 31, $SS_LEFT) GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif") Global $Input1 = GUICtrlCreateInput(@UserName, 274, 130, 185, 32) GUICtrlSetFont(-1, 14, 800, 1, "MS Sans Serif") Global $Input2 = GUICtrlCreateInput("Password", 274, 210, 185, 32, $ES_PASSWORD) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") Global $OK = GUICtrlCreateButton("OK", 274, 270, 185, 57) GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $OK Global $UserName = GUICtrlRead($Input1) Global $PassWord = GUICtrlRead($Input2) ExitLoop EndSwitch WEnd ; Delete the GUI window GUIDelete()  
    • By Colduction
      Hello AutoIt Programmers, i was working on my project and i reffered to @KBLayout, @MUILang & @OSLang then i saw that code example of this macro is not too complete, i decided to share my customized _GetLanguage() for you:
      #include <MsgBoxConstants.au3> MsgBox($MB_SYSTEMMODAL, "", "The language of the OS is: " & _GetLanguage() & " (" & LCIDToLocaleName("0x" & @OSLang) & ")") ; Retrieve the language of the operating system. Func _GetLanguage() Switch @OSLang Case "0004" Return "Chinese - Simplified" Case "0401" Return "Arabic - Saudi Arabia" Case "0402" Return "Bulgarian - Bulgaria" Case "0403" Return "Catalan - Spain" Case "0404" Return "Chinese (Traditional) - Taiwan" Case "0405" Return "Czech - Czech Republic" Case "0406" Return "Danish - Denmark" Case "0407" Return "German - Germany" Case "0408" Return "Greek - Greece" Case "0409" Return "English - United States" Case "040A" Return "Spanish - Spain" Case "040B" Return "Finnish - Finland" Case "040C" Return "French - France" Case "040D" Return "Hebrew - Israel" Case "040E" Return "Hungarian - Hungary" Case "040F" Return "Icelandic - Iceland" Case "0410" Return "Italian - Italy" Case "0411" Return "Japanese - Japan" Case "0412" Return "Korean - Korea" Case "0413" Return "Dutch - Netherlands" Case "0414" Return "Norwegian (Bokmål) - Norway" Case "0415" Return "Polish - Poland" Case "0416" Return "Portuguese - Brazil" Case "0417" Return "Romansh - Switzerland" Case "0418" Return "Romanian - Romania" Case "0419" Return "Russian - Russia" Case "041A" Return "Croatian - Croatia" Case "041B" Return "Slovak - Slovakia" Case "041C" Return "Albanian - Albania" Case "041D" Return "Swedish - Sweden" Case "041E" Return "Thai - Thailand" Case "041F" Return "Turkish - Turkey" Case "0420" Return "Urdu - Pakistan" Case "0421" Return "Indonesian - Indonesia" Case "0422" Return "Ukrainian - Ukraine" Case "0423" Return "Belarusian - Belarus" Case "0424" Return "Slovenian - Slovenia" Case "0425" Return "Estonian - Estonia" Case "0426" Return "Latvian - Latvia" Case "0427" Return "Lithuanian - Lithuanian" Case "0428" Return "Tajik (Cyrillic) - Tajikistan" Case "0429" Return "Persian - Iran" Case "042A" Return "Vietnamese - Vietnam" Case "042B" Return "Armenian - Armenia" Case "042C" Return "Azeri (Latin) - Azerbaijan" Case "042D" Return "Basque - Basque" Case "042E" Return "Upper Sorbian - Germany" Case "042F" Return "Macedonian - Macedonia" Case "0432" Return "Setswana / Tswana - South Africa" Case "0434" Return "isiXhosa - South Africa" Case "0435" Return "isiZulu - South Africa" Case "0436" Return "Afrikaans - South Africa" Case "0437" Return "Georgian - Georgia" Case "0438" Return "Faroese - Faroe Islands" Case "0439" Return "Hindi - India" Case "043A" Return "Maltese - Malta" Case "043B" Return "Sami (Northern) - Norway" Case "043e" Return "Malay - Malaysia" Case "043F" Return "Kazakh - Kazakhstan" Case "0440" Return "Kyrgyz - Kyrgyzstan" Case "0441" Return "Swahili - Kenya" Case "0442" Return "Turkmen - Turkmenistan" Case "0443" Return "Uzbek (Latin) - Uzbekistan" Case "0444" Return "Tatar - Russia" Case "0445" Return "Bangla - Bangladesh" Case "0446" Return "Punjabi - India" Case "0447" Return "Gujarati - India" Case "0448" Return "Oriya - India" Case "0449" Return "Tamil - India" Case "044A" Return "Telugu - India" Case "044B" Return "Kannada - India" Case "044C" Return "Malayalam - India" Case "044D" Return "Assamese - India" Case "044E" Return "Marathi - India" Case "044F" Return "Sanskrit - India" Case "0450" Return "Mongolian (Cyrillic) - Mongolia" Case "0451" Return "Tibetan - China" Case "0452" Return "Welsh - United Kingdom" Case "0453" Return "Khmer - Cambodia" Case "0454" Return "Lao - Lao PDR" Case "0456" Return "Galician - Spain" Case "0457" Return "Konkani - India" Case "0459" Return "(reserved) - (reserved)" Case "045A" Return "Syriac - Syria" Case "045B" Return "Sinhala - Sri Lanka" Case "045C" Return "Cherokee - Cherokee" Case "045D" Return "Inuktitut (Canadian_Syllabics) - Canada" Case "045E" Return "Amharic - Ethiopia" Case "0461" Return "Nepali - Nepal" Case "0462" Return "Frisian - Netherlands" Case "0463" Return "Pashto - Afghanistan" Case "0464" Return "Filipino - Philippines" Case "0465" Return "Divehi - Maldives" Case "0468" Return "Hausa - Nigeria" Case "046A" Return "Yoruba - Nigeria" Case "046B" Return "Quechua - Bolivia" Case "046C" Return "Sesotho sa Leboa - South Africa" Case "046D" Return "Bashkir - Russia" Case "046E" Return "Luxembourgish - Luxembourg" Case "046F" Return "Greenlandic - Greenland" Case "0470" Return "Igbo - Nigeria" Case "0473" Return "Tigrinya - Ethiopia" Case "0475" Return "Hawiian - United States" Case "0478" Return "Yi - China" Case "047A" Return "Mapudungun - Chile" Case "047C" Return "Mohawk - Canada" Case "047E" Return "Breton - France" Case "0480" Return "Uyghur - China" Case "0481" Return "Maori - New Zealand" Case "0482" Return "Occitan - France" Case "0483" Return "Corsican - France" Case "0484" Return "Alsatian - France" Case "0485" Return "Sakha - Russia" Case "0486" Return "K'iche - Guatemala" Case "0487" Return "Kinyarwanda - Rwanda" Case "0488" Return "Wolof - Senegal" Case "048C" Return "Dari - Afghanistan" Case "0491" Return "Scottish Gaelic - United Kingdom" Case "0492" Return "Central Kurdish - Iraq" Case "0801" Return "Arabic - Iraq" Case "0803" Return "Valencian - Valencia" Case "0804" Return "Chinese (Simplified) - China" Case "0807" Return "German - Switzerland" Case "0809" Return "English - United Kingdom" Case "080A" Return "Spanish - Mexico" Case "080C" Return "French - Belgium" Case "0810" Return "Italian - Switzerland" Case "0813" Return "Dutch - Belgium" Case "0814" Return "Norwegian (Nynorsk) - Norway" Case "0816" Return "Portuguese - Portugal" Case "081A" Return "Serbian (Latin) - Serbia and Montenegro" Case "081D" Return "Swedish - Finland" Case "0820" Return "Urdu - (reserved)" Case "082C" Return "Azeri (Cyrillic) - Azerbaijan" Case "082E" Return "Lower Sorbian - Germany" Case "0832" Return "Setswana / Tswana - Botswana" Case "083B" Return "Sami (Northern) - Sweden" Case "083C" Return "Irish - Ireland" Case "083E" Return "Malay - Brunei Darassalam" Case "0843" Return "Uzbek (Cyrillic) - Uzbekistan" Case "0845" Return "Bangla - Bangladesh" Case "0846" Return "Punjabi - Pakistan" Case "0849" Return "Tamil - Sri Lanka" Case "0850" Return "Mongolian (Mong) - Mongolia" Case "0859" Return "Sindhi - Pakistan" Case "085D" Return "Inuktitut (Latin) - Canada" Case "085F" Return "Tamazight (Latin) - Algeria" Case "0867" Return "Pular - Senegal" Case "086B" Return "Quechua - Ecuador" Case "0873" Return "(reserved) - (reserved)" Case "0873" Return "Tigrinya - Eritrea" Case "0C01" Return "Arabic - Egypt" Case "0C04" Return "Chinese - Hong Kong SAR" Case "0C07" Return "German - Austria" Case "0C09" Return "English - Australia" Case "0C0A" Return "Spanish - Spain" Case "0C0C" Return "French - Canada" Case "0C1A" Return "Serbian (Cyrillic) - Serbia and Montenegro" Case "0C3B" Return "Sami (Northern) - Finland" Case "0C6B" Return "Quechua - Peru" Case "1001" Return "Arabic - Libya" Case "1004" Return "Chinese - Singapore" Case "1007" Return "German - Luxembourg" Case "1009" Return "English - Canada" Case "100A" Return "Spanish - Guatemala" Case "100C" Return "French - Switzerland" Case "101A" Return "Croatian (Latin) - Bosnia and Herzegovina" Case "103B" Return "Sami (Lule) - Norway" Case "105F" Return "Central Atlas Tamazight (Tifinagh) - Morocco" Case "1401" Return "Arabic - Algeria" Case "1404" Return "Chinese - Macao SAR" Case "1407" Return "German - Liechtenstein" Case "1409" Return "English - New Zealand" Case "140A" Return "Spanish - Costa Rica" Case "140C" Return "French - Luxembourg" Case "141A" Return "Bosnian (Latin) - Bosnia and Herzegovina" Case "143B" Return "Sami (Lule) - Sweden" Case "1801" Return "Arabic - Morocco" Case "1809" Return "English - Ireland" Case "180A" Return "Spanish - Panama" Case "180C" Return "French - Monaco" Case "181A" Return "Serbian (Latin) - Bosnia and Herzegovina" Case "183B" Return "Sami (Southern) - Norway" Case "1C01" Return "Arabic - Tunisia" Case "1c09" Return "English - South Africa" Case "1C0A" Return "Spanish - Dominican Republic" Case "1C1A" Return "Serbian (Cyrillic) - Bosnia and Herzegovina" Case "1C3B" Return "Sami (Southern) - Sweden" Case "2001" Return "Arabic - Oman" Case "2009" Return "English - Jamaica" Case "200A" Return "Spanish - Venezuela" Case "201A" Return "Bosnian (Cyrillic) - Bosnia and Herzegovina" Case "203B" Return "Sami (Skolt) - Finland" Case "2401" Return "Arabic - Yemen" Case "2409" Return "English - Caribbean" Case "240A" Return "Spanish - Colombia" Case "241A" Return "Serbian (Latin) - Serbia" Case "243B" Return "Sami (Inari) - Finland" Case "2801" Return "Arabic - Syria" Case "2809" Return "English - Belize" Case "280A" Return "Spanish - Peru" Case "281A" Return "Serbian (Cyrillic) - Serbia" Case "2C01" Return "Arabic - Jordan" Case "2C09" Return "English - Trinidad and Tobago" Case "2C0A" Return "Spanish - Argentina" Case "2C1A" Return "Serbian (Latin) - Montenegro" Case "3001" Return "Arabic - Lebanon" Case "3009" Return "English - Zimbabwe" Case "300A" Return "Spanish - Ecuador" Case "301A" Return "Serbian (Cyrillic) - Montenegro" Case "3401" Return "Arabic - Kuwait" Case "3409" Return "English - Philippines" Case "340A" Return "Spanish - Chile" Case "3801" Return "Arabic - U.A.E." Case "380A" Return "Spanish - Uruguay" Case "3C01" Return "Arabic - Bahrain" Case "3C0A" Return "Spanish - Paraguay" Case "4001" Return "Arabic - Qatar" Case "4009" Return "English - India" Case "400A" Return "Spanish - Bolivia" Case "4409" Return "English - Malaysia" Case "440A" Return "Spanish - El Salvador" Case "4809" Return "English - Singapore" Case "480A" Return "Spanish - Honduras" Case "4C0A" Return "Spanish - Nicaragua" Case "500A" Return "Spanish - Puerto Rico" Case "540A" Return "Spanish - United States" Case "7C04" Return "Chinese - Traditional" Case Else Return "Other (can't determine with @OSLang directly)" EndSwitch EndFunc ;==>_GetLanguage Func LCIDToLocaleName($iLCID) Local $aRet = DllCall("kernel32.dll", "int", "LCIDToLocaleName", "int", $iLCID, "wstr", "", "int", 85, "dword", 0) Return $aRet[2] EndFunc ;==>LCIDToLocaleName _GetLanguage.au3
      Source: AutoIt Help File (ScITE Editor (F1))

      I hope you enjoy this tiny code.
×
×
  • Create New...