Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Special characters, OSX style


  • Please log in to reply
5 replies to this topic
Veil
  • Members
  • 24 posts
  • Last active: Jun 01 2013 04:47 PM
  • Joined: 01 Apr 2008
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 => Ñ

#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+\ = »

;
; 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 :oops: . But it works, and it's a pretty efficient and easy way to create special chars. Hope someone finds it useful!

tally
  • Members
  • 6 posts
  • Last active: Aug 01 2008 09:59 PM
  • Joined: 06 Apr 2008
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 )

cuthbert
  • Members
  • 1 posts
  • Last active: Apr 17 2011 06:36 PM
  • Joined: 17 Apr 2011

A script for Mac users working in Windows, who are used to the way you create special characters in OSX


Thanks Veil!

Here's an adaptation of your script that uses MS-Word/MS-Office style key-codes to generate the same accents. (the only change to MS's characters I've made is Ctrl-, + s for German Sharp-S; esset). So Ctrl-' + e = e-accent. There may be some conflicts with other programs, but for me it's worth it (and there's probably a way to do #IfNotWinActive to get rid of those conflicts). It also no longer traps Ctrl-C, so those commands still work.

; AutoHotkey Version: 1.x
; Language.........: English
; Platform.........: Win9x/NT/XP/Vista/Windows 7 
; Author...........: Veil <veilure@gmail.com> adapted by Michael Cuthbert <cuthbert@mit.edu>
;
; Script Function..: Special characters, MS Word style (Office 2010; except Sharp S and some , accents
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#UseHook
^VKC0SC029::Return    ; grave -> the grave ` accent gave some probs, used the virtualkey + scancode instead
^'::Return            ; acute
^^::Return            ; circumflex
^~::Return            ; tilde
^+SC027::Return       ; umlaut
^,::Return            ; cedilla

;                  1 2 3 4 5 6 
;              r   g a c t u c
a::diacritic("a", "à,á,â,ã,ä,ą")
+a::diacritic("A","À,Á,Â,Ã,Ä,Ą")
e::diacritic("e", "è,é,ê,e,ë,ę")
+e::diacritic("E","È,É,Ê,E,Ë,Ę")
i::diacritic("i", "ì,í,î,i,ï,į")
+i::diacritic("I","Ì,Í,Î,I,Ï,Į")
o::diacritic("o", "ò,ó,ô,õ,ö,o")
+o::diacritic("O","Ò,Ó,Ô,Õ,Ö,O")
u::diacritic("u", "ù,ú,û,u,ü,u")
+u::diacritic("U","Ù,Ú,Û,U,Ü,U")
n::diacritic("n", "n,ń,n,ñ,n,n")
+n::diacritic("N","N,Ń,N,Ñ,N,N")
y::diacritic("y", "y,ý,y,y,ÿ,y")
+y::diacritic("Y","Y,Y,Y,Y,Ÿ,Y")
c::diacritic("c", "c,c,c,c,c,ç")
+c::diacritic("C","C,C,C,C,C,Ç")
s::diacritic("s", "s,s,s,s,s,ß")

diacritic(regular,accentedCharacters) {
   StringSplit, char, accentedCharacters, `,
   graveOption            := char1
   acuteOption            := char2
   circumflexOption       := char3
   tildeOption            := char4
   umlautOption           := char5
   cedillaOption          := char6

   timeOutMax := 1000
   
   if (A_PriorHotKey = "^VKC0SC029" && A_TimeSincePriorHotkey < timeOutMax) {
         SendInput % graveOption
   } else if (A_PriorHotKey = "^'" && A_TimeSincePriorHotkey < timeOutMax) {
         SendInput % acuteOption
   } else if (A_PriorHotKey = "^^" && A_TimeSincePriorHotkey < timeOutMax) {
         SendInput % circumflexOption
   } else if (A_PriorHotKey = "^~" && A_TimeSincePriorHotkey < timeOutMax) {
         SendInput % tildeOption
   } else if (A_PriorHotKey = "^+SC027" && A_TimeSincePriorHotkey < timeOutMax) {
         SendInput % umlautOption
   } else if (A_PriorHotKey = "^," && A_TimeSincePriorHotkey < timeOutMax) {
         SendInput % cedillaOption
   } else {
	SendInput % regular   
   }
}

All the best, Michael

Zeta
  • Guests
  • Last active:
  • Joined: --
Wasn't able to get either working with Windows 7 64-bit version of AutoHotKey, so I wrote my own. Incomplete, but totally replaces what I was doing with KeyTweak.

; Remaps windows keys to act like a Mac.
; The latter half remaps the number row to the Mac option combos.

LAlt::LControl
RAlt::RControl
LWin::LAlt
RWin::RAlt
LCtrl::RWin
RCtrl::LWin

!1::SendInput {Asc 173}
!2::SendInput {Asc 0153}
!3::SendInput {Asc 0163}
!4::SendInput {Asc 0162}
!5::SendInput {Asc 236}
!6::SendInput {Asc 0167}
!7::SendInput {Asc 0182}
!8::SendInput {Asc 0149}
!9::Send, {NumpadLeft}{NumpadRight}ª
!0::Send, {NumpadLeft}{NumpadRight}°
!-::Send, {NumpadLeft}{NumpadRight}─
!=::Send, {NumpadLeft}{NumpadRight}≠


Sandro
  • Members
  • 1 posts
  • Last active: Mar 26 2013 08:14 AM
  • Joined: 05 Mar 2013


Here's an adaptation of your script that uses MS-Word/MS-Office style key-codes to generate the same accents. (the only change to MS's characters I've made is Ctrl-, + s for German Sharp-S; esset). So Ctrl-' + e = e-accent. There may be some conflicts with other programs, but for me it's worth it (and there's probably a way to do #IfNotWinActive to get rid of those conflicts). It also no longer traps Ctrl-C, so those commands still work.
 

...

 

 
The version by cuthbert solved the issues I had with CTRL-{key} or ALT-{key} being intercepted, but does not recognize caps lock (when caps lock is active, the intercepted keys remain lower case). The following is a simple hack that solves the caps lock issue, at least for me. Please post if you have a nicer way to get this done.
 
#UseHook
!VKC0SC029::Return 	; grave (using virtualkey + scancode)
!VKDESC028::Return      ; acute (using virtualkey + scancode)
;!i::Return		; circumflex
;!t::Return         	; tilde
!u::Return		; umlaut

a::diacritic("a","à,á,â,ã,ä","A","À,Á,Â,Ã,Ä")
e::diacritic("e","è,é,ê,e,ë","E","È,É,Ê,E,Ë")
i::diacritic("i","ì,í,î,i,ï","I","Ì,Í,Î,I,Ï")
o::diacritic("o","ò,ó,ô,õ,ö","O","Ò,Ó,Ô,Õ,Ö")
u::diacritic("u","ù,ú,û,u,ü","U","Ù,Ú,Û,U,Ü")
n::diacritic("n","n,n,n,ñ,n","N","N,N,N,Ñ,N")

+a::diacritic("A","À,Á,Â,Ã,Ä","a","à,á,â,ã,ä")
+e::diacritic("E","È,É,Ê,E,Ë","e","è,é,ê,e,ë")
+i::diacritic("I","Ì,Í,Î,I,Ï","i","ì,í,î,i,ï")
+o::diacritic("O","Ò,Ó,Ô,Õ,Ö","o","ò,ó,ô,õ,ö")
+u::diacritic("U","Ù,Ú,Û,U,Ü","u","ù,ú,û,u,ü")
+n::diacritic("N","N,N,N,Ñ,N","n","n,n,n,ñ,n")

diacritic(regular, accented, cl_regular, cl_accented) {
	StringSplit, char, accented, `,
	graveOption            := char1
	acuteOption            := char2
	circumflexOption       := char3
	tildeOption            := char4
	umlautOption           := char5

	StringSplit, char, cl_accented, `,
	cl_graveOption         := char1
	cl_acuteOption         := char2
	cl_circumflexOption    := char3
	cl_tildeOption         := char4
	cl_umlautOption        := char5

	if (GetKeyState("Capslock", "T"))
	{
		if (A_TimeSincePriorHotkey < 2000)
		{
			if (A_PriorHotKey = "!VKC0SC029")
				SendInput %cl_graveOption%
			else if (A_PriorHotKey = "!VKDESC028")
				SendInput %cl_acuteOption%
			else if (A_PriorHotKey = "!i")
				SendInput %cl_circumflexOption%
			else if (A_PriorHotKey = "!t")
				SendInput %cl_tildeOption%
			else if (A_PriorHotKey = "!u")
				SendInput %cl_umlautOption% 
			else
				SendInput %cl_regular%
		}
		else
		{
			Send %cl_regular%
		}
	}
	else 
	{
		if (A_TimeSincePriorHotkey < 2000)
		{
			if (A_PriorHotKey = "!VKC0SC029")
				SendInput %graveOption%
			else if (A_PriorHotKey = "!VKDESC028")
				SendInput %acuteOption%
			else if (A_PriorHotKey = "!i")
				SendInput %circumflexOption%
			else if (A_PriorHotKey = "!t")
				SendInput %tildeOption%
			else if (A_PriorHotKey = "!u")
				SendInput %umlautOption% 
			else
				SendInput %regular%
		}
		else
		{
			Send %regular%
		}
	}
}


BartL
  • Members
  • 1 posts
  • Last active: Jul 22 2013 09:15 AM
  • Joined: 21 Jul 2013

Just wanted to say thank you, just what I was looking for :)

I'm using ConnectedText with in a Windows simulation using Parallels, and it is really useful not having to learn Windows style special character input.

 

The 'ancient' version Veil made still seems to be working fine (using Windows XP).

There are no accents on capitals in Dutch, so for the now I'll stick to that version.