#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <EditConstants.au3>
$hForm = GUICreate('Test',300, 300)
GUISetBkColor(0xECE9D8)
$hInput1=GUICtrlCreateInput ( "", 5, 60, 250, 40)
$hInput2=GUICtrlCreateInput ( "", 5, 120, 250, 40)
$ButTest1=GUICtrlCreateButton('Обратная операция',150, 270, 120, 25)
GUICtrlSetTip (-1, "Проверить обратной операцией ")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $ButTest1
$sText=GUICtrlRead($hInput2)
GUICtrlSetData($hInput1, $sText)
EndSwitch
WEnd
Func WM_COMMAND($hWnd, $imsg, $iwParam, $ilParam)
Local $hWndFrom = $ilParam
Local $iIDFrom = BitAND($iwParam, 0xFFFF)
Local $iCode = BitShift($iwParam, 16)
Switch $hWnd
Case $hForm
Switch $iIDFrom
Case $hInput1
Switch $iCode
Case $EN_UPDATE
$sText=GUICtrlRead($hInput1)
$iASC=Asc(StringLeft($sText,1))
If $iASC< 192 Then
$iFlag=2
Else
$iFlag=1
EndIf
$sNewText=__StringTranslit_ReTranslit1($sText, $iFlag)
GUICtrlSetData($hInput2, $sNewText)
EndSwitch
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
;============================================================================================================
Func __StringTranslit_ReTranslit1($sString,$flag=1)
; - Название функции : Транслит-Ретранслит текстовой строки
;- Синтаксис : $text=__StringTranslit_ReTranslit($text,$flag)
; Параметры ; $flfg = 1 - Транслит
; ; $flfg = 2 - РеТранслит
;- Возврашаемое значение : Измененная строка
;- Дата написания : 19.10.2008
;- Версия : AutoIT 3.2.12.0
;============================================================================================================
Local Const $aCyrTab[72] = [71, "щ","Щ", "щ","Щ","ы","Ы", _
"ё","ж","ч","ш","э","ю","я", _
"Ё","Ж","Ц","Ч","Ш","Э","Ю","Я", _
"а","б","в","г","д","е","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ь","ъ","ы", _
"А","Б","В","Г","Д","Е","З","И","Й","К","Л","М","Н","О","П","Р","С","Т","У","Ф","Х","Ь","Ъ","Ы", _
"ц","Ц"]
Local Const $aLatTab[72] = [71, "sch","SCH", "sh`","SH`","i`","I`", _
"yo" ,"zh" ,"ch","sh","e`","yu","ya", _
"YO" ,"ZH" ,"TS","CH","SH","E`","YU","YA", _
"a","b","v","g","d","e","z","i","j","k","l","m","n","o","p","r","s","t","u","f","h","`","'","y", _
"A","B","V","G","D","E","Z","I","J","K","L","M","N","O","P","R","S","T","U","F","H","`","'","Y", _
"c","C"]
$sString=StringReplace ( $sString ,"'",'"')
If $flag=1 Then
;$sString=StringReplace ( $sString ,"'",'"')
Local $a1=$aCyrTab,$a2=$aLatTab
Else
Local $a2=$aCyrTab,$a1=$aLatTab
EndIf
For $i = 1 To UBound($a1)-1
$sString = StringReplace($sString, $a1[$i],$a2[$i], 0, 2)
Next
If $flag=1 Then Return $sString
$sString = StringRegExpReplace($sString, "([А-Я,Ё]{2})ь","\1Ь")
$sString = StringRegExpReplace($sString, "([А-Я,Ё]{2})ъ","\1Ъ")
$sString = StringRegExpReplace($sString, "ь([А-Я,Ё])","Ь\1")
$sString = StringRegExpReplace($sString, "ъ([А-Я,Ё])","Ъ\1")
Return $sString
EndFunc ;==>__StringTranslit_ReTranslit