 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Veil
Joined: 01 Apr 2008 Posts: 22 Location: Netherlands
|
Posted: Fri Apr 04, 2008 12:54 pm Post subject: Stuck with accents hotkeys, how to fix this? |
|
|
I'm trying to recreate the OSX method for adding diacritical marks. You can press e.g. Alt+e for acute ´ and Alt+u for umlaut. On the next character you press, the accent will be added. Like:
First press: Alt+e (acute accent), then:
-> press a for á
-> press Shift+a for Á
-> press e for é
-> press Shift+e for É
And so forth. I found a script somewhere on this forum, that did exactly that, but it didn't take in to account the Shift-possibility. Here's the script:
| Code: | #UseHook
!e::Return
a::f("a","á")
f(c,d) {
SendInput % A_PriorHotKey = "!e" && A_TimeSincePriorHotkey < 2000 ? d : c
} |
So if you press e, it'll just give e. If the previous hotkey was Alt+e, it'll add an acute accent, the second variable of the function.
I added a third variable to the function, the capitalized version of the character, as so:
| Code: | #UseHook
!e::Return
a::acute("a","á","Á")
e::acute("e","é","É")
; n = normal, o = option (alt in windows), s = shift+option
acute(n,o,s) {
if (A_PriorHotKey = "!e" && A_TimeSincePriorHotkey < 2000) {
if (GetKeyState("Shift")) {
SendInput % s
} else {
SendInput % o
}
} else {
SendInput % n
}
} |
But I'm stuck at the Shift-part. It should differentiate between either "a" or "shift+a", and send the corresponding variable.
With this code, it'll send back "á" when I press Alt+e and then a. But not "Á" when I press Alt+e and then Shift+a; instead just a normal "A".
Any thoughts on how to fix this? |
|
| Back to top |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1259 Location: Denmark
|
Posted: Fri Apr 04, 2008 1:01 pm Post subject: |
|
|
One way:
| Code: | !e::Return
+a::acute("A","Á")
a::acute("a","á")
; n = normal, o = option (alt in windows), s = shift+option
acute(n,o) {
if (A_PriorHotKey = "!e" && A_TimeSincePriorHotkey < 2000) {
SendInput % o
} else {
SendInput % n
}
}
|
_________________ there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face
- Kashmir |
|
| Back to top |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1259 Location: Denmark
|
Posted: Fri Apr 04, 2008 1:06 pm Post subject: |
|
|
Another:
| Code: | !e::Return
; note the * prefix interfere #a, ^a, !a and combinations of other prefix
*a::acute("a","á","Á")
; n = normal, o = option (alt in windows), s = shift+option
acute(n,o,s) {
if (A_PriorHotKey = "!e" && A_TimeSincePriorHotkey < 2000) {
If (GetKeyState("Shift"))
SendInput % s
Else
SendInput % o
} else {
If (GetKeyState("Shift"))
SendInput % "+" . n
Else
SendInput % n
}
} |
_________________ there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face
- Kashmir |
|
| Back to top |
|
 |
Veil
Joined: 01 Apr 2008 Posts: 22 Location: Netherlands
|
Posted: Fri Apr 04, 2008 2:03 pm Post subject: |
|
|
Works great, thank you!
I still didn't really get how the * works, but I think I've got it now. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|