Jump to content

How do I automatically change letters to other letters in a text editor?


Recommended Posts

Hi everyone. I am new to AutoIt and I like the program but I don't know how to use it. I work with languages and I would like to know how to change letters to other letters automatically in a word editor. For example, when the script comes across the letter д it will turn it into letter d. (transliteration)

Is this possible, and if so how do I do it?

Thanks.

Link to comment
Share on other sites

Non latin characters are showing up as ? in Autoit, and how exactly do I use this string? I copy pasted

$tempstring=StringReplace($tempstring,"д","d"), saved it and ran it and the script doesn't run.

AZJIO, I got your program, and it works for cyrillic, but when I replaced the letters in translits.txt with other letters, it didn't work. It also functions in a window which has limited space, if it could work with Microsoft Word for example, that would be good.

Sorry for being a noob.

Link to comment
Share on other sites

Salvia,

I haven't tried this but maybe it will work for you. ;)

Func _ReplaceNonAsciiChar($sString)
    Local $iCharCode, $aString = StringSplit($sString, "", 1), $sNewString
    For $iChar = 0 To $aString[0] Step 1
        $iCharCode = AscW($aString[$iChar])
        If $iCharCode < 0 Or $iCharCode > 127 Then
            ConsoleWrite('Non ASCII char: "' & $aString[$iChar] & '" is char code #' & $iCharCode)
            $aString[$iChar] = "-Replacement Char-"
        EndIf
        $sNewString &= $aString[$iChar]
    Next
    Return $sNewString
EndFunc   ;==>_ReplaceNonAsciiChar

*Edit to remove code error and added ConsoleWrite('Non ASCII char: "' & $aString[$iChar] & '" is char code #' & $iCharCode).

Once you know the char code you could use

$sNewString = StringReplace("SomeString", ChrW(SomeNumber), "SomeCharacter")

Anonymous

Edited by Decipher
Spoiler

censored.jpg

 

Link to comment
Share on other sites

Salvia,

AutoIt may not display the non ASCII characters correctly in a GUI? I'm not sure because I haven't tried it but as far support for Unicode characters in a string the above should work for you. Scite is a completely different topic. If you want to change the text in other programs then you will need to get handles to the windows and then to the controls in that order. Next, read the value of the control into a string and use the functions suggested above.

I would suggest you read http://www.autoitscript.com/autoit3/docs/intro/au3spy.htm the tool comes with the installation of AutoIt. Use it the get the Title or Handle to the window/controls you need then http://www.autoitscript.com/autoit3/docs/guiref/GUIRef.htm but pay special attention to

GUICtrlRead()
I hope that answered your question(s). :)

Anonymous

Spoiler

censored.jpg

 

Link to comment
Share on other sites

Salvia,

I think that you will find this quite useful.

Func _GenerateConverterFunction($sFileName)
    Local $aChar, $aArray = StringSplit(FileRead($sFileName), @CRLF, 1)
    ConsoleWrite("Func _ReplaceCharacters($sString)" & @CRLF)
    For $i = 1 To $aArray[0] Step 1
        $aChar = StringSplit(StringStripWS($aArray[$i], 8), "=", 3)
        If UBound($aChar, 1) <> 2 Then ContinueLoop
        ConsoleWrite(@TAB & '$sString = StringReplace($sString,' & 'ChrW(' & AscW($aChar[0]) & '), "' & $aChar[1] & '")' & @CRLF)
    Next
    ConsoleWrite("EndFunc" & @CRLF & @CRLF)
EndFunc

_GenerateConverterFunction("characters.txt")

Characters.txt

Ё=YO
Ж=ZH
Й=Y'
Х=KH
Ц=TC
Ч=CH
Щ=SHC
Ш=SH
Э=E'
Ю=YU
Я=YA
А=A
Б=B
В=V
Г=G
Д=D
Е=E
З=Z
И=I
К=K
Л=L
М=M
Н=N
О=O
П=P
Р=R
С=S
Т=T
У=U
Ф=F
Ъ='
Ы=Y
Ь='
ё=yo
ж=zh
й=y'
х=kh
ц=tc
ч=ch
щ=shc
ш=sh
э=e'
ю=yu
я=ya
а=a
б=b
в=v
г=g
д=d
е=e
з=z
и=i
к=k
л=l
м=m
н=n
о=o
п=p
р=r
с=s
т=t
у=u
ф=f
ъ='
ы=y
ь='

This is the output of the above function and it works I tested it.

ConsoleWrite(_ReplaceCharacters(FileRead("characters.txt")))

Func _ReplaceCharacters($sString)
    $sString = StringReplace($sString,ChrW(1025), "YO")
    $sString = StringReplace($sString,ChrW(1046), "ZH")
    $sString = StringReplace($sString,ChrW(1049), "Y'")
    $sString = StringReplace($sString,ChrW(1061), "KH")
    $sString = StringReplace($sString,ChrW(1062), "TC")
    $sString = StringReplace($sString,ChrW(1063), "CH")
    $sString = StringReplace($sString,ChrW(1065), "SHC")
    $sString = StringReplace($sString,ChrW(1064), "SH")
    $sString = StringReplace($sString,ChrW(1069), "E'")
    $sString = StringReplace($sString,ChrW(1070), "YU")
    $sString = StringReplace($sString,ChrW(1071), "YA")
    $sString = StringReplace($sString,ChrW(1040), "A")
    $sString = StringReplace($sString,ChrW(1041), "B")
    $sString = StringReplace($sString,ChrW(1042), "V")
    $sString = StringReplace($sString,ChrW(1043), "G")
    $sString = StringReplace($sString,ChrW(1044), "D")
    $sString = StringReplace($sString,ChrW(1045), "E")
    $sString = StringReplace($sString,ChrW(1047), "Z")
    $sString = StringReplace($sString,ChrW(1048), "I")
    $sString = StringReplace($sString,ChrW(1050), "K")
    $sString = StringReplace($sString,ChrW(1051), "L")
    $sString = StringReplace($sString,ChrW(1052), "M")
    $sString = StringReplace($sString,ChrW(1053), "N")
    $sString = StringReplace($sString,ChrW(1054), "O")
    $sString = StringReplace($sString,ChrW(1055), "P")
    $sString = StringReplace($sString,ChrW(1056), "R")
    $sString = StringReplace($sString,ChrW(1057), "S")
    $sString = StringReplace($sString,ChrW(1058), "T")
    $sString = StringReplace($sString,ChrW(1059), "U")
    $sString = StringReplace($sString,ChrW(1060), "F")
    $sString = StringReplace($sString,ChrW(1066), "'")
    $sString = StringReplace($sString,ChrW(1067), "Y")
    $sString = StringReplace($sString,ChrW(1068), "'")
    $sString = StringReplace($sString,ChrW(1105), "yo")
    $sString = StringReplace($sString,ChrW(1078), "zh")
    $sString = StringReplace($sString,ChrW(1081), "y'")
    $sString = StringReplace($sString,ChrW(1093), "kh")
    $sString = StringReplace($sString,ChrW(1094), "tc")
    $sString = StringReplace($sString,ChrW(1095), "ch")
    $sString = StringReplace($sString,ChrW(1097), "shc")
    $sString = StringReplace($sString,ChrW(1096), "sh")
    $sString = StringReplace($sString,ChrW(1101), "e'")
    $sString = StringReplace($sString,ChrW(1102), "yu")
    $sString = StringReplace($sString,ChrW(1103), "ya")
    $sString = StringReplace($sString,ChrW(1072), "a")
    $sString = StringReplace($sString,ChrW(1073), "b")
    $sString = StringReplace($sString,ChrW(1074), "v")
    $sString = StringReplace($sString,ChrW(1075), "g")
    $sString = StringReplace($sString,ChrW(1076), "d")
    $sString = StringReplace($sString,ChrW(1077), "e")
    $sString = StringReplace($sString,ChrW(1079), "z")
    $sString = StringReplace($sString,ChrW(1080), "i")
    $sString = StringReplace($sString,ChrW(1082), "k")
    $sString = StringReplace($sString,ChrW(1083), "l")
    $sString = StringReplace($sString,ChrW(1084), "m")
    $sString = StringReplace($sString,ChrW(1085), "n")
    $sString = StringReplace($sString,ChrW(1086), "o")
    $sString = StringReplace($sString,ChrW(1087), "p")
    $sString = StringReplace($sString,ChrW(1088), "r")
    $sString = StringReplace($sString,ChrW(1089), "s")
    $sString = StringReplace($sString,ChrW(1090), "t")
    $sString = StringReplace($sString,ChrW(1091), "u")
    $sString = StringReplace($sString,ChrW(1092), "f")
    $sString = StringReplace($sString,ChrW(1098), "'")
    $sString = StringReplace($sString,ChrW(1099), "y")
    $sString = StringReplace($sString,ChrW(1100), "'")
    Return $sString
EndFunc

With the end result being.

YO=YO
ZH=ZH
Y'=Y'
KH=KH
TC=TC
CH=CH
SHC=SHC
SH=SH
E'=E'
YU=YU
YA=YA
A=A
B=B
V=V
G=G
D=D
E=E
Z=Z
I=I
K=K
L=L
M=M
N=N
O=O
P=P
R=R
S=S
T=T
U=U
F=F
'='
Y=Y
'='
YO=yo
ZH=zh
Y'=y'
KH=kh
TC=tc
CH=ch
SHC=shc
SH=sh
E'=e'
YU=yu
YA=ya
A=a
B=b
V=v
G=g
D=d
E=e
Z=z
I=i
K=k
L=l
M=m
N=n
O=o
P=p
R=r
S=s
T=t
U=u
F=f
'='
Y=y
'='

*Edit - Added Spoilers.

Anonymous

Edited by Decipher
Spoiler

censored.jpg

 

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...