Hotstrings using final sigma (Greek alphabet) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Logos

Hotstrings using final sigma (Greek alphabet)

14 Aug 2018, 01:55

Hello, all! So I'm testing out a simple AutoHotkey script using hotstrings that's supposed to automatically add diacritical marks (those tiny squiggly line things that indicate tone, breathing, etc.) to Ancient Greek words. So for example, one line of the code says

Code: Select all

::γλαυκος::γλαῦκος
When the user types γλαυκος, the script replaces it with γλαῦκος. So far, so good. The only problem? I'd also like for this output to be triggered if the user is lazy and ends the input string using a middle-sigma (σ) instead of the final-sigma (ς), so that typing γλαυκοσ will also trigger the replacement with γλαῦκος. I suppose I could just accomplish that with two separate lines by writing

Code: Select all

::γλαυκος::γλαῦκος
::γλαυκοσ::γλαῦκος
but the problem is that this list of entries is big -like, to the tune of 700,000 hotstrings big! If, say, 200,000 of those entries have input strings that end in ς, I'll have to add another 200,000 entries that have the corresponding lines of code where the input strings end in σ. That seems... inelegant. Is there a better workaround, here? Ideally just a few lines of code that I can enter at the top of the script to say something like, "hey, this script should treat the user input keystrokes of ς and σ as being interchangeable"? Thanks in advance!
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Hotstrings using final sigma (Greek alphabet)

14 Aug 2018, 03:56

Normally hotstrings don't trigger each other, unless you make them to do so. You could make the middle-sigma at the end of a word replace to final-sigma which then triggers any of the the final-sigma spelling hotstrings.

Code: Select all

:?O:σ::
	SendLevel,1
	SetKeyDelay,0,0
	SendEvent ς%A_EndChar%
Return
::γλαυκος::γλαῦκος
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Hotstrings using final sigma (Greek alphabet)  Topic is solved

14 Aug 2018, 08:59

You could use the Hotstring function. I've provided 2 examples, one with Greek letters, one with Latin (i.e. English) letters.

Code: Select all

;q:: ;word with diacritics to word without diacritics (plus trailing middle-sigma to final-sigma)
vList := "
(
γλαῦκος
)"

Loop, Parse, vList, `n, `r
{
	vTemp := A_LoopField
	vAbbrev := A_LoopField

	;remove 'accents' (diacritics)
	vAbbrev := StrReplace(vAbbrev, "ῦ", "υ")

	;if word ends in final-sigma, create middle-sigma hotstring
	Hotstring("::" vAbbrev, vTemp)
	if (vAbbrev ~= "ς$")
		Hotstring("::" SubStr(vAbbrev, 1, -1) "σ", vTemp)
}
return

;==================================================

;w:: ;abcs/abcz both go to abcs
vList := "
(
abcs
)"

Loop, Parse, vList, `n, `r
{
	vTemp := A_LoopField
	vAbbrev := A_LoopField
	Hotstring("::" vAbbrev, vTemp)
	if (vAbbrev ~= "s$")
		Hotstring("::" SubStr(vAbbrev, 1, -1) "z", vTemp)
}
return

;==================================================
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Spawnova and 326 guests