JGR
Joined: 15 Jun 2006 Posts: 53 Location: Flaky internet connection :/
|
Posted: Thu Sep 25, 2008 10:57 am Post subject: Yet Another Accent Script |
|
|
This is the accent processing section of my home AHK setup...
Included are the entire greek alphabet in upper and lower case, various miscellaneous characters, and a mechanism where one or more of the following accents: grave, acute, tilde, umlaut, cedilla, circumflex, caron, breve, macron, stroke overlay and dot above, can be combined with a typed letter in a dead-key type system.
This is easy to extend to other accent types (those in the 0300-036F part of the unicode table).
Character transformation is done by the FoldStringW function.
Characters-accent combinations which do not exist as discrete characters will be sent as separate characters, and may or may not look acceptable depending on the combination.
Your mileage may vary trying to use this script to put two accents on one character (the order of accents is important, see a character map for practical combinations).
EDIT: Using the clipboard code here: http://www.autohotkey.com/forum/viewtopic.php?p=50708#50708, post-modification of characters can be performed, by entering the character by any method (into an editable region), then pressing the accent key combination and then enter.
This enables characters entered by hotkey to be themselves accent-modified.
Code below has been updated...
Examples:
alt-gr(or ctrl-alt)+[, a --> á
alt-gr+;, alt-gr+], u --> ǜ
o, e, ¬ --> ø
a, e, ¬, alt-gr+[, enter --> ǽ
e, t, h, ¬ --> ð
a, l, ¬, alt-gr+[, enter --> ά
i, n, f, ¬ --> ∞
| Code: | stackcount:=0
; This set of key mappings was originally designed for a UK laptop keyboard layout.
; By JGR - Jonathan G. Rennison
:?*:oe¬::ø
:?*:ae¬::æ
:?*:aa¬::å
:?*C:eth¬::
SendInputU("00F0")
return
:?*Cæ:ETH¬::
SendInputU("00D0")
return
:?*C:ksi¬::
SendInputU("03BE")
return
:?*C:KSI¬::
SendInputU("039E")
return
:?*:tm¬::
SendInputU("2122")
return
:?*:r¬::®
:?*:ohm¬::
SendInputU("2126")
return
:?*C:th¬::
SendInputU("03B8")
return
:?*C:iot¬::
SendInputU("03B9")
return
:?*C:kap¬::
SendInputU("03BA")
return
:?*C:pi¬::
SendInputU("03C0")
return
:?*C:dl¬::
SendInputU("03B4")
return
:?*C:eps¬::
SendInputU("03B5")
return
:?*C:zta¬::
SendInputU("03B6")
return
:?*C:eta¬::
SendInputU("03B7")
return
:?*C:lm¬::
SendInputU("03BB")
return
:?*C:om¬::
SendInputU("03C9")
return
:?*C:psi¬::
SendInputU("03C8")
return
:?*C:phi¬::
SendInputU("03C6")
return
:?*C:chi¬::
SendInputU("03C7")
return
:?*C:si¬::
SendInputU("03C3")
return
:?*C:tau¬::
SendInputU("03C4")
return
:?*C:ups¬::
SendInputU("03C5")
return
:?*C:al¬::
SendInputU("03B1")
return
:?*C:be¬::
SendInputU("03B2")
return
:?*C:ga¬::
SendInputU("03B3")
return
:?*C:TH¬::
SendInputU("0398")
return
:?*C:IOT¬::
SendInputU("0399")
return
:?*C:KAP¬::
SendInputU("039A")
return
:?*C:PI¬::
SendInputU("03A0")
return
:?*C:DL¬::
SendInputU("0394")
return
:?*C:EPS¬::
SendInputU("0395")
return
:?*C:ZTA¬::
SendInputU("0396")
return
:?*C:ETA¬::
SendInputU("0397")
return
:?*C:LM¬::
SendInputU("039B")
return
:?*C:OM¬::
SendInputU("03A9")
return
:?*C:PSI¬::
SendInputU("03A8")
return
:?*C:AL¬::
SendInputU("0391")
return
:?*C:BE¬::
SendInputU("0392")
return
:?*C:GA¬::
SendInputU("0393")
return
:?*C:PHI¬::
SendInputU("03A6")
return
:?*C:CHI¬::
SendInputU("03A7")
return
:?*C:SI¬::
SendInputU("03A3")
return
:?*C:TAU¬::
SendInputU("03A4")
return
:?*C:UPS¬::
SendInputU("03A5")
return
:?*:int¬::
SendInputU("222B")
return
:?*:pd¬::
SendInputU("2202")
return
:?*:inf¬::
SendInputU("221E")
return
:?*:+-¬::
SendInputU("00B1")
return
:?*:deg¬::
SendInputU("00B0")
return
:?*C:mu¬::
SendInputU("03BC")
return
:?*C:MU¬::
SendInputU("039C")
return
:?*C:nu¬::
SendInputU("03BD")
return
:?*C:NU¬::
SendInputU("039D")
return
:?*C:omi¬::
SendInputU("03BF")
return
:?*C:OMI¬::
SendInputU("039F")
return
:?*C:cc¬::
SendInputU("00E7")
return
:?*C:CC¬::
SendInputU("00C7")
return
:?*:c¬::©
:?*C:rh¬::
SendInputU("03C1")
return
:?*C:RH¬::
SendInputU("03A1")
return
:?*C:thn¬::
SendInputU("00FE")
return
:?*C:THN¬::
SendInputU("00DE")
return
$^![::
DoAccent("0301") ;acute
return
$^!]::
DoAccent("0300") ;grave
return
$^!#::
DoAccent("0303","~") ;tilde
return
$^!;::
DoAccent("0308") ;umlaut
return
$^!'::
DoAccent("0327") ;cecilla
return
$^!6::
DoAccent("0302","^") ;circumflex
return
$^!7::
DoAccent("030C") ;caron
return
$^!8::
DoAccent("0306") ;breve
return
$^!=::
DoAccent("0304") ;macron
return
$^!-::
DoAccent("0335") ;long stroke overlay
return
$^!.::
DoAccent("0307") ;dot above
return
#include clip.ahk ; http://www.autohotkey.com/forum/viewtopic.php?p=50708#50708
DoAccent( p_text, norm_=0 )
{
global
if(stackcount=0)
{
str_in:=1
VarSetCapacity( str_in, 500, 0)
}
NumPut( "0x" p_text, &str_in, 2+stackcount*2,"UShort" )
stackcount++
Input, SingleKey, L1
;pause
if(ErrorLevel = "NewInput")
return
if(SingleKey=" " && stackcount = 1)
{
if(norm_ != 0)
SendInput {Raw}%norm_%
else
SendInputU(p_text)
stackcount:=0
str_in:=1
return
}
if(SingleKey="`n")
{
Clip:=ClipboardAll
Send, +{left}
;Sleep, 50
Send, ^c
;Sleep, 50
VarSetCapacity(str, 50)
GetClipboardData(13, str)
keynum:=NumGet(str, 0, "UShort")
Clipboard:=Clip
}
else
keynum:=asc(SingleKey)
NumPut( keynum, &str_in, 0,"UShort" )
str_out:=1
VarSetCapacity( str_out, 500, 0 )
; #define MAP_PRECOMPOSED 32
outcount:=DllCall("FoldStringW", "UInt", 32, "UInt", &str_in, "UInt", stackcount+1, "UInt", &str_out, "UInt", 250, "UInt")
stackcount:=0
str_in:=1
SendInputU(&str_out,outcount)
}
SendInputU( p_text, num=0 )
{
if(num)
len:=num*4
else
StringLen, len, p_text
INPUT_size = 28
event_count := ( len//4 )*2
VarSetCapacity( events, INPUT_size*event_count, 0 )
loop, % event_count//2
{
if(num)
code:=NumGet(p_text+0,(A_Index*2)-2,"UShort")
else
{
StringMid, code, p_text, ( A_Index-1 )*4+1, 4
code:="0x" code
}
;pause
base := ( ( A_Index-1 )*2 )*INPUT_size+4
NumPut( 1, &events, base-4 )
NumPut( code, &events, base+2,"UShort" )
NumPut( 4, &events, base+4 ) ; KEYEVENTF_UNICODE
base += INPUT_size
NumPut( 1, &events, base-4 )
NumPut( code, &events, base+2, "UShort" )
NumPut( 2|4, &events, base+4 ) ; KEYEVENTF_KEYUP|KEYEVENTF_UNICODE
}
result := DllCall( "SendInput", "uint", event_count, "uint", &events, "int", INPUT_size )
if ( ErrorLevel or result < event_count )
{
MsgBox, [SendInput] failed: EL = %ErrorLevel% ~ %result% of %event_count%
return, false
}
return, true
} |
| Code: | Char hotstrings:
int¬: ∫, pd¬: ∂, inf¬: ∞, oe¬: ø, ae¬: æ, aa¬: å, deg¬: °, cc¬: ç, +-¬: ±, thn: þ, eth¬: ð, ohm¬: Ω, c¬: ©, tm¬: ™, r¬: ®
Greek hotstrings:
al¬: α, be¬: β, ga¬: γ, dl¬: δ, eps¬: ε, zta¬: ζ, eta¬: η, th¬: θ, iot¬: ι, kap¬: κ,lm¬: λ, mu¬: μ, nu¬: ν, ksi¬: ξ, omi¬: ο, pi¬: π, rh¬: ρ, si¬: σ, tau¬: τ, ups¬: υ, phi¬: φ, chi¬: χ,psi¬: ψ, om¬: ω
Accent pre-modifiers:
^![: ́ , ^!]: ̀ , ^!#: ~ , ^!;: ̈ , ^!': ̧ , ^!6: ^ , ^!7: ̌ , ^!8: ̆ , ^!=: ̄ , ^!-: ̵ , ^!.: ̇ |
|
|