Easy accents including french ç as well as spanish ñ and ¿ and ¡

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
guivho
Posts: 15
Joined: 09 Mar 2017, 08:59
Contact:

Easy accents including french ç as well as spanish ñ and ¿ and ¡

25 Oct 2020, 08:19

Hi, there used to be a forum topic at How to enter basic Spanish accented characters but I can not post a reply in there anymore. Out of gratitude to the whole Autohotkey community I just want to post my personal solution that enables easy French and Spanish characters on a qwerty keyboard. I find it very convenient and hope it might help others.

Code: Select all

/*
Easy accents on a qwerty keyboard including french ç as well as spanish ñ and ¿ 1nd ¡

Inspired a.o. by https://autohotkey.com/board/topic/16920-how-to-enter-basic-spanish-accented-characters/
Note: Obtained the unicode values at: https en.wikipedia.org /wiki/List_of_Unicode_characters  Broken Link for safety  

Basiclly this solution allows to type any vowel followed by any of ['"\^] to obtain the 'accented' version:
' after [aeiou] produces [áéíóú]
" after [aeiou] produces [äëïöü]
\ after [aeiou] produces [àèìòù]
^ after [aeiou] produces [âêîôû]
' after [NnCc?!] procuces [ÑñÇç¿¡]

This approach requires extra care to enter a quote or single quote character as such after a vowel.
This is cared for by preceding ' or " with a space:
this sequence will be changed into a ' or " without the ledig space.

Note: I use the \ key to issue an ` accent, because it is available
on my US Apple keyboard as an extra key between the single/double quotes key and the return key.
This is just a personal lazy solution, the real ` key could be used as well.
*/

;; a ;;
:C*?:A\::{U+00C0} ; A followed by \ => À
:C*?:A'::{U+00C1} ; A followed by ' => Á
:C*?:A^::{U+00C2} ; A followed by ^ => Â
:C*?:A"::{U+00C4} ; A followed by " => Ä
:C*?:a\::{U+00E0} ; a followed by \ => à
:C*?:a'::{U+00E1} ; a followed by ' => á
:C*?:a^::{U+00E2} ; a followed by ^ => â
:C*?:a"::{U+00E4} ; a followed by " => ä

;; e ::
:C*?:E\::{U+00C8} ; E followed by \ => È
:C*?:E'::{U+00C9} ; E followed by ' => É
:C*?:E^::{U+00CA} ; E followed by ^ => Ê
:C*?:E"::{U+00CB} ; E followed by " => Ë
:C*?:e\::{U+00E8} ; e followed by \ => è
:C*?:e'::{U+00E9} ; e followed by ' => é
:C*?:e^::{U+00EA} ; e followed by ^ => ê
:C*?:e"::{U+00EB} ; é followed by " => ë

;; i ;;
:C*?:I\::{U+00CC} ; I followed by \ => Ì
:C*?:I'::{U+00CD} ; I followed by ' => Í
:C*?:I^::{U+00CE} ; I followed by ^ => Î
:C*?:I"::{U+00CF} ; I followed by " => Ï
:C*?:i\::{U+00EC} ; i followed by \ => ì
:C*?:i'::{U+00ED} ; i followed by ' => í
:C*?:i^::{U+00EE} ; i followed by ^ => î
:C*?:i"::{U+00EF} ; i followed by " => ï

;; o ;;
:C*?:O\::{U+00D2} ; O followed by \ => Ò
:C*?:O'::{U+00D3} ; O followed by ' => Ó
:C*?:O^::{U+00D4} ; O followed by ^ => Ô
:C*?:O"::{U+00D6} ; O followed by " => Ö
:C*?:o\::{U+00F2} ; o followed by \ => ò
:C*?:o'::{U+00F3} ; o followed by ' => ó
:C*?:o^::{U+00F4} ; o followed by ^ => ô
:C*?:o"::{U+00F6} ; o followed by " => ö

;; u ;;
:C*?:U\::{U+00D9} ; U followed by \ => Ù
:C*?:U'::{U+00DA} ; U followed by ' => Ú
:C*?:U^::{U+00DB} ; U followed by ^ => Û
:C*?:U"::{U+00DC} ; U followed by " => Ü
:C*?:u\::{U+00F9} ; u followed by \ => ù
:C*?:u'::{U+00FA} ; u followed by ' => ú
:C*?:u^::{U+00FB} ; u followed by ^ => û
:C*?:u"::{U+00FC} ; u followed by " => ü

;; c ;;
:C*?:C'::{U+00C7} ; C followed by ' => Ç
:C*?:c'::{U+00E7} ; c followed by ' => ç

;; n ;;
:C*?:N'::{U+00D1} ; N followed by ' => N
:C*?:n'::{U+00F1} ; n followed by ' => ñ
:C*?:N|::{U+00D1} ; N followed by | => N
:C*?:n|::{U+00F1} ; n followed by | => ñ

;; ! ;;
:*?:!'::{U+00A1} ; ! followed by ' => ¡

;; ? ;;
:*?:?'::{U+00BF} ; ? followed by ' => ¿

;; {space} followed by single quote removes the space and issues a ' (allows a quote after e, o...);;
:*?: '::' ; '

;; {space} followed by double quote removes the space and issues a " (allows a " after e, o...);;
:*?: "::" ; "

;; Thanks for comments and or corrections to Guido Van Hoecke <[email protected]>

[Mod edit: c-tags replaced with [code][/code] tags.]
Greast
Posts: 71
Joined: 24 Oct 2020, 19:01

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

28 Oct 2020, 20:07

Also, you could simply use

Code: Select all

::a\::À
But of course, you need to press space or enter.
Last edited by Greast on 29 Oct 2020, 11:10, edited 1 time in total.
gregster
Posts: 8916
Joined: 30 Sep 2013, 06:48

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

29 Oct 2020, 00:46

Greast wrote:
28 Oct 2020, 20:07
Post it on Scripts and Functions.
what are you talking about? That's where it is - and was.

@guivho: Thank you for your contribution to the forum! :thumbup:
Greast
Posts: 71
Joined: 24 Oct 2020, 19:01

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

29 Oct 2020, 11:12

@gregster
My bad... I think that posts on Unanswered are Ask for help...
User avatar
guivho
Posts: 15
Joined: 09 Mar 2017, 08:59
Contact:

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

18 Nov 2020, 17:44

Hi,

I'd like to offer a less intrusive way to type accented vowels et al. My previous approach permanently changed the behavior of the single and double quotes keys, which becomes awkward e.g. when typing software. This approach doesn't change them.

It is a lot of code lines. But I want to provide the complete implementation, ready to be used by whom may desire so.

Code: Select all

;; Generate accented vowels by prefixing them with Ctrl-', Ctrl-\, Ctrl-" or Ctrl-^
;; I chose Ctrl-\ for accent grave prefix, but feel free to change to your liking
;; This can easily be expanded for accented consonants if needed. In fact I use the
;; Ctrl-' followed by c, C, n, N, ? or ! to generate ç, Ç, ñ, Ñ, ¿ or ¡.

;; This is inspired a.o by https://www.autohotkey.com/boards/viewtopic.php?f=76&t=72327
;; My other implementation at https://www.autohotkey.com/boards/viewtopic.php?f=6&t=82484
;; is better for touch typing, but the single and double quote behaviour is difficult
;; when programming.

;; The problem to overcome was the fact that we really want a kind of hotstring, such as
;; Ctrl-' and a, but caracters with modifiers can not be part of a hotstring sequence.
;; So this is circumvented by remembering in a global value wich prefix was typed.
;; If this is followed by one of the supported characters, the trigger value is reset
;; after sending the required accented character.

;; Once the trigger state is set to a non zero value, it preserves that state until one
;; of [aAeEuUiIoOcCnN?!] is typed.
;; The trigger remains active until of the supported characters is typed, even after
;; one or more not supported characters were typed in between: Ctrl-' go produces gó.
;; Ideally this should not happen, but I didn't yet find a solution for it.

;; Corrections and/or suggestions to [email protected] are more than welcome.

;; The Trigger variable controls generation of accented characters and ç, Ç, ñ, Ñ, ¿, ¡
global Trigger := 0 ; define the control variable and set it to inactive state

;; Set the Hotkeys to set the trigger to each of the four triggers
^'::Trigger := 1 ;;prefix for á, Á, é, É, í, Í, ó, Ó, ú, Ú, ç, Ç, ñ, Ñ, ¿, ¡
^\::Trigger := 2 ;;prefix for à, À, è, È, ì, Í, ò, Ò, ù, Ù
^"::Trigger := 3 ;;prefix for ä, Ä, ë, Ë, ï, Ï, ö, Ö, ü, Ü
^^::Trigger := 4 ;;prefix for â, Â, ê, Ê, î, Î, ô, Ô, û, Û

#if (Trigger=1) ;;prefix was for á, Á, é, É, í, Í, ó, Ó, ú, Ú, ç, Ç, ñ, Ñ
{
:C*?:a::
    SendInput {U+00E1} ; á
    Trigger := 0
    return

:C*?:A::
    SendInput {U+00C1} ; Á
    Trigger := 0
    return

:C*?:e::
    SendInput {U+00E9} ; é
    Trigger := 0
    return

:C*?:E::
    SendInput {U+00C9} ; É
    Trigger := 0
    return

:C*?:i::
    SendInput {U+00ED} ; í
    Trigger := 0
    return

:C*?:I::
    SendInput {U+00CD} ; Í
    Trigger := 0
    return

:C*?:o::
    SendInput {U+00F3} ; ó
    Trigger := 0
    return

:C*?:O::
    SendInput {U+00D3} ; Ó
    Trigger := 0
    return

:C*?:u::
    SendInput {U+00FA} ; ú
    Trigger := 0
    return

:C*?:U::
    SendInput {U+00DA} ; Ú
    Trigger := 0
    return

:C*?:c::
    SendInput {U+00E7} ; ç
    Trigger := 0
    return

:C*?:C::
    SendInput {U+00C7} ; Ç
    Trigger := 0
    return

:C*?:n::
    SendInput {U+00F1} ; ñ
    Trigger := 0
    return

:C*?:N::
    SendInput {U+00D1} ; Ñ
    Trigger := 0
    return

:*?:!::
    SendInput {U+00A1} ; ¡
    Trigger := 0
    return

:*?:?::
    SendInput {U+00BF} ; ¿
    Trigger := 0
    return

Trigger := 0 ;; should but doesn't reset it for any other character
}

#if % Trigger=2 ;;prefix was for à, À, è, È, ì, Í, ò, Ò, ù, Ù
{
:C*?:a::
    SendInput {U+00E0} ; à
    Trigger := 0
    return

:C*?:A::
    SendInput {U+00C0} ; À
    Trigger := 0
    return

:C*?:e::
    SendInput {U+00E8} ; é
    Trigger := 0
    return

:C*?:E::
    SendInput {U+00C8} ; È
    Trigger := 0
    return

:C*?:i::
    SendInput {U+00EC} ; ì
    Trigger := 0
    return

:C*?:I::
    SendInput {U+00CC} ; Ì
    Trigger := 0
    return

:C*?:o::
    SendInput {U+00F2} ; ò
    Trigger := 0
    return

:C*?:O::
    SendInput {U+00D2} ; Ò
    Trigger := 0
    return

:C*?:u::
    SendInput {U+00F9} ; ù
    Trigger := 0
    return

:C*?:U::
    SendInput {U+00D9} ; Ù
    Trigger := 0
    return

Trigger := 0 ;; should but doesn't reset it for any other character
}

#if % Trigger=3 ;;prefix was for à, À, è, È, ì, Í, ò, Ò, ù, Ù
{
:C*?:a::
    SendInput {U+00E4} ; ä
    Trigger := 0
    return

:C*?:A::
    SendInput {U+00C4} ; Ä
    Trigger := 0
    return

:C*?:e::
    SendInput {U+00EB} ; ë
    Trigger := 0
    return

:C*?:E::
    SendInput {U+00CB} ; Ë
    Trigger := 0
    return

:C*?:i::
    SendInput {U+00EF} ; ï
    Trigger := 0
    return

:C*?:I::
    SendInput {U+00CF} ; Ï
    Trigger := 0
    return

:C*?:o::
    SendInput {U+00F6} ; ö
    Trigger := 0
    return

:C*?:O::
    SendInput {U+00D6} ; Ö
    Trigger := 0
    return

:C*?:u::
    SendInput {U+00FC} ; ü
    Trigger := 0
    return

:C*?:U::
    SendInput {U+00DC} ; Ü
    Trigger := 0
    return

Trigger := 0 ;; should but doesn't reset it for any other character
}

#if % Trigger=4 ;;prefix was for â, Â, ê, Ê, î, Î, ô, Ô, û, Û
{
:C*?:a::
    SendInput {U+00E2} ; â
    Trigger := 0
    return

:C*?:A::
    SendInput {U+00C2} ; Â
    Trigger := 0
    return

:C*?:e::
    SendInput {U+00EA} ; ê
    Trigger := 0
    return

:C*?:E::
    SendInput {U+00CA} ; Ê
    Trigger := 0
    return

:C*?:i::
    SendInput {U+00EE} ; î
    Trigger := 0
    return

:C*?:I::
    SendInput {U+00CE} ; Î
    Trigger := 0
    return

:C*?:o::
    SendInput {U+00F4} ; ô
    Trigger := 0
    return

:C*?:O::
    SendInput {U+00D4} ; Ô
    Trigger := 0
    return

:C*?:u::
    SendInput {U+00FB} ; û
    Trigger := 0
    return

:C*?:U::
    SendInput {U+00DB} ; Û
    Trigger := 0
    return

Trigger := 0 ;; should but doesn't reset it for any other character
}

User avatar
guivho
Posts: 15
Joined: 09 Mar 2017, 08:59
Contact:

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

18 Apr 2021, 09:43

I switched to an implementation that uses CapsLock as main trigger key. I find this more convenient and faster than my previous implementations:

Code: Select all

/*
Generate accented and special characters by prefixing them with (modifier and) CapsLock
e.g. Ctrl_CapsLock a produces à. The available combinations are listed in this table:

| Trigger | Modifier | Main key | aAeEiIoOuUcCnN?!s |
|---------+----------+----------+-------------------|
|       1 |          | CapsLock | áÁéÉíÍóÓúÚçÇñÑ¿¡ß |
|       2 | Ctrl     | CapsLock | àÀèÈìÍòÒùÙ        |
|       3 | Alt      | CapsLock | äÄëËïÏöÖüÜ        |
|       4 | Shift    | CapsLock | âÂêÊîÎôÔûÛ        |

This is inspired a.o by https://www.autohotkey.com/boards/viewtopic.php?f=76&t=72327
My other implementation at https://www.autohotkey.com/boards/viewtopic.php?f=6&t=82484
is better for touch typing, but the single and double quote behaviour is difficult
when programming.

I use this mainly when studying spanish where the accent aigu is used most often.
So characters áÁéÉíÍóÓúÚçÇñÑ¿¡β are all produced with a simple CapsLock followed by
aAeEiIoOuUcCnN?!s. The accent grave, diaresis and circonflexe combinations are
obtained by using modifier Ctrl, Alt or Shift with the CapsLock key.

The problem to overcome was the fact that we really want a hotstring with optional
modifiers, such as e.g. Ctrl-CapsLock followed by the character a,
but characters with modifiers can not be part of a hotstring sequence.

So this is circumvented by remembering in a global value wich prefix was typed
thus linking it to the corresponding trigger state.

Once the trigger state is set to a non zero value, it preserves that state for 1000 msecs.
So if you're fast CapsLock o o gives óó, a liitle slower gives óo, too slow gives oo.

Corrections and/or suggestions to [email protected] are more than welcome.

*/

;; Define the global trigger variable
global Trigger := 0 ; set it to inactive state

;; Save current trigger value for 1000 msecs
TimeTheTrigger(code) {
  Trigger := code
  SetTimer, AccentTimer, 1000
}
AccentTimer:
  Trigger := 0 ; timer elapsed
return

;; Set each of the four trigger states
CapsLock::TimeTheTrigger(1) ;;prefix for ' et al
^CapsLock::TimeTheTrigger(2) ;;prefix for `
!CapsLock::TimeTheTrigger(3) ;;prefix for diaresis
+CapsLock::TimeTheTrigger(4) ;;prefix for circonflexe

;; Handle áÁéÉíÍóÓúÚçÇñÑ¿¡β

#if (Trigger=1)
{
  :C*?:a::{U+00E1} ; á
  :C*?:A::{U+00C1} ; Á
  :C*?:e::{U+00E9} ; é
  :C*?:E::{U+00C9} ; É
  :C*?:i::{U+00ED} ; í
  :C*?:I::{U+00CD} ; Í
  :C*?:o::{U+00F3} ; ó
  :C*?:O::{U+00D3} ; Ó
  :C*?:u::{U+00FA} ; ú
  :C*?:U::{U+00DA} ; Ú
  :C*?:c::{U+00E7} ; ç
  :C*?:C::{U+00C7} ; Ç
  :C*?:n::{U+00F1} ; ñ
  :C*?:N::{U+00D1} ; Ñ
  :*?:!::{U+00A1} ; ¡
  :*?:?::{U+00BF} ; ¿
  :*?:s::{U+03B2} ; ß
}

;; Handle àÀèÈìÍòÒùÙ

#if % Trigger=2
{
  :C*?:a::{U+00E0} ; à
  :C*?:A::{U+00C0} ; À
  :C*?:e::{U+00E8} ; é
  :C*?:E::{U+00C8} ; È
  :C*?:i::{U+00EC} ; ì
  :C*?:I::{U+00CC} ; Ì
  :C*?:o::{U+00F2} ; ò
  :C*?:O::{U+00D2} ; Ò
  :C*?:u::{U+00F9} ; ù
  :C*?:U::{U+00D9} ; Ù
}

;; Handle äÄëËïÏöÖüÜ

#if % Trigger=3
{
  :C*?:a::{U+00E4} ; ä
  :C*?:A::{U+00C4} ; Ä
  :C*?:e::{U+00EB} ; ë
  :C*?:E::{U+00CB} ; Ë
  :C*?:i::{U+00EF} ; ï
  :C*?:I::{U+00CF} ; Ï
  :C*?:o::{U+00F6} ; ö
  :C*?:O::{U+00D6} ; Ö
  :C*?:u::{U+00FC} ; ü
  :C*?:U::{U+00DC} ; Ü
}

;; Handle âÂêÊîÎôÔûÛ

#if % Trigger=4
{
  :C*?:a::{U+00E2} ; â
  :C*?:A::{U+00C2} ; Â
  :C*?:e::{U+00EA} ; ê
  :C*?:E::{U+00CA} ; Ê
  :C*?:i::{U+00EE} ; î
  :C*?:I::{U+00CE} ; Î
  :C*?:o::{U+00F4} ; ô
  :C*?:O::{U+00D4} ; Ô
  :C*?:u::{U+00FB} ; û
  :C*?:U::{U+00DB} ; Û
}

User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

18 Apr 2021, 15:41

I think you find very friendly way to write diacritics. Addded this to toggle CapsLock via long press.

Code: Select all

CapsLock:: TimeTheTrigger(1), st? "": st:= A_TickCount
CapsLock Up::
    if (A_TickCount-st > 350, st:= "")
        if (GetKeyState("CapsLock", "T"), TimeTheTrigger(0))
            SetCapsLockState, Off
        else SetCapsLockState, On
Return
User avatar
guivho
Posts: 15
Joined: 09 Mar 2017, 08:59
Contact:

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

19 Apr 2021, 01:22

Thanks,

Nice extra for people who need the original functionality of CapsLock.
User avatar
guivho
Posts: 15
Joined: 09 Mar 2017, 08:59
Contact:

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

05 May 2021, 04:37

The script has evolved further, so here is the latest version:

Code: Select all

/*
Generate accented and special characters by prefixing them with (modifier and) CapsLock
e.g. Ctrl_CapsLock a produces à. The available combinations are listed in this table:

| Accent      | Modifier | Primary  | aaeeiioouuccnn?!s |
|-------------+----------+----------+-------------------|
| Aigu        |          | Capslock | ááééííóóúúççññ¿¡ß |
| Grave       | Shift    | Capslock | ààèèìíòòùù        |
| Circonflexe | Ctrl     | Capslock | ââêêîîôôûû        |
| Diaresis    | Alt      | Capslock | ääëëïïööüü        |

This is inspired a.o by https://www.autohotkey.com/boards/viewtopic.php?f=76&t=72327
My other implementation at https://www.autohotkey.com/boards/viewtopic.php?f=6&t=82484
is better for touch typing, but the single and double quote behaviour is difficult
when programming.

I use this mainly when studying spanish where the accent aigu is used most often.
So characters áÁéÉíÍóÓúÚçÇñÑ¿¡β are all produced with a simple CapsLock followed by
aAeEiIoOuUcCnN?!s. The accent grave, diaresis and circonflexe combinations are
obtained by using modifier Shift, Alt or Ctrl with the CapsLock key.

They can also be produced by following the CapsLock with ', 6 or 7 before typing
one of the aAeEiIoOu characters:

| Accent      | Primary  | Secondary | aAeEiIoOuU |
|-------------+----------+-----------+------------|
| Grave       | CapsLock |         ' | àÀèÈìÍòÒùÙ |
| Circonflexe | CapsLock |         6 | âÂêÊîÎôÔûÛ |
| Diaresis    | CapsLock |         7 | äÄëËïÏöÖüÜ |

The problem to overcome was the fact that we really want a hotstring with optional
modifiers, such as e.g. Ctrl-CapsLock followed by the character a,
but characters with modifiers can not be part of a hotstring sequence.

So this is circumvented by remembering in a global value wich prefix was typed
thus linking it to the corresponding trigger state.

Once the trigger state is set to a non zero value, it preserves that state until
you hit one of the implemented accent characters for a maximum period of 1500 msecs.

Corrections and/or suggestions to [email protected] are more than welcome.

*/

;; Define the global trigger variable
global Trigger := 0 ; set it to inactive state

;; Save current trigger value for 1000 msecs
TimeTheTrigger(code) {
    Trigger := code
    SetTimer, AccentTimer, 1500
}
AccentTimer:
    Trigger := 0 ; timer elapsed
    return

;; Send the character and reser the trigger
SndAndReset(char){
    SendInput, %char%
    Trigger := 0
}

;; Set each of the four trigger states
CapsLock::TimeTheTrigger(1) ;;prefix for ' et al
+CapsLock::TimeTheTrigger(2) ;;prefix for `
!CapsLock::TimeTheTrigger(3) ;;prefix for diaresis
^CapsLock::TimeTheTrigger(4) ;;prefix for circonflexe

;; Handle áÁéÉíÍóÓúÚçÇñÑ¿¡β

#if (Trigger=1)
{
      6::TimeTheTrigger(4) ;;CapsLock 6 circonflexe
      7::TimeTheTrigger(3) ;;CapsLock 7 diaresis
      '::TimeTheTrigger(2) ;;CapsLock ' accent grave
  :C*?:a::
       SndAndReset("{U+00E1}") ; á
       return
  :C*?:A::
       SndAndReset("{U+00C1}") ; Á
       return
  :C*?:e::
       SndAndReset("{U+00E9}") ; é
       return
  :C*?:E::
       SndAndReset("{U+00C9}") ; É
       return
  :C*?:i::
       SndAndReset("{U+00ED}") ; í
       return
  :C*?:I::
       SndAndReset("{U+00CD}") ; Í
       return
  :C*?:o::
       SndAndReset("{U+00F3}") ; ó
       return
  :C*?:O::
       SndAndReset("{U+00D3}") ; Ó
       return
  :C*?:u::
       SndAndReset("{U+00FA}") ; ú
       return
  :C*?:U::
       SndAndReset("{U+00DA}") ; Ú
       return
  :C*?:c::
       SndAndReset("{U+00E7}") ; ç
       return
  :C*?:C::
       SndAndReset("{U+00C7}") ; Ç
       return
  :C*?:n::
       SndAndReset("{U+00F1}") ; ñ
       return
  :C*?:N::
       SndAndReset("{U+00D1}") ; Ñ
       return
  :*?:!::
       SndAndReset("{U+00A1}") ; ¡
       return
  :*?:?::
       SndAndReset("{U+00BF}") ; ¿
       return
  :*?:s::
       SndAndReset("{U+03B2}") ; ß
       return
}

;; Handle àÀèÈìÍòÒùÙ

#if % Trigger=2
{
  :C*?:a::
         SndAndReset("{U+00E0}") ; à
         return
  :C*?:A::
         SndAndReset("{U+00C0}") ; À
         return
  :C*?:e::
         SndAndReset("{U+00E8}") ; é
         return
  :C*?:E::
         SndAndReset("{U+00C8}") ; È
         return
  :C*?:i::
         SndAndReset("{U+00EC}") ; ì
         return
  :C*?:I::
         SndAndReset("{U+00CC}") ; Ì
         return
  :C*?:o::
         SndAndReset("{U+00F2}") ; ò
         return
  :C*?:O::
         SndAndReset("{U+00D2}") ; Ò
         return
  :C*?:u::
         SndAndReset("{U+00F9}") ; ù
         return
  :C*?:U::
         SndAndReset("{U+00D9}") ; Ù
         return
}

;; Handle äÄëËïÏöÖüÜ

#if % Trigger=3
{
  :C*?:a::
         SndAndReset("{U+00E4}") ; ä
         return
  :C*?:A::
         SndAndReset("{U+00C4}") ; Ä
         return
  :C*?:e::
         SndAndReset("{U+00EB}") ; ë
         return
  :C*?:E::
         SndAndReset("{U+00CB}") ; Ë
         return
  :C*?:i::
         SndAndReset("{U+00EF}") ; ï
         return
  :C*?:I::
         SndAndReset("{U+00CF}") ; Ï
         return
  :C*?:o::
         SndAndReset("{U+00F6}") ; ö
         return
  :C*?:O::
         SndAndReset("{U+00D6}") ; Ö
         return
  :C*?:u::
         SndAndReset("{U+00FC}") ; ü
         return
  :C*?:U::
         SndAndReset("{U+00DC}") ; Ü
         return
}

;; Handle âÂêÊîÎôÔûÛ

#if % Trigger=4
{
  :C*?:a::
         SndAndReset("{U+00E2}") ; â
         return
  :C*?:A::
         SndAndReset("{U+00C2}") ; Â
         return
  :C*?:e::
         SndAndReset("{U+00EA}") ; ê
         return
  :C*?:E::
         SndAndReset("{U+00CA}") ; Ê
         return
  :C*?:i::
         SndAndReset("{U+00EE}") ; î
         return
  :C*?:I::
         SndAndReset("{U+00CE}") ; Î
         return
  :C*?:o::
         SndAndReset("{U+00F4}") ; ô
         return
  :C*?:O::
         SndAndReset("{U+00D4}") ; Ô
         return
  :C*?:u::
         SndAndReset("{U+00FB}") ; û
         return
  :C*?:U::
         SndAndReset("{U+00DB}") ; Û
         return
}

User avatar
guivho
Posts: 15
Joined: 09 Mar 2017, 08:59
Contact:

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

23 Jun 2022, 03:04

To whom it may benefit: my script has evolved (due to intermittent chromebook use) and I prefer this approach and find it very convenient.

Code: Select all

    /*
    Easy accents on a qwerty keyboard including french ç as well as spanish ñ and ¿ 1nd ¡
    
    Note: Obtained the unicode values at: https en.wikipedia.org /wiki/List_of_Unicode_characters  Spaced Link for safety
    
    Basiclly this solution allows to type any vowel preceded by any of ['"`^] to obtain the 'accented' version:
    ' before [AEIOUaeiou'NnCc?!] produces [ÁÉÍÓÚáéíóú'ÑñÇç¿¡]
    " before [AEIOUaeiou"]       produces [ÄËÏÖÜäëïöü"]
    ` before [AEIOUaeiou`]       produces [ÀÈÌÒÙàèìòù`]
    ^ before [AEIOUaeiou^]       produces [ÂÊÎÔÛâêîôû^]
    
    The leader character can be produced by typing it twice: '' => ', "" => " et al.
    This is only needed if the leader character is followed by a vowel, n, c, ? or !.
    
    Note that for my personal ease of typing, ñ and Ñ can also pr produced by 'n and 'N.
    
    The available combinations can easily be extended if you need other accented characters.
    
    */
    
    ; ' followed by character
    :C*?:'!::{U+00A1} ; ! followed by ' => ¡
    :C*?:''::{U+0027} ; ' followed by ' => '
    :C*?:'?::{U+00BF} ; ? followed by ' => ¿
    :C*?:'A::{U+00C1} ; ' followed by A => Á
    :C*?:'C::{U+00C7} ; ' followed by C => Ç
    :C*?:'E::{U+00C9} ; ' followed by E => É
    :C*?:'I::{U+00CD} ; ' followed by I => Í
    :C*?:'N::{U+00D1} ; ' followed by N => N
    :C*?:'O::{U+00D3} ; ' followed by O => Ó
    :C*?:'U::{U+00DA} ; ' followed by U => Ú
    :C*?:'a::{U+00E1} ; ' followed by a => á
    :C*?:'c::{U+00E7} ; ' followed by c => ç
    :C*?:'e::{U+00E9} ; ' followed by e => é
    :C*?:'i::{U+00ED} ; ' followed by i => í
    :C*?:'n::{U+00F1} ; ' followed by n => ñ
    :C*?:'o::{U+00F3} ; ' followed by o => ó
    :C*?:'u::{U+00FA} ; ' followed by u => ú
    
    ; " followed by character
    :C*?:""::{U+0022} ; " followed by : => :
    :C*?:"A::{U+00C4} ; " followed by A => Ä
    :C*?:"E::{U+00CB} ; " followed by E => Ë
    :C*?:"I::{U+00CF} ; " followed by I => Ï
    :C*?:"O::{U+00D6} ; " followed by O => Ö
    :C*?:"U::{U+00DC} ; " followed by U => Ü
    :C*?:"a::{U+00E4} ; " followed by a => ä
    :C*?:"e::{U+00EB} ; " followed by é => ë
    :C*?:"i::{U+00EF} ; " followed by i => ï
    :C*?:"o::{U+00F6} ; " followed by o => ö
    :C*?:"u::{U+00FC} ; " followed by u => ü
    
    ; ` followed by character
    :C*?:````::{U+0060} ; ` followed by ` => `
    :C*?:``A::{U+00C0} ; ` followed by A => À
    :C*?:``E::{U+00C8} ; ` followed by E => È
    :C*?:``I::{U+00CC} ; ` followed by I => Ì
    :C*?:``O::{U+00D2} ; ` followed by O => Ò
    :C*?:``U::{U+00D9} ; ` followed by U => Ù
    :C*?:``a::{U+00E0} ; ` followed by a => à
    :C*?:``e::{U+00E8} ; ` followed by e => è
    :C*?:``i::{U+00EC} ; ` followed by i => ì
    :C*?:``o::{U+00F2} ; ` followed by o => ò
    :C*?:``u::{U+00F9} ; ` followed by u => ù
    
    ; ^ followed by character
    :C*?:^^::{U+005E} ; ^ followed by ^ => ^
    :C*?:^A::{U+00C2} ; ^ followed by A => Â
    :C*?:^E::{U+00CA} ; ^ followed by E => Ê
    :C*?:^I::{U+00CE} ; ^ followed by I => Î
    :C*?:^O::{U+00D4} ; ^ followed by O => Ô
    :C*?:^U::{U+00DB} ; ^ followed by U => Û
    :C*?:^a::{U+00E2} ; ^ followed by a => â
    :C*?:^e::{U+00EA} ; ^ followed by e => ê
    :C*?:^i::{U+00EE} ; ^ followed by i => î
    :C*?:^o::{U+00F4} ; ^ followed by o => ô
    :C*?:^u::{U+00FB} ; ^ followed by u => û
    
    ; ~ followed by character
    :C*?:~~::{U+007E} ; ~ followed by ~ => ~
    :C*?:~N::{U+00D1} ; ~ followed by N => N
    :C*?:~n::{U+00F1} ; ~ followed by n => ñ
    
    ;; Thanks for comments and or corrections to Guido Van Hoecke <[email protected]>
Last edited by guivho on 02 Apr 2023, 04:26, edited 1 time in total.
brnyza
Posts: 1
Joined: 30 Dec 2018, 17:42

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

30 Aug 2022, 06:18

Save your script in UTF-8 with BOM encoding
User avatar
guivho
Posts: 15
Joined: 09 Mar 2017, 08:59
Contact:

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

30 Aug 2022, 06:26

brnyza wrote:
30 Aug 2022, 06:18
Save your script in UTF-8 with BOM encoding
Please clarify
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

30 Aug 2022, 06:36

guivho wrote:
30 Aug 2022, 06:26
brnyza wrote:
30 Aug 2022, 06:18
Save your script in UTF-8 with BOM encoding
Please clarify
The easiest way, check your editor for an "Encoding"-option like "UTF-8 with BOM". Select it for your script. Save it that way. Done. HTH

PS. if you prefer the command line (or a ComObjCreate())-option this might come in handy: https://docs.microsoft.com/en-us/answers/questions/405610/powershell-change-save-encoding-how-to-convert-sev.html
basrongen
Posts: 1
Joined: 18 Jan 2024, 10:14

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

18 Jan 2024, 10:32

I enjoyed it so much, then had to migrate to V2 with my main script that has this included there. I had a tough time getting it to work again, so thought I'd create an account and let everyone else enjoy using it in V2.

Code: Select all

;; Generate accented vowels by prefixing them with Ctrl-', Ctrl-\, Ctrl-" or Ctrl-^
;; I chose Ctrl-\ for accent grave prefix, but feel free to change to your liking
;; This can easily be expanded for accented consonants if needed. In fact I use the
;; Ctrl-' followed by c, C, n, N, ? or ! to generate ç, Ç, ñ, Ñ, ¿ or ¡.

;; This is inspired a.o by https://www.autohotkey.com/boards/viewtopic.php?f=76&t=72327
;; My other implementation at https://www.autohotkey.com/boards/viewtopic.php?f=6&t=82484
;; is better for touch typing, but the single and double quote behaviour is difficult
;; when programming.

;; The problem to overcome was the fact that we really want a kind of hotstring, such as
;; Ctrl-' and a, but caracters with modifiers can not be part of a hotstring sequence.
;; So this is circumvented by remembering in a global value wich prefix was typed.
;; If this is followed by one of the supported characters, the trigger value is reset
;; after sending the required accented character.

;; Once the trigger state is set to a non zero value, it preserves that state until one
;; of [aAeEuUiIoOcCnN?!] is typed.
;; The trigger remains active until of the supported characters is typed, even after
;; one or more not supported characters were typed in between: Ctrl-' go produces gó.
;; Ideally this should not happen, but I didn't yet find a solution for it.

;; Corrections and/or suggestions to [email protected] are more than welcome.

;; The Trigger variable controls generation of accented characters and ç, Ç, ñ, Ñ, ¿, ¡
global Trigger := 0 ; define the control variable and set it to inactive state

triggerEqualsOne() {
    global
    if (Trigger = 1) {
        return true
    } else {
        return false
    }
}
triggerEqualsTwo() {
    global
    if (Trigger = 2) {
        return true
    } else {
        return false
    }
}
triggerEqualsThree() {
    global
    if (Trigger = 3) {
        return true
    } else {
        return false
    }
}
triggerEqualsFour() {
    global
    if (Trigger = 4) {
        return true
    } else {
        return false
    }
}

;; Set the Hotkeys to set the trigger to each of the four triggers
^'::global Trigger := 1 ;;prefix for á, Á, é, É, í, Í, ó, Ó, ú, Ú, ç, Ç, ñ, Ñ, ¿, ¡
^`::global Trigger := 2 ;;prefix for à, À, è, È, ì, Í, ò, Ò, ù, Ù
^"::global Trigger := 3 ;;prefix for ä, Ä, ë, Ë, ï, Ï, ö, Ö, ü, Ü
^^::global Trigger := 4 ;;prefix for â, Â, ê, Ê, î, Î, ô, Ô, û, Û

#HotIf triggerEqualsOne() ;;prefix was for á, Á, é, É, í, Í, ó, Ó, ú, Ú, ç, Ç
{
    a:: {
        SendInput "{U+00E1}" ; á
        global Trigger := 0
        return
    }
    :C*?:A:: {
        SendInput "{U+00C1}" ; Á
        global Trigger := 0
        return
    }
    :C*?:e:: {
        SendInput "{U+00E9}" ; é
        global Trigger := 0
        return
    }
    :C*?:E:: {
        SendInput "{U+00C9}" ; É
        global Trigger := 0
        return
    }
    :C*?:i:: {
        SendInput "{U+00ED}" ; í
        global Trigger := 0
        return
    }
    :C*?:I:: {
        SendInput "{U+00CD}" ; Í
        global Trigger := 0
        return
    }
    :C*?:o:: {
        SendInput "{U+00F3}" ; ó
        global Trigger := 0
        return
    }
    :C*?:O:: {
        SendInput "{U+00D3}" ; Ó
        global Trigger := 0
        return
    }
    :C*?:u:: {
        SendInput "{U+00FA}" ; ú
        global Trigger := 0
        return
    }
    :C*?:U:: {
        SendInput "{U+00DA}" ; Ú
        global Trigger := 0
        return
    }
    :C*?:c:: {
        SendInput "{U+00E7}" ; ç
        global Trigger := 0
        return
    }
    :C*?:C:: {
        SendInput "{U+00C7}" ; Ç
        global Trigger := 0
        return
    }
    :*?:!:: {
        SendInput "{U+00A1}" ; ¡
        global Trigger := 0
        return
    }
    :*?:?:: {
        SendInput "{U+00BF}" ; ¿
        global Trigger := 0
        return
    }
}
#HotIf triggerEqualsTwo() ;;prefix was for à, À, è, È, ì, Í, ò, Ò, ù, Ù, ñ, Ñ
{
    ToolTip("Trigger 2 pressed")
    :C*?:a:: {
        SendInput "{U+00E0}" ; à
        global Trigger := 0
        return
    }
    :C*?:A:: {
        SendInput "{U+00C0}" ; À
        global Trigger := 0
        return
    }
    :C*?:e:: {
        SendInput "{U+00E8}" ; é
        global Trigger := 0
        return
    }
    :C*?:E:: {
        SendInput "{U+00C8}" ; È
        global Trigger := 0
        return
    }
    :C*?:i:: {
        SendInput "{U+00EC}" ; ì
        global Trigger := 0
        return
    }
    :C*?:I:: {
        SendInput "{U+00CC}" ; Ì
        global Trigger := 0
        return
    }
    :C*?:o:: {
        SendInput "{U+00F2}" ; ò
        global Trigger := 0
        return
    }
    :C*?:O:: {
        SendInput "{U+00D2}" ; Ò
        global Trigger := 0
        return
    }
    :C*?:u:: {
        SendInput "{U+00F9}" ; ù
        global Trigger := 0
        return
    }
    :C*?:U:: {
        SendInput "{U+00D9}" ; Ù
        global Trigger := 0
        return
    }
    :C*?:n:: {
        SendInput "{U+00F1}" ; ñ
        global Trigger := 0
        return
    }
    :C*?:N:: {
        SendInput "{U+00D1}" ; Ñ
        global Trigger := 0
        return
    }
}
#HotIf triggerEqualsThree() ;;prefix was for à, À, è, È, ì, Í, ò, Ò, ù, Ù
{
    :C*?:a:: {
        SendInput "{U+00E4}" ; ä
        global Trigger := 0
        return
    }
    :C*?:A:: {
        SendInput "{U+00C4}" ; Ä
        global Trigger := 0
        return
    }
    :C*?:e:: {
        SendInput "{U+00EB}" ; ë
        global Trigger := 0
        return
    }
    :C*?:E:: {
        SendInput "{U+00CB}" ; Ë
        global Trigger := 0
        return
    }
    :C*?:i:: {
        SendInput "{U+00EF}" ; ï
        global Trigger := 0
        return
    }
    :C*?:I:: {
        SendInput "{U+00CF}" ; Ï
        global Trigger := 0
        return
    }
    :C*?:o:: {
        SendInput "{U+00F6}" ; ö
        global Trigger := 0
        return
    }
    :C*?:O:: {
        SendInput "{U+00D6}" ; Ö
        global Trigger := 0
        return
    }
    :C*?:u:: {
        SendInput "{U+00FC}" ; ü
        global Trigger := 0
        return
    }
    :C*?:U:: {
        SendInput "{U+00DC}" ; Ü
        global Trigger := 0
        return
    }
}
#HotIf triggerEqualsFour() ;;prefix was for â, Â, ê, Ê, î, Î, ô, Ô, û, Û
{
    :C*?:a:: {
        SendInput "{U+00E2}" ; â
        global Trigger := 0
        return
    }
    :C*?:A:: {
        SendInput "{U+00C2}" ; Â
        global Trigger := 0
        return
    }
    :C*?:e:: {
        SendInput "{U+00EA}" ; ê
        global Trigger := 0
        return
    }
    :C*?:E:: {
        SendInput "{U+00CA}" ; Ê
        global Trigger := 0
        return
    }
    :C*?:i:: {
        SendInput "{U+00EE}" ; î
        global Trigger := 0
        return
    }
    :C*?:I:: {
        SendInput "{U+00CE}" ; Î
        global Trigger := 0
        return
    }
    :C*?:o:: {
        SendInput "{U+00F4}" ; ô
        global Trigger := 0
        return
    }
    :C*?:O:: {
        SendInput "{U+00D4}" ; Ô
        global Trigger := 0
        return
    }
    :C*?:u:: {
        SendInput "{U+00FB}" ; û
        global Trigger := 0
        return
    }
    :C*?:U:: {
        SendInput "{U+00DB}" ; Û
        global Trigger := 0
        return
    }
}
#HotIf
User avatar
guivho
Posts: 15
Joined: 09 Mar 2017, 08:59
Contact:

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

18 Jan 2024, 13:52

Good to share it! The day I switch to V2 I'll certainly use it!
loopernow
Posts: 27
Joined: 17 Mar 2019, 14:18

Re: Easy accents including french ç as well as spanish ñ and ¿ and ¡

19 Jan 2024, 21:33

I love the latest version of your script. It is very similar to the way an actual Spanish (or what-have-you) keyboard layout works, but without having to switch to an actual Spanish keyboard layout. :P

One change I made is, two ' just sends two '.

Code: Select all

;   :C*?:''::{U+0027} ; ' followed by ' => '     ; original
    :C*?:''::''       ; ' followed by ' => ''    ; my tweak
Maybe more handy for some people in some cases. :)

Cheers, and thanks for a great script.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: gwarble and 105 guests