Advertisement
sawczakl

AHK IPA

Jan 23rd, 2024
1,746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; adds Windows + f as an IPA hotkey
  2. ; once in IPA mode, press a letter to cycle through IPA symbols (see KEYS below)
  3. ; then hit another key (e.g. right arrow or space) to select that symbol
  4. ; e.g. to type æ type: windows + f > a > a > right arrow
  5.  
  6. ; comments: luke@sawczak.com
  7. ; last updated 2020-08-13
  8.  
  9.  
  10. ;     KEYS
  11.  
  12. ;     a = ɑ æ ɐ ɑ̃
  13. ;     b = β ɓ ʙ
  14. ;     c = ɕ ç
  15. ;     d = ð d͡ʒ ɖ ɗ
  16. ;     e = ə ɚ ɵ ɘ
  17. ;     f = ɛ ɜ ɝ ɛ̃ ɞ
  18. ;     g = ɠ ɢ ʛ
  19. ;     h = ɥ ɦ ħ ɧ ʜ
  20. ;     i = ɪ ɪ̈ ɨ
  21. ;     j = ʝ ɟ ʄ
  22. ;     k = ʔ ʕ ʢ ʡ
  23. ;     l = ɫ ɬ ʟ ɭ ɮ
  24. ;     m = ɱ
  25. ;     n = ŋ ɲ ɴ ɳ
  26. ;     o = ɔ œ ø ɒ ɔ̃ ɶ œ̃
  27. ;     p = ɸ
  28. ;     q = "ˈ "ˌ | ‖ ∅
  29. ;     r = ɾ ʁ ɹ ɻ ʀ ɽ ɺ
  30. ;     s = ʃ ʂ
  31. ;     t = θ t͡ʃ t͡s ʈ
  32. ;     u = ʊ ʊ̈ ʉ
  33. ;     v = ʌ ʋ ⱱ
  34. ;     w = ʍ ɯ ɰ
  35. ;     x = χ
  36. ;     y = ʎ ɣ ʏ ɤ
  37. ;     z = ʒ ʐ ʑ
  38.  
  39.  
  40. #NoTrayIcon
  41.  
  42. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  43. ; #Warn  ; Enable warnings to assist with detecting common errors.
  44. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  45. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  46.  
  47. KEYS := {"a": ["ɑ", "æ", "ɐ", "ɑ̃"],"b": ["β", "ɓ", "ʙ"],"c": ["ɕ", "ç"],"d": ["ð", "d͡ʒ", "ɖ", "ɗ"],"e": ["ə", "ɚ", "ɵ", "ɘ"],"f": ["ɛ", "ɜ", "ɝ", "ɛ̃", "ɞ"],"g": ["ɠ", "ɢ", "ʛ"],"h": ["ɥ", "ɦ", "ħ", "ɧ", "ʜ"],"i": ["ɪ", "ɪ̈", "ɨ"],"j": ["ʝ", "ɟ", "ʄ"], "k": ["ʔ", "ʕ", "ʢ", "ʡ"],"l": ["ɫ", "ɬ", "ʟ", "ɭ", "ɮ"],"m": ["ɱ"], "n": ["ŋ", "ɲ", "ɴ", "ɳ"],"o": ["ɔ", "œ", "ø", "ɒ", "ɔ̃", "ɶ", "œ̃"],"p": ["ɸ"],"q": ["ˈ", "ˌ", "|", "‖", "∅"],"r": ["ɾ", "ʁ", "ɹ", "ɻ", "ʀ", "ɽ", "ɺ"],"s": ["ʃ", "ʂ"],"t": ["θ", "t͡ʃ", "t͡s", "ʈ"],"u": ["ʊ", "ʊ̈", "ʉ"],"v": ["ʌ", "ʋ", "ⱱ"],"w": ["ʍ", "ɯ", "ɰ"],"x": ["χ"],"y": ["ʎ", "ɣ", "ʏ", "ɤ"],"z": ["ʒ", "ʐ", "ʑ"]}
  48.  
  49. DIRECT := ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", " ", ",", ".", ";", "/", "[", "]", "-", "=", "\", "``", "'"]
  50.  
  51. #f::
  52.  caret_x = %A_CaretX%
  53.  caret_y = %A_CaretY%
  54.  caret_y += 50
  55.  
  56.  tooltip, Entering IPA symbol (type alphabetic letters; any other key to quit), caret_x, caret_y
  57.  
  58.  started := 0
  59.  index := 1
  60.  last := "-"
  61.  entered := "-"
  62.  
  63.  while True {
  64.   Input, key, L1, {RCtrl}{Enter}{Delete}{BackSpace}{Escape}{LAlt}{RAlt}{LShift}{RShift}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Ins}{Capslock}{Numlock}{PrintScreen}{Pause}{LWin}{RWin}
  65.  
  66.   for i, val in DIRECT {
  67.    if (val = key) {
  68.     tooltip,
  69.     send % key
  70.     return
  71.    }
  72.   }
  73.  
  74.   if (not (KEYS.HasKey(key))) {
  75.    tooltip,
  76.    return
  77.  
  78.   } else {
  79.  
  80.    if ((started = 1) and (key != last)) {
  81.     send % key
  82.     tooltip,
  83.     return
  84.     index := 1
  85.    } else if (key = last) {
  86.     index++
  87.    }
  88.  
  89.    if ((index) > KEYS[key].MaxIndex()) {
  90.     index := 1
  91.    }
  92.  
  93.    if (started = 1) {
  94.     Loop, % StrLen(entered) {
  95.      send {BackSpace}
  96.     }
  97.    } else {
  98.     started := 1
  99.    }
  100.  
  101.    last := key
  102.    entered := KEYS[key][index]
  103.    send % entered
  104.   }
  105.  }
  106.  
  107. return
  108.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement