Changing characters written depending on what follows

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Elaphe666
Posts: 131
Joined: 28 Nov 2015, 11:39

Changing characters written depending on what follows

01 Dec 2016, 12:32

Any idea how I could make a hotkey so that a specific letter (for instance L) followed by any other letter (except vowels) sends itself normally as always, but followed by a,e,i,o or u, sends a different thing, for instance R? It doesn't matter if the letter (L) is not visually written on screen until the next letter is sent, as it's expected.
Fee
Posts: 57
Joined: 05 Aug 2016, 14:30

Re: Changing characters written depending on what follows

01 Dec 2016, 13:05

Two examples you can work on:

https://autohotkey.com/docs/commands/Input.htm

Code: Select all

~l::
Input,c,VL1I
if InStr("aeioul",c)
    Send % "{Blind}{bs 2}r" ((c="l")?"r":c)
return
https://autohotkey.com/docs/Hotstrings.htm

Code: Select all

:*?z:la::
:*?z:le::
:*?z:li::
:*?z:lo::
:*?z:lu::
:*?z:ll::
Send % "{Blind}r" (((t:=SubStr(A_ThisHotkey,0))="l")?"r":t)
return

{Blind} - https://autohotkey.com/docs/commands/Send.htm#blind
Elaphe666
Posts: 131
Joined: 28 Nov 2015, 11:39

Re: Changing characters written depending on what follows

01 Dec 2016, 13:59

Code: Select all

:*?z:'a::
:*?z:'e::
:*?z:'i::
:*?z:'o::
:*?z:'u::
Send % "{Blind}´" (((t:=SubStr(A_ThisHotkey,0))="'")?"´":t)
return
Ok, I've applied your second code to my script, with my real needs. This is for Spanish accents with US keyboards. The idea is to use the same apostrophe key ('), which has the same position on the ANSI layout than the Spanish accent key (´) on our ISO keyboards, which is used for vowels only, so it will be fast, easy and intuitive to remember and to use (much better than holding a modifier key plus the vowel).

So this example is working great. In English when you use the apostrophe, it's normally followed by consonants, so it will work as always. However, when followed by a vowel, it will transform it just like with a Spanish keyboard: a>á, e>é, i>í, o>ó, u>ú.

It's also working for caps, when the caps lock is on (Á, É...). However, with any of the shifts keys, it turns the letter into Ä, Ë, etc. instead or Á, É... Actually, ¨ is the shift modificacion of ´ (what happens when you press and hold shift plus the accent key in a Spanish keyboard). So, now the result of this sequence (', shift + vowel) is Ä. not Á. I'm trying with getkeystate, but there's no difference.

Thanks a lot.
Elaphe666
Posts: 131
Joined: 28 Nov 2015, 11:39

Re: Changing characters written depending on what follows

01 Dec 2016, 19:17

I'm trying to add conditions like these:

Code: Select all

if ( GetKeyState("Shift", "P") = 1 )
but I don't know exactly how to modify

Code: Select all

Send % "{Blind}´" (((t:=SubStr(A_ThisHotkey,0))="'")?"´":t)
so that the vowel is capitalized but the accent is not (not turned from ´to ¨)
Elaphe666
Posts: 131
Joined: 28 Nov 2015, 11:39

Re: Changing characters written depending on what follows

02 Dec 2016, 15:21

After some tests, I have it working as I wanted. If anyone is able to make it shorter and smarter, go ahead. Thanx.

Code: Select all

:*?z:'a::
:*?z:'e::
:*?z:'i::
:*?z:'o::
:*?z:'u::
if ( GetKeyState("Shift", "P") = 0 )
{
Send % "{Blind}´" (((t:=SubStr(A_ThisHotkey,0))="'")?"´":t)
return
}
if ( GetKeyState("Shift", "P") = 1 )
{
Send % "´{shift down}" (((t:=SubStr(A_ThisHotkey,0))="'")?"´":t)
send {shift up}
return
}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Joey5, Nerafius, RandomBoy and 161 guests