Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Accent Hotkey Script


  • Please log in to reply
7 replies to this topic
Ethan
  • Guests
  • Last active:
  • Joined: --
I'm not sure if a script like this has already been posted. I just noticed the umlaut script, but that is not really quite the same thing. Anyway, this is a relatively simple script that adds Word-style hotkeys for accents and a few other things using the windows key and keys that look vaguely like accent marks for the shortcuts (I find the windows key rarely is used for other hotkeys, so there's no problem with disabling something I want in some program). What I mean by word-style hotkeys are ones where you hit a hotkey for an accent type, such as acute, then the next key, be it e, a, i or whatever that takes an acute accent will have one. This script accomplishes this by having hotkeys for a, e, i, o, u, c and n, which are disabled most of the time. Hitting any of the accent hotkeys enables them and and sets a variable to the desired type of accent.
I hope this is helpful to people. I also have a few other common character hotkeys with the Win key in the beginning, feel free to take just use whatever bits of the code you want, and/or add characters and accents.

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT or later
; Author:         Ethan
;


#+-::Send,—
#-::Send,–

#+[::Send,“
#+]::Send,”

#[::Send,‘
#]::Send,’

#o::Send,°
#c::Send,©
#t::Send,™
#.::Send,…

a::
if accent=acute
	Send,á
else if accent=grave
	Send,à
else if accent=circumflex
	Send,â
else if accent=umlaut
	Send,ä
else if accent=tilda
 	Send,ã
Gosub,TurnAccentsOff
Return

e::
if accent=acute
	Send,é
else if accent=grave
	Send,è
else if accent=circumflex
	Send,ê
else if accent=umlaut
	Send,ë
Gosub,TurnAccentsOff
Return

i::
if accent=acute
	Send,í
else if accent=grave
	Send,ì
else if accent=circumflex
	Send,î
else if accent=umlaut
	Send,ï
Gosub,TurnAccentsOff
Return

o::
if accent=acute
	Send,ó
else if accent=grave
	Send,ò
else if accent=circumflex
	Send,ô
else if accent=umlaut
	Send,ö
else if accent=tilda
 	Send,õ
Gosub,TurnAccentsOff
Return

u::
if accent=acute
	Send,ú
else if accent=grave
	Send,ù
else if accent=circumflex
	Send,û
else if accent=umlaut
	Send,ü
Gosub,TurnAccentsOff
Return

c::
if accent=cedilla
 	Send,ç
Gosub,TurnAccentsOff
Return

n::
if accent=tilda
 	Send,ñ
Gosub,TurnAccentsOff
Return

+a::
if accent=acute
	Send,Á
else if accent=grave
	Send,À
else if accent=circumflex
	Send,Â
else if accent=umlaut
	Send,Ä
else if accent=tilda
 	Send,Ã
Gosub,TurnAccentsOff
Return

+e::
if accent=acute
	Send,É
else if accent=grave
	Send,È
else if accent=circumflex
	Send,Ê
else if accent=umlaut
	Send,Ë
Gosub,TurnAccentsOff
Return

+i::
if accent=acute
	Send,Í
else if accent=grave
	Send,Ì
else if accent=circumflex
	Send,Î
else if accent=umlaut
	Send,Ï
Gosub,TurnAccentsOff
Return

+o::
if accent=acute
	Send,Ó
else if accent=grave
	Send,Ò
else if accent=circumflex
	Send,Ô
else if accent=umlaut
	Send,Ö
else if accent=tilda
 	Send,Õ
Gosub,TurnAccentsOff
Return

+u::
if accent=acute
	Send,ú
else if accent=grave
	Send,ù
else if accent=circumflex
	Send,û
else if accent=umlaut
	Send,ü
Gosub,TurnAccentsOff
Return

+c::
if accent=cedilla
 	Send,Ç
Gosub,TurnAccentsOff
Return

+n::
if accent=tilda
 	Send,Ñ
Gosub,TurnAccentsOff
Return

TurnAccentsOff:
Hotkey,a,off
Hotkey,e,off
Hotkey,i,off
Hotkey,o,off
Hotkey,u,off
Hotkey,c,off
Hotkey,n,off
Hotkey,+a,off
Hotkey,+e,off
Hotkey,+i,off
Hotkey,+o,off
Hotkey,+u,off
Hotkey,+c,off
Hotkey,+n,off
Return

TurnAccentsOn:
Hotkey,a,on
Hotkey,e,on
Hotkey,i,on
Hotkey,o,on
Hotkey,u,on
Hotkey,c,on
Hotkey,n,on
Hotkey,+a,on
Hotkey,+e,on
Hotkey,+i,on
Hotkey,+o,on
Hotkey,+u,on
Hotkey,+c,on
Hotkey,+n,on
Return

#'::
accent=acute
Gosub,TurnAccentsOn
Return

#`::
accent=grave
Gosub,TurnAccentsOn
Return

#6::
#+6::
accent=circumflex
Gosub,TurnAccentsOn
Return

#;::
#+;::
accent=umlaut
Gosub,TurnAccentsOn
Return

#,::
accent=cedilla
Gosub,TurnAccentsOn
Return

#+`::
accent=tilda
Gosub,TurnAccentsOn
Return

Gosub,TurnAccentsOff


jak
  • Members
  • 159 posts
  • Last active: Dec 16 2010 11:26 PM
  • Joined: 28 Feb 2006
wow, thanks for this, works perfectly for me.

I improved this a bit according to the information found here on this thread:

http://www.autohotke...ansform unicode

So that now this works in notepad and powerpoint and so forth as well.

[code=auto:0]
#SingleInstance Force
#NoEnv
SendMode Input
;--------------------aa a
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT or later
; Author: Ethan (tweaked by jak to work in notepad and powerpoint)
;


#+-::
;Send,—
{
Transform, Clipboard, Unicode, —
send ^v
}

#-::
;Send,–
{
Transform, Clipboard, Unicode, –
send ^v
}

#+[::
;Send,“
{
Transform, Clipboard, Unicode, “
send ^v
}

#+]::
;Send,”
{
Transform, Clipboard, Unicode, â€

ArchCarrier
  • Members
  • 39 posts
  • Last active: Apr 07 2014 05:43 PM
  • Joined: 03 Jun 2008
Looks like it could be very useful, but I get the following error message after pressing one of the Win+accent combinations:

Posted Image

jak
  • Members
  • 159 posts
  • Last active: Dec 16 2010 11:26 PM
  • Joined: 28 Feb 2006

Looks like it could be very useful, but I get the following error message after pressing one of the Win+accent combinations:


it looks like you miscopied 3 lines? (lines 171 and 172, one of which is a 'turn accents on:' label)?

it works well for me

jak
  • Members
  • 159 posts
  • Last active: Dec 16 2010 11:26 PM
  • Joined: 28 Feb 2006
Here's another version, posting it here since it might save someone time.

This version uses a different method from the above, and one that does not erase the clipboard (does not use the control-v to paste the character). It may also be slightly faster.

I typed this out with help and info from this thread:
http://www.autohotke...der=asc&start=0
and looked up the latin-1 supplemental unicodes for the various french accents.
http://en.wikipedia....t_unicode_block

I like this version because even though its long, its simple and I can more or less understand it and tweak it now and then. There are various other versions of "universal accents" scripts on these forums, though.

;====================================
;accents "top part" - this top part needs to be located at the top part (the 'run' part) of the ahk file
;====================================
;
;============ ----- Send Unicode Character - universal MS word-style accents in any application
;
SendInput:=DllCall("GetProcAddress",UInt,DllCall("GetModuleHandle",Str,"user32"),Str,"SendInput")
VarSetCapacity(SendUbuf, 56, 0) ; INIT SendU data strucure
NumPut(1, SendUbuf, 0, "Char")
NumPut(1, SendUbuf,28, "Char")
NumPut(0x40000, SendUbuf, 6)
NumPut(0x60000, SendUbuf,34)
;-----------------
;

;====================================
;accents "hotkey part" -  (this part can be located anywhere)
;====================================
;



SendU(UC) {                     ; Send Unicode Char, Pressed modifier keys stay active!
   Global                       ; SendUbuf, SendInput
   NumPut(UC, SendUbuf, 6, "Short")
   NumPut(UC, SendUbuf,34, "Short")
   Return DllCall(SendInput, UInt,2, UInt,&SendUbuf, Int,28)
}


a::
if accent=grave
;   sendinput,à
{
SendU(0x00e0)
}
else if accent=acute
{
;   Send,á
SendU(0x00e1)
}

else if accent=circumflex
;   sendinput,â
{
SendU(0x00e2)
}
else if accent=tilda
;    sendinput,ã
{
SendU(0x00e3)
}
else if accent=umlaut
;   sendinput,ä
{
SendU(0x00e4)
}
Gosub,TurnAccentsOff
Return


c::
if accent=cedilla
;    sendinput,ç
{
SendU(0x00e7)
}
Gosub,TurnAccentsOff
Return

e::
if accent=grave
;   sendinput,è
{
SendU(0x00e8)
}
else if accent=acute
;   sendinput,é
{
SendU(0x00e9)
}
else if accent=circumflex
;   sendinput,ê
{
SendU(0x00ea)
}
else if accent=umlaut
;   sendinput,ë
{
SendU(0x00eb)
}
Gosub,TurnAccentsOff
Return


i::
if accent=grave
;   sendinput,ì
{
SendU(0x00ec)
}
else if accent=acute
;   sendinput,í
{
SendU(0x00ed)
}
else if accent=circumflex
;   sendinput,î
{
SendU(0x00ee)
}
else if accent=umlaut
;  sendinput,ï
{
SendU(0x00ef)
}
Gosub,TurnAccentsOff
Return


n::
if accent=tilda
;    sendinput,ñ
{
SendU(0x00f1)
}
Gosub,TurnAccentsOff
Return

o::
if accent=grave
;   sendinput,ò
{
SendU(0x00f2)
}
else if accent=acute
;   sendinput,ó
{
SendU(0x00f3)
}
else if accent=circumflex
;   sendinput,ô
{
SendU(0x00f4)
}
else if accent=tilda
;    sendinput,õ
{
SendU(0x00f5)
}
else if accent=umlaut
;   sendinput,ö
{
SendU(0x00f6)
}
Gosub,TurnAccentsOff
Return


u::
if accent=grave
;   sendinput,ù
{
SendU(0x00f9)
}
else if accent=acute
;   sendinput,ú
{
SendU(0x00fa)
}
else if accent=circumflex
;   sendinput,û
{
SendU(0x00fb)
}
else if accent=umlaut
;   sendinput,ü
{
SendU(0x00fc)
}
Gosub,TurnAccentsOff
Return


+a::
if accent=grave
;   sendinput,À
{
SendU(0x00c0)
}
else if accent=acute
;   sendinput,Á
{
SendU(0x00c1)
}
else if accent=circumflex
;   sendinput,Â
{
SendU(0x00c2)
}
else if accent=tilda
;    sendinput,Ã
{
SendU(0x00c3)
}
else if accent=umlaut
;   sendinput,Ä
{
SendU(0x00c4)
}
Gosub,TurnAccentsOff
Return



+c::
if accent=cedilla
;    sendinput,Ç
{
SendU(0x00c7)
}
Gosub,TurnAccentsOff
Return


+e::
if accent=grave
;   sendinput,È
{
SendU(0x00c8)
}
else if accent=acute
;   sendinput,É
{
SendU(0x00c9)
}
else if accent=circumflex
;   sendinput,Ê
{
SendU(0x00ca)
}
else if accent=umlaut
;  sendinput,Ë
{
SendU(0x00cb)
}
Gosub,TurnAccentsOff
Return


+i::
if accent=acute
;   sendinput,Í
{
SendU(0x00cc)
}
else if accent=grave
;   sendinput,Ì
{
SendU(0x00cd)
}
else if accent=circumflex
;   sendinput,Î
{
SendU(0x00ce)
}
else if accent=umlaut
;   sendinput,Ï
{
SendU(0x00cf)
}
Gosub,TurnAccentsOff
Return


+n::
if accent=tilda
;    sendinput,Ñ
{
SendU(0x00d1)
}
Gosub,TurnAccentsOff
Return


+o::
if accent=grave
;   sendinput,Ò
{
SendU(0x00d2)
}
else if accent=acute
;   sendinput,Ó
{
SendU(0x00d3)
}
else if accent=circumflex
;   sendinput,Ô
{
SendU(0x00d4)
}
else if accent=tilda
;    sendinput,Õ
{
SendU(0x00d5)
}
else if accent=umlaut
;   sendinput,Ö
{
SendU(0x00d6)
}
Gosub,TurnAccentsOff
Return



+u::
if accent=grave
;   sendinput,ù
{
SendU(0x00d9)
}
else if accent=acute
;   sendinput,ú
{
SendU(0x00da)
}
else if accent=circumflex
;   sendinput,û
{
SendU(0x00db)
}
else if accent=umlaut
;   sendinput,ü
{
SendU(0x00dc)
}
Gosub,TurnAccentsOff
Return


TurnAccentsOff:
Hotkey,a,off
Hotkey,e,off
Hotkey,i,off
Hotkey,o,off
Hotkey,u,off
Hotkey,c,off
Hotkey,n,off
Hotkey,+a,off
Hotkey,+e,off
Hotkey,+i,off
Hotkey,+o,off
Hotkey,+u,off
Hotkey,+c,off
Hotkey,+n,off
Return

TurnAccentsOn:
Hotkey,a,on
Hotkey,e,on
Hotkey,i,on
Hotkey,o,on
Hotkey,u,on
Hotkey,c,on
Hotkey,n,on
Hotkey,+a,on
Hotkey,+e,on
Hotkey,+i,on
Hotkey,+o,on
Hotkey,+u,on
Hotkey,+c,on
Hotkey,+n,on
Return



<#'::
keywait, lwin
accent=acute
Gosub,TurnAccentsOn
Return



<#`::
keywait, lwin
accent=grave
Gosub,TurnAccentsOn
Return



<#6::
<#+6::
keywait, lwin
accent=circumflex
Gosub,TurnAccentsOn
Return



<#;::
<#+;::
keywait, lwin
accent=umlaut
Gosub,TurnAccentsOn
Return



<#,::
keywait, lwin
accent=cedilla
Gosub,TurnAccentsOn
Return



<#+`::
keywait, lwin
accent=tilda
Gosub,TurnAccentsOn
Return



Gosub,TurnAccentsOff


Nibbler
  • Guests
  • Last active:
  • Joined: --
Hello, this was a fantastic little script.

Unfortunately, now that AHK has upgraded to a unicode version Autohotkey_L and this script now doesn't work. I'm a bit rubbish at scripting and though I have tried to re-edit the script to work with the AHK_L but can't. :(

Has anyone found a way round this?

Of course I could go back to the old version, but AHK_L is very useful to me for other reasons so don't really want to.

nimda
  • Members
  • 4368 posts
  • Last active: Jan 15 2014 02:47 PM
  • Joined: 26 Dec 2010
Save the script as UTF-8 and remove the tranform parts

maestrith
  • Members
  • 614 posts
  • Last active: Today, 04:54 AM
  • Joined: 17 Sep 2005
I was messing around and came up with this. Hope it works for everyone.
KEYS=aeiounc

Coordmode,ToolTip,Screen

a:=["E0","E1","E2","E3","E4","61"]

CaPA:=["C0","C1","C2","C3","C4","41"]

E:=["E8","E9","EA","65","EB","65"]

CaPE:=["C8","C9","CA","45","CB","45"]

i:=["EC","ED","EE","69","EF","69"]

CAPI:=["CC","CD","CE","49","CF","49"]

o:=["F2","F3","F4","F5","F6","6F"]

CAPO:=["D2","D3","D4","D5","D6","4F"]

u:=["F9","FA","FB","75","FC","75"]

CAPu:=["D9","DA","DB","55","DC","55"]

n:=["6E","6E","6E","F1","6E","6E"]

capn:=["4E","4E","4E","D1","4E","4E"]

c:=["63","63","63","63","63","E7"]

capc:=["43","43","43","43","43","C7"]

RETURN

ACCENT:

key:=IF GETKEYSTATE("CAPSLOCK","T") ? "+" a_thishotkey : a_thishotkey

KEY:=IF INSTR(KEY,"+") ? "CaP" REGEXREPLACE(KEY,"\+") : KEY

gosub,off

send % CHR("0X" %KEY%[CURRENT])

tooltip,

return

f1::

reload

return

on:

loop,parse,keys

{

 HOTKEY,%a_loopfield%,ACCENT,ON

 hotkey,+%a_loopfield%,ACCENT,ON

}

return

off:

loop,parse,keys

{

 HOTKEY,%a_loopfield%,ACCENT,off

 hotkey,+%a_loopfield%,ACCENT,off

}

return

#'::

accent("acute")

#`::

accent("grave")

#6::

accent("circumflex")

#;::

accent("umlaut")

#,::

accent("cedilla")

#+`::

accent("tilda")

accent(accent){

 global

 TYPE:=["GRAVE","ACCUTE","CIRCUMFLEX","TILDA","UMLAUT","CEDILLA"]

 FOR index,t IN TYPE

 IF t=%accent%

 CURRENTtype:=t,current:=a_index

 tooltip,%currenttype%,0,0

 gosub,on

 exit

}