thanks in advance for your valuable and diligent assistance !
I have a little Qwerty laptop and I'm trying to remap unaccented vowels into accented ones using AHK (AutohotKey).
ISSUE #1:
For example, for the letter e, if I press "e" and "right arrow" altogether, I should get "é"; and if I do the same combination with Capslock activated, I should get "É". So I used the following script:
e & Right::
if GetKeyState("CapsLock", "t")
send É
else
send é
return
It works !... Except that the "e" key is no longer functional after this.
REQUEST #1:
How do you preserve the "e" key in the previous script ?
ISSUE #2:
Instead of repeating the same (corrected) previous script for each vowel to be accentuated in upper and lower case (all vowels {a,e,i,o,u}) ...
REQUEST #2:
Can you create for me an optimized generic script, using this set of vowels as variables, such as:
If Capslock is activated and I simultaneously press a Vowel and:
If Capslock is not activated and I simultaneously press a vowel and:
My initial goal was to use my QWERTY keyboard as-is while being able to quickly generate accented vowels with a 2-key hotkeys (a Vowel & an Arrow Key). After digesting the AHK v2 documentation, I wrote the following script which even exceeds my expectations...
#SingleInstance Force
#Warn All
;I. ACCENTED VOWELS
; CORRESPONDENCE TABLE
; SECOND-BUTTON: a, A, o, O, e, E, i, I, u, U
; INDEX NUMBERS: 1 2 3 4 5 6 7 8 9 10
; FIRST-BUTTON:
; [RIGHT] á, Á, ó, Ó, é, É, í, Í, ú, Ú
; [LEFT] à, À, ò, Ò, è, È, ì, Ì, ù, Ù
; [UP] â, Â, ô, Ô, ê, Ê, î, Î, û, Û
; [DOWN] ä, Ä, ö, Ö, ë, Ë, ï, Ï, ü, Ü
VowelKeys_Str := "a,A,o,O,e,E,i,I,u,U"
VowelKeys_Arr := StrSplit(VowelKeys_Str, ",")
Acute_Arr := ["á", "Á", "ó", "Ó", "é", "É", "í", "Í", "ú", "Ú"]
Grave_Arr := ["à", "À", "ò", "Ò", "è", "È", "ì", "Ì", "ù", "Ù"]
Cflex_Arr := ["â", "Â", "ô", "Ô", "ê", "Ê", "î", "Î", "û", "Û"]
Trema_Arr := ["ä", "Ä", "ö", "Ö", "ë", "Ë", "ï", "Ï", "ü", "Ü"]
; For Acute Vowels : Press [RIGHT] Button with the corresponding [Vowel] Key (Lowercase or Uppercase)
Right::
{
IH := InputHook("C T0.4", "", VowelKeys_Str)
IH.start()
IH.wait()
KEY := IH.Match
Loop
{
if A_Index > 10
{
SendInput "{Right}"
break
}
if VowelKeys_Arr[A_Index] == KEY
{
SendInput Acute_Arr[A_Index]
break
}
}
}
; For Grave Vowels : Press [LEFT] Button with the corresponding [Vowel] Key (Lowercase or Uppercase)
Left::
{
IH := InputHook("C T0.4", "", VowelKeys_Str)
IH.start()
IH.wait()
KEY := IH.Match
Loop
{
if A_Index > 10
{
SendInput "{Left}"
break
}
if VowelKeys_Arr[A_Index] == KEY
{
SendInput Grave_Arr[A_Index]
break
}
}
}
; For Circumflex Vowels : Press [UP] Button with the corresponding [Vowel] Key (Lowercase or Uppercase)
Up::
{
IH := InputHook("C T0.4", "", VowelKeys_Str)
IH.start()
IH.wait()
KEY := IH.Match
Loop
{
if A_Index > 10
{
SendInput "{Up}"
break
}
if VowelKeys_Arr[A_Index] == KEY
{
SendInput Cflex_Arr[A_Index]
break
}
}
}
; For Trema Vowels : Press [DOWN] Button with the corresponding [Vowel] Key (Lowercase or Uppercase)
Down::
{
IH := InputHook("C T0.4", "", VowelKeys_Str)
IH.start()
IH.wait()
KEY := IH.Match
Loop
{
if A_Index > 10
{
SendInput "{Down}"
break
}
if VowelKeys_Arr[A_Index] == KEY
{
SendInput Trema_Arr[A_Index]
break
}
}
}
;II. SYMBOLS (AND SOME SPECIAL LETTERS)
; CORRESPONDENCE TABLE
; SECOND-BUTTON: a, A, o, O, c, C, e, d, p, y, n, r, s, b, v, w, q, h, x, t, z
; INDEX NUMBERS: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
; FIRST-BUTTON:
; [END] æ, Æ, œ, Œ, ç, Ç, €, $, £, ¥, &, @, §, ¦, |, !, ?, ", *, °, º
LetterKeys_Str := "a,A,o,O,c,C,e,d,p,y,n,r,s,b,v,w,q,h,x,t,z"
LetterKeys_Arr := StrSplit(LetterKeys_Str, ",")
Symbols_Arr := ["æ", "Æ", "œ", "Œ", "ç", "Ç", "€", "$", "£", "¥", "`&", "@", "§", "¦", "|", "{!}", "`?", "`"", "*", "°", "º"]
; For Symbols : Press [END] Button with the corresponding [Letter] Key (Lowercase or Uppercase)
End::
{
IH := InputHook("C T0.4", "", LetterKeys_Str)
IH.start()
IH.wait()
KEY := IH.Match
Loop
{
if A_Index > 21
{
SendInput "{End}"
break
}
if LetterKeys_Arr[A_Index] == KEY
{
SendInput Symbols_Arr[A_Index]
break
}
}
}