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 

Special characters, OSX style

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



Joined: 01 Apr 2008
Posts: 22
Location: Netherlands

PostPosted: Fri Apr 04, 2008 9:23 pm    Post subject: Special characters, OSX style Reply with quote

Howdy!

A script for Mac users working in Windows, who are used to the way you create special characters in OSX. Here's something that works the same way. I only included ASCII 0-255, for the rest I used a replacement or a description of the symbol.

Key combo's are based on this pdf with all the Mac glyphs.

Two parts, 1st: Alt+key adds accent to a third key, e.g.:
Alt+e+a => á
Alt+e+O => Ó
Alt+u+e => ë
Alt+t+N => Ñ

Code:
#UseHook
!VKC0SC029::Return    ; grave -> the grave ` accent gave some probs, used the virtualkey + scancode instead
!e::Return            ; acute
!i::Return                ; circumflex
!t::Return            ; tilde
!u::Return                ; umlaut

;                  1 2 3 4 5 6 7 8 9 1
;                                    0
;              r   g G a A c C t T u U
*a::diacritic("a","à,À,á,Á,â,Â,ã,Ã,ä,Ä")
*e::diacritic("e","è,È,é,É,ê,Ê,e,E,ë,Ë")
*i::diacritic("i","ì,Ì,í,Í,î,Î,i,I,ï,Ï")
*o::diacritic("o","ò,Ò,ó,Ó,ô,Ô,õ,Õ,ö,Ö")
*u::diacritic("u","ù,Ù,ú,Ú,û,Û,u,U,ü,Ü")
*n::diacritic("n","n,N,n,N,n,N,ñ,Ñ,n,N")
*y::diacritic("y","y,Y,y,Y,y,Y,y,Y,ÿ,Ÿ")

diacritic(regular,accentedCharacters) {
   StringSplit, char, accentedCharacters, `,
   graveOption            := char1
   graveShiftOption       := char2
   acuteOption                := char3
   acuteShiftOption       := char4
   circumflexOption       := char5
   circumflexShiftOption  := char6
   tildeOption            := char7
   tildeShiftOption       := char8
   umlautOption           := char9
   umlautShiftOption      := char10
   
   if (A_PriorHotKey = "!VKC0SC029" && A_TimeSincePriorHotkey < 2000) {
      if (GetKeyState("Shift")) {
         SendInput % graveShiftOption
      } else {
         SendInput % graveOption
      }
   } else if (A_PriorHotKey = "!e" && A_TimeSincePriorHotkey < 2000) {
      if (GetKeyState("Shift")) {
         SendInput % acuteShiftOption
      } else {
         SendInput % acuteOption
      }
   } else if (A_PriorHotKey = "!i" && A_TimeSincePriorHotkey < 2000) {
      if (GetKeyState("Shift")) {
         SendInput % circumflexShiftOption
      } else {
         SendInput % circumflexOption
      }      
   } else if (A_PriorHotKey = "!t" && A_TimeSincePriorHotkey < 2000) {
      if (GetKeyState("Shift")) {
         SendInput % tildeShiftOption
      } else {
         SendInput % tildeOption
      }
   } else if (A_PriorHotKey = "!u" && A_TimeSincePriorHotkey < 2000) {
      if (GetKeyState("Shift")) {
         SendInput % umlautShiftOption
      } else {
         SendInput % umlautOption
      }
   } else {
      if (GetKeyState("Shift") or GetKeyState("Capslock","T")) {
         SendInput % "+" regular
      } else {
         SendInput % regular
      }
   }
}


Second part: Alt+key or Alt+shift+key, e.g.:
Alt+8 = •
Alt+Shift+8 = °
Alt+\ = «
Alt+Shift+\ = »

Code:
;
; Alt + Shift + key
;
*!1::altShift("¡","/")
*!2::altShift("€","™")
*!3::altShift("£","‹")
*!4::altShift("¢","›")
*!5::altShift("8","fi")
*!6::altShift("§","fl")
*!7::altShift("¶","‡")
*!8::altShift("•","°")
*!9::altShift("ª","·")
*!0::altShift("º","‚")

*!a::altShift("å","Å")
*!b::altShift("integral","i")
*!c::altShift("ç","Ç")
*!d::altShift("partial difference","Î")
*!e::altShift("´","‰")
*!f::altShift("ƒ","Ï")
*!g::altShift("©","Ì")
*!h::altShift("overdot","Ó")
*!i::altShift("^","È")
*!j::altShift("delta","Ô")
*!k::altShift("°","Apple")
*!l::altShift("¬","Ò")
*!m::altShift("µ","˜")
*!n::altShift("~","ˆ")
*!o::altShift("ø","Ø")
*!p::altShift("pi","Pi")
*!q::altShift("œ","Œ")
*!r::altShift("®","Â")
*!s::altShift("ß","Í")
;*!t::altShift("†","Ê")
*!u::altShift("¨","Ë")
*!v::altShift("v","lozenge")
*!w::altShift("epsilon","„")
*!x::altShift("approximately equal","Ù")
*!y::altShift("¥","Á")
*!z::altShift("Omega","Û")

*!-::altShift("–","—")
*!=::altShift("!=","±")
*![::altShift("“","”")
*!]::altShift("‘","’")
*!`;::altShift("…","Ú")
*!'::altShift("æ","Æ")
*!\::altShift("«","»")
*!,::altShift("<=","¯")
*!.::altShift(">=","breve")
*!/::altShift("÷","¿")   
   
altShift(accented,accentedShift) {
   if (!GetKeyState("Shift")) {
      SendInput % accented
   } else {
      SendInput % accentedShift
   }
}


I'm sure it's not the most efficient script, but I've only worked with AHK for a few days now Embarassed . But it works, and it's a pretty efficient and easy way to create special chars. Hope someone finds it useful!
Back to top
View user's profile Send private message Send e-mail
tally



Joined: 06 Apr 2008
Posts: 7

PostPosted: Mon Apr 07, 2008 8:33 pm    Post subject: Reply with quote

its simple, so its maintainable and expandable, and it looks useful for OSX users (ive been with windows long enough now but i used to be on mac )
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