AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Accent Hotkey Script

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Ethan
Guest





PostPosted: Tue Aug 03, 2004 8:25 am    Post subject: Accent Hotkey Script Reply with quote

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.

Code:

;
; 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
Back to top
jak



Joined: 28 Feb 2006
Posts: 137

PostPosted: Tue Sep 02, 2008 9:15 am    Post subject: Reply with quote

wow, thanks for this, works perfectly for me.

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

http://www.autohotkey.com/forum/viewtopic.phpt=2506&highlight=transform+unicode

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

Code:

#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, ”
send ^v
}

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

#]::
;Send,
{
Transform, Clipboard, Unicode, ’
send ^v
}

#o::
;Send,
{
Transform, Clipboard, Unicode, °
send ^v
}

#c::
;Send,
{
Transform, Clipboard, Unicode, ©
send ^v
}

#t::
;Send,
{
Transform, Clipboard, Unicode, ™
send ^v
}

#.::
;Send,
{
Transform, Clipboard, Unicode, …
send ^v
}


a::
if accent=acute
{
Transform, Clipboard, Unicode, á
send, ^v
}
;   Send,
else if accent=grave
;   Send,
{
Transform, Clipboard, Unicode, à
send ^v
}
else if accent=circumflex
;   Send,
{
Transform, Clipboard, Unicode, â
send ^v
}
else if accent=umlaut
;   Send,
{
Transform, Clipboard, Unicode, ä
send ^v
}
else if accent=tilda
;    Send,
{
Transform, Clipboard, Unicode, ã
send ^v
}
Gosub,TurnAccentsOff
Return


e::
if accent=acute
;   Send,
{
Transform, Clipboard, Unicode, é
send ^v
}
else if accent=grave
;   Send,
{
Transform, Clipboard, Unicode, è
send ^v
}
else if accent=circumflex
;   Send,
{
Transform, Clipboard, Unicode, ê
send ^v
}
else if accent=umlaut
;   Send,
{
Transform, Clipboard, Unicode, ë
send ^v
}
Gosub,TurnAccentsOff
Return


i::
if accent=acute
;   Send,
{
Transform, Clipboard, Unicode, í
send ^v
}
else if accent=grave
;   Send,
{
Transform, Clipboard, Unicode, ì
send ^v
}
else if accent=circumflex
;   Send,
{
Transform, Clipboard, Unicode, î
send ^v
}
else if accent=umlaut
;  Send,
{
Transform, Clipboard, Unicode, ï
send ^v
}
Gosub,TurnAccentsOff
Return


o::
if accent=acute
;   Send,
{
Transform, Clipboard, Unicode, ó
send ^v
}
else if accent=grave
;   Send,
{
Transform, Clipboard, Unicode, ò
send ^v
}
else if accent=circumflex
;   Send,
{
Transform, Clipboard, Unicode, ô
send ^v
}
else if accent=umlaut
;   Send,
{
Transform, Clipboard, Unicode, ö
send ^v
}
else if accent=tilda
;    Send,
{
Transform, Clipboard, Unicode, õ
send ^v
}
Gosub,TurnAccentsOff
Return


u::
if accent=acute
;   Send,
{
Transform, Clipboard, Unicode, ú
send ^v
}
else if accent=grave
;   Send,
{
Transform, Clipboard, Unicode, ù
send ^v
}
else if accent=circumflex
;   Send,
{
Transform, Clipboard, Unicode, û
send ^v
}
else if accent=umlaut
;   Send,
{
Transform, Clipboard, Unicode, ü
send ^v
}
Gosub,TurnAccentsOff
Return


c::
if accent=cedilla
;    Send,
{
Transform, Clipboard, Unicode, ç
send ^v
}
Gosub,TurnAccentsOff
Return


n::
if accent=tilda
;    Send,
{
Transform, Clipboard, Unicode, ñ
send ^v
}
Gosub,TurnAccentsOff
Return


+a::
if accent=acute
;   Send,
{
Transform, Clipboard, Unicode, Á
send ^v
}
else if accent=grave
;   Send,
{
Transform, Clipboard, Unicode, À
send ^v
}
else if accent=circumflex
;   Send,
{
Transform, Clipboard, Unicode, Â
send ^v
}
else if accent=umlaut
;   Send,
{
Transform, Clipboard, Unicode, Ä
send ^v
}
else if accent=tilda
;    Send,
{
Transform, Clipboard, Unicode, Ã
send ^v
}
Gosub,TurnAccentsOff
Return


+e::
if accent=acute
;   Send,
{
Transform, Clipboard, Unicode, É
send ^v
}
else if accent=grave
;   Send,
{
Transform, Clipboard, Unicode, È
send ^v
}
else if accent=circumflex
;   Send,
{
Transform, Clipboard, Unicode, Ê
send ^v
}
else if accent=umlaut
;  Send,
{
Transform, Clipboard, Unicode, Ë
send ^v
}
Gosub,TurnAccentsOff
Return


+i::
if accent=acute
;   Send,
{
Transform, Clipboard, Unicode, Í
send ^v
}
else if accent=grave
;   Send,
{
Transform, Clipboard, Unicode, Ì
send ^v
}
else if accent=circumflex
;   Send,
{
Transform, Clipboard, Unicode, Î
send ^v
}
else if accent=umlaut
;   Send,
{
Transform, Clipboard, Unicode, Ï
send ^v
}
Gosub,TurnAccentsOff
Return


+o::
if accent=acute
;   Send,
{
Transform, Clipboard, Unicode, Ó
send ^v
}
else if accent=grave
;   Send,
{
Transform, Clipboard, Unicode, Ò
send ^v
}
else if accent=circumflex
;   Send,
{
Transform, Clipboard, Unicode, Ô
send ^v
}
else if accent=umlaut
;   Send,
{
Transform, Clipboard, Unicode, Ö
send ^v
}
else if accent=tilda
;    Send,
{
Transform, Clipboard, Unicode, Õ
send ^v
}
Gosub,TurnAccentsOff
Return


+u::
if accent=acute
;   Send,
{
Transform, Clipboard, Unicode, ú
send ^v
}
else if accent=grave
;   Send,
{
Transform, Clipboard, Unicode, ù
send ^v
}
else if accent=circumflex
;   Send,
{
Transform, Clipboard, Unicode, û
send ^v
}
else if accent=umlaut
;   Send,
{
Transform, Clipboard, Unicode, ü
send ^v
}
Gosub,TurnAccentsOff
Return


+c::
if accent=cedilla
;    Send,
{
Transform, Clipboard, Unicode, Ç
send ^v
}
Gosub,TurnAccentsOff
Return


+n::
if accent=tilda
;    Send,
{
Transform, Clipboard, Unicode, Ñ
send ^v
}
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


Back to top
View user's profile Send private message
ArchCarrier



Joined: 03 Jun 2008
Posts: 19

PostPosted: Wed Sep 03, 2008 11:44 am    Post subject: Reply with quote

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

Back to top
View user's profile Send private message
jak



Joined: 28 Feb 2006
Posts: 137

PostPosted: Wed Sep 03, 2008 4:35 pm    Post subject: Reply with quote

ArchCarrier wrote:
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
Back to top
View user's profile Send private message
jak



Joined: 28 Feb 2006
Posts: 137

PostPosted: Fri Sep 05, 2008 7:04 am    Post subject: Reply with quote

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.autohotkey.com/forum/viewtopic.php?t=7328&postdays=0&postorder=asc&start=0
and looked up the latin-1 supplemental unicodes for the various french accents.
http://en.wikipedia.org/wiki/Latin-1_Supplement_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.

Code:

;====================================
;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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group