'How to change the behavior of accents from ´ symbol to ` symbol

I have the following script for typing Spanish accents:

AppsKey::var := "´"

#if (var = "´"), var := ""
a::Send, á
e::Send, é
i::Send, í
o::Send, ó
u::Send, ú
+a::Send, Á
+e::Send, É
+i::Send, Í
+o::Send, Ó
+u::Send, Ú

If I run this then I have to type the ´ symbol (Acute accent - spacing acute) for the vowels to have the accent. This symbol is not "easy" to type on a US keyboard, so I want to change that for the following symbol: ` (Grave accent)

The issue is, when I change it on the script all the vowels have the accent always, not just when I press de grave accent symbol.

I don't know why this is and haven't been able to solve it. Does anybody know how?



Solution 1:[1]

It seems that what you need is to use hotstrings instead of hotkeys, but declare a different escape character, so something like this:

#EscapeChar /
:*C:`a::á
:*C:`e::é
:*C:`i::í
Etc…

The asterisk in the first set of colons indicates that the hotstring will not wait for an end key such as space or enter to be pressed for the hotstring to fire. The capital C indicates that hotstring is case sensitive. What new escape char you use is up to you.

Solution 2:[2]

The grave accent is used in AHK as the escape sequence character. "`" isn't read as the string containing a grave, it's an open string containing a single ". You should be able to fix this back escaping the grave itself by writing "``".

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Hovercouch