Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Fast replacing keyboard


  • Please log in to reply
5 replies to this topic
Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
The latest AHK release (1.0.37.04) allows the use of the printed-on key names in hotkeys. This greatly simplifies the fastest keyboard modifier script for typing special ANSI characters. The script below activates a function at pressing the same designated keys twice in rapid succession, to send another character to the foreground application (or do whatever you want). You have to learn paying attention, though. If "ss" often occurs in your language, replacing quickly typed ones could be annoying. Seldom doubled keys are safer, like "," or "\". Keep from the large set of replacement rules below, what you really need, or add more diacritical letters!
$$::Strike2("€")

$'::Strike2("’")

$`::Strike2("´")

$%::Strike2("§")

$"::Strike2("”")

$*::Strike2("•")

$x::Strike2("×")

$+::Strike2("±")

$-::Strike2("–")

$.::Strike2("…")

$,::Strike2("„")

$/::Strike2("÷")

$|::Strike2("¦")

$0::Strike2("º")

$1::Strike2("¹")

$2::Strike2("²")

$3::Strike2("³")

$4::Strike2("¼")

$5::Strike2("½")

$6::Strike2("¾")

$<::Strike2("«")

$>::Strike2("»")



$+A::Strike2("Á")

$+Q::Strike2("Ä")

$+E::Strike2("É")

$+I::Strike2("Í")

$+L::Strike2("£")



$+O::Strike2("Ó") 

$+P::Strike2("Ö") 

$+{::Strike2("Õ") 

$+U::Strike2("Ú") 

$+Y::Strike2("Ü") 

$+T::Strike2("Û") 



$a::Strike2("á")

$q::Strike2("ä")

$e::Strike2("é")

$f::Strike2("ƒ")

$i::Strike2("í")

$m::Strike2("µ")

$s::Strike2("ß")



$o::Strike2("ó")

$p::Strike2("ö")

$[::Strike2("õ")

$u::Strike2("ú")

$y::Strike2("ü")

$t::Strike2("û")



Strike2(ch)         ; If hotkey was activated twice within 200 ms

{                   ; Send ch, else send activating hotkey

   If (!keywas and A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200)

   {

      Send {BS}%ch% ; erase char, Send replacement

      keywas = 1    ; key got replaced, next press is normal

   }

   Else

   {

      StringRight key, A_ThisHotkey, 1

      SendRaw %key% ; Send activating key

      keywas = 0    ; normal key press, next can be replaced

   }

}
The very first line replaces $$ with € (the Euro symbol), but it does not show up right in the code listing.

BeRto
  • Guests
  • Last active:
  • Joined: --
Hi,
This script is very handy. As I type in spanish, french on the same english keybord.

Problem is, when I type CAPSLOCK, HeRe is WHat HappeNs :)

it seems aLL Keys iNCLuDeD iN tHe sCRipt aRe tuRNeD to LoWeR Case.

HeRe is tHe CoNteNt of my fReNCH KeyBoaRD: "aZeRtyuiopqsDfGHJKLmWxCVBN"

Any solution?

Thanks for a great tool anyway

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Try replacing the Strike2() function definition with this:
Strike2(ch) {       ; If hotkey activated twice within 200 ms Send ch, else send activating hotkey
   Static keywas
   If (!keywas && A_ThisHotkey = A_PriorHotkey && A_TimeSincePriorHotkey < 200) {
      If GetKeyState("CapsLock", "T")
         IF GetKeyState("Shift", "P")
            StringLower Ch, Ch
         Else
            StringUpper Ch, Ch
      Send {BS}%ch% ; erase char, Send replacement
      keywas = 1    ; key got replaced, next press is normal
   }
   Else {
      StringRight key, A_ThisHotkey, 1
      If GetKeyState("CapsLock", "T")
         IF GetKeyState("Shift", "P")
            StringLower key, key
         Else
            StringUpper key, key
      SendRaw %key% ; Send activating key
      keywas = 0    ; normal key press, next can be replaced
   }
}


tipo_FR_ES
  • Guests
  • Last active:
  • Joined: --
Thanks a lot for this script :D
It is rather simple but helps me a lot. I adopt it right now.
I especially use the French / Spanish keyboards and find it very handy.

tipo_FR_ES
  • Guests
  • Last active:
  • Joined: --
By the way, do you see how to correct this:
With this script, when à type C R O ^ U T E, I get croû^te instead of croûte, as I should normally get wihtout the script.
Any idea?
Thx

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
You have two conflicting keyboard managers. If you disable the deadkeys, key combinations in your keyboard layout, but use AHK hotstrings instead, you would have a more flexible keyboard driver, without conflicts.