Replace Latin letters with Greek, problem

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
siomosp
Posts: 27
Joined: 18 Jan 2022, 10:21

Replace Latin letters with Greek, problem

Post by siomosp » 04 Mar 2022, 16:50

Hi!
I am looking for a simple script to quick replace text accidentally written with Latin letters , instead of Greek :D ( It happens sooo often when replying mails at work...)
This script replace the Latin letters, one by one, with Greek ("; 1st step")
Of course the grammar , is not always correct, so I am trying to define another replacement pattern for partially handling grammar.
It it seems is not possible at "2nd step" to make the replacement.

Code: Select all

#SingleInstance, force
F1::
Clipboard := "" ; Empty the clipboard
Send, ^c
ClipWait, 0.5

; 1st step , 1 letter replacement
chars1 :={α:"[a]"
	    ,υ:"[u]"
	    ,τ:"[t]"
	    ,ο:"[o]"	
        ,κ:"[k]"
		,ν:"[n]"
		,ι:"[i]"
		,τ:"[t]"
		,"ο": "[o]"}
		
myString1 :=	Clipboard
For replace, find in chars1
	myString1 :=	RegExReplace(myString1,find,replace)
	
; 2nd step, 2 letters replacement ; this step is not working
chars2 :={κι:"[ki]"
	    ,νη:"[ni]"	 ; this is the part need to change at my provided test word 
		,"μη": "[mi]"}
		
For replace, find in chars2
	myString2 :=RegExReplace(myString1,find,replace)
	
MsgBox %myString1% - %myString2%
The test word is

Code: Select all

autokinito
result is

Code: Select all

αυτοκινιτο
it should be , if the code at line 24 was working

Code: Select all

αυτοκινητο
Any help (or ideas for a different approach) are welcome

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: Replace Latin letters with Greek, problem

Post by mikeyww » 04 Mar 2022, 16:59

Your first loop updates the string iteratively. Your second loop does not. Instead, it always uses the original source string. That is the bug.

siomosp
Posts: 27
Joined: 18 Jan 2022, 10:21

Re: Replace Latin letters with Greek, problem

Post by siomosp » 04 Mar 2022, 17:24

Thank you, i think i can fix it...

Post Reply

Return to “Ask for Help (v1)”