/AutohotKey.ahk

https://github.com/kkovacs/kkrc · AutoHotKey · 150 lines · 115 code · 12 blank · 23 comment · 34 complexity · f66965d33e1ebe66da846acf870f34ff MD5 · raw file

  1. ;
  2. ; OSX-like (Mac-like) AutoHotKey script, based on the work of Veil <veilure@gmail.com> by KKovacs
  3. ; Platform: Win9x/NT/XP/Vista
  4. ;
  5. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  6. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  7. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
  8. ;
  9. ; ### PART I: Mac-like flying accents (diacritics) ###
  10. ;
  11. #UseHook
  12. ;#VKC0SC029::Return ; grave -> the grave ` accent gave some probs, used the virtualkey + scancode instead
  13. #e::Return ; acute
  14. #i::Return ; circumflex
  15. #t::Return ; tilde
  16. #u::Return ; umlaut
  17. #j::Return ; doubleacute
  18. ; 1 2 3 4 5 6 7 8 9 1 1 2
  19. ; 0 1 2
  20. ; r g G a A c C t T u U d D
  21. a::diacritic("a","a,A,á,Á,â,Â,a,A,ä,Ä,a,A")
  22. e::diacritic("e","e,E,é,É,e,E,e,E,ë,Ë,e,E")
  23. i::diacritic("i","i,I,í,Í,î,Î,i,I,i,I,i,I")
  24. o::diacritic("o","o,O,ó,Ó,ô,Ô,o,O,ö,Ö,ő,Ő")
  25. u::diacritic("u","u,U,ú,Ú,u,U,u,U,ü,Ü,ű,Ű")
  26. ; Now again, with SHIFT. ("*" didn't work correctly, it swallows CTRL-A, for example)
  27. +a::diacritic("a","a,A,á,Á,â,Â,a,A,ä,Ä,a,A")
  28. +e::diacritic("e","e,E,é,É,e,E,e,E,ë,Ë,e,E")
  29. +i::diacritic("i","i,I,í,Í,î,Î,i,I,i,I,i,I")
  30. +o::diacritic("o","o,O,ó,Ó,ô,Ô,o,O,ö,Ö,ő,Ő")
  31. +u::diacritic("u","u,U,ú,Ú,u,U,u,U,ü,Ü,ű,Ű")
  32. diacritic(regular,accentedCharacters) {
  33. StringSplit, char, accentedCharacters, `,
  34. graveOption := char1
  35. graveShiftOption := char2
  36. acuteOption := char3
  37. acuteShiftOption := char4
  38. circumflexOption := char5
  39. circumflexShiftOption := char6
  40. tildeOption := char7
  41. tildeShiftOption := char8
  42. umlautOption := char9
  43. umlautShiftOption := char10
  44. doubleacuteOption := char11
  45. doubleacuteShiftOption := char12
  46. if (A_PriorHotKey = "#VKC0SC029" && A_TimeSincePriorHotkey < 2000) {
  47. if (GetKeyState("Shift")) {
  48. SendInput % graveShiftOption
  49. } else {
  50. SendInput % graveOption
  51. }
  52. } else if (A_PriorHotKey = "#j" && A_TimeSincePriorHotkey < 2000) {
  53. if (GetKeyState("Shift")) {
  54. SendInput % doubleacuteShiftOption
  55. } else {
  56. SendInput % doubleacuteOption
  57. }
  58. } else if (A_PriorHotKey = "#e" && A_TimeSincePriorHotkey < 2000) {
  59. if (GetKeyState("Shift")) {
  60. SendInput % acuteShiftOption
  61. } else {
  62. SendInput % acuteOption
  63. }
  64. } else if (A_PriorHotKey = "#i" && A_TimeSincePriorHotkey < 2000) {
  65. if (GetKeyState("Shift")) {
  66. SendInput % circumflexShiftOption
  67. } else {
  68. SendInput % circumflexOption
  69. }
  70. } else if (A_PriorHotKey = "#t" && A_TimeSincePriorHotkey < 2000) {
  71. if (GetKeyState("Shift")) {
  72. SendInput % tildeShiftOption
  73. } else {
  74. SendInput % tildeOption
  75. }
  76. } else if (A_PriorHotKey = "#u" && A_TimeSincePriorHotkey < 2000) {
  77. if (GetKeyState("Shift")) {
  78. SendInput % umlautShiftOption
  79. } else {
  80. SendInput % umlautOption
  81. }
  82. } else {
  83. if (GetKeyState("Shift")) {
  84. SendInput % "+" regular
  85. } else {
  86. SendInput % regular
  87. }
  88. }
  89. }
  90. ;
  91. ; ### PART II: Other special Characters ###
  92. ;
  93. #*1::altShift("!","/")
  94. #*2::altShift("™","€")
  95. #*3::altShift("L","‹")
  96. #*4::altShift("c","›")
  97. #*5::altShift("§","%")
  98. #*6::altShift("^","^")
  99. #*7::altShift("ś","‡")
  100. #*8::altShift("•","°")
  101. #*9::altShift("a","ˇ")
  102. #*0::altShift("o","‚")
  103. #*d::altShift("?","?")
  104. #*f::altShift("f","F")
  105. #*g::altShift("Š","G")
  106. #*o::altShift("o","O")
  107. #*q::altShift("o","O")
  108. #*r::altShift("Ž","‰")
  109. #*s::altShift("ß","S")
  110. #*t::altShift("?","?")
  111. #*y::altShift("Y","Y")
  112. #*-::altShift("–","—")
  113. #*+::altShift("?","ą")
  114. #*[::altShift("“","”")
  115. #*]::altShift("‘","’")
  116. #*`;::altShift("…","?")
  117. #*'::altShift("a","A")
  118. #*\::altShift("Ť","ť")
  119. #*,::altShift("?","„")
  120. #*.::altShift("?",">")
  121. #*/::altShift("÷","?")
  122. altShift(accented,accentedShift) {
  123. if (!GetKeyState("Shift")) {
  124. SendInput % accented
  125. } else {
  126. SendInput % accentedShift
  127. }
  128. }
  129. ;
  130. ; ### PART III: Messing with Modifier Keys
  131. ;
  132. ; Make CAPS LOCK act as CONTROL
  133. Capslock::Ctrl
  134. ;; disable Win key behavior of popping up the Start Menu, but don't disable Win+‹key› combination
  135. ;~LWin Up::Return
  136. ;~RWin Up::Return
  137. ; "í" key to Shift (XXX: but aeiou works only once with it)
  138. SC056::LShift