AutoHotkey Community

It is currently May 26th, 2012, 11:54 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Accent Hotkey Script
PostPosted: August 3rd, 2004, 8:25 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 2nd, 2008, 9:15 am 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
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, â€


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 3rd, 2008, 11:44 am 
Offline

Joined: June 3rd, 2008, 6:44 pm
Posts: 27
Looks like it could be very useful, but I get the following error message after pressing one of the Win+accent combinations:

Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 3rd, 2008, 4:35 pm 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 5th, 2008, 7:04 am 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Unicode version
PostPosted: October 19th, 2011, 6:14 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 19th, 2011, 9:56 pm 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
Save the script as UTF-8 and remove the tranform parts

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2011, 10:40 pm 
Offline

Joined: September 17th, 2005, 6:43 pm
Posts: 242
I was messing around and came up with this. Hope it works for everyone.
Code:
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
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: IsNull, oldbrother, Rajat and 58 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group