Autohotkey 是否可以在自动热键中对X-Sampa到IPA解释器进行编码?

Autohotkey 是否可以在自动热键中对X-Sampa到IPA解释器进行编码?,autohotkey,Autohotkey,我刚刚开始,虽然我一直在阅读文档,但还没有发现任何暗示可以完成这项任务的建议 我希望能够键入文本,并将其替换为相应的文本。为了抵消这一点,我打算用X[和]将其括起来。因此,如果我键入X[T@]并按下一个魔术键,它将被替换为/θə/ 这有可能吗 如果是这样的话,该怎么做?再说一次,我没有在文件中找到线索。(注意:我可以找到方法来声明神奇钥匙;它正在进行“智能替换”,这并不明显。) ;使用UTF-8-Bom编码保存脚本 xsampa:=ComObjCreate(“Scripting.Dictiona

我刚刚开始,虽然我一直在阅读文档,但还没有发现任何暗示可以完成这项任务的建议

我希望能够键入文本,并将其替换为相应的文本。为了抵消这一点,我打算用
X[
]
将其括起来。因此,如果我键入
X[T@]
并按下一个魔术键,它将被替换为
/θə/

  • 这有可能吗

  • 如果是这样的话,该怎么做?再说一次,我没有在文件中找到线索。(注意:我可以找到方法来声明神奇钥匙;它正在进行“智能替换”,这并不明显。)

  • ;使用UTF-8-Bom编码保存脚本
    xsampa:=ComObjCreate(“Scripting.Dictionary”)
    ; 小写、大写、符号、变音符号-X-Sampa字典
    ;  - 发现https://en.wikipedia.org/wiki/X-SAMPA
    xsampa.item(“A”):=“α”,xsampa.item(“}}}”):=“͈”
    
    xsampa.item(“b_@user3419297-是的,但是如何处理或多或少的智能解析?X-SAMPA的问题是它使用基本文本(字符范围0x20到0x7E)来编码IPA。这就是为什么我用
    X[]
    将其括起来;这在X-SAMPA中找不到。我需要的是让AHK“拾取”"将每个X-SAMPA表示形式分别转换为其对应的IPA,但不是我必须将每个X-SAMPA表示形式单独括起来的地方。主要问题不是解析,而是如何首先将整个字符串作为变量。例如,您需要将整个字符串放入剪贴板to从AHK获取内容。我只建议使用支持脚本的文本编辑器,例如记事本++。有像Pythonscript这样的插件,它会简单得多。@MikhailV-有几个程序我需要这个功能,打开记事本++并不断剪切粘贴是…最不方便的,实际上也没有太大的赌注比打开一个X-SAMPA到IPA的网页进行复制粘贴要好得多。AHK至少有一个优点,可以在大多数情况下工作,如果不是所有我需要它的环境中。如果你在各种应用程序中都需要这个功能,那么是的,你应该使用AHK方法。(不过应该在问题中说明)。因此,在这种情况下,第一个问题应该是-如何检索输入到AHK字符串变量中的文本。通常,这是一个问题,您是否可以选择所需的文本位并将其复制到剪贴板。因此,我建议最好问这个问题。建议的“热字符串”可能会解决这个问题,但它很难管理,而且并不总是稳定的。
    ; Save Script with UTF-8-Bom Encoding
    
    xsampa :=   ComObjCreate("Scripting.Dictionary")
    ; Lower, Uppercase, Symbols, Diacritics - X-Sampa Dictionary 
    ;  - Found on https://en.wikipedia.org/wiki/X-SAMPA
    xsampa.item("A")    := "ɑ", xsampa.item("}}}")  := "͈"
    xsampa.item("b_<")  := "ɓ", xsampa.item("B")    := "β", xsampa.item("L\")   := "ʟ"
    xsampa.item("d_<")  := "ɗ", xsampa.item("B\")   := "ʙ", xsampa.item("M")    := "ɯ"
    xsampa.item("g_<")  := "ɠ", xsampa.item("C")    := "ç", xsampa.item("M\")   := "ɰ"
    xsampa.item("h\")   := "ɦ", xsampa.item("D")    := "ð", xsampa.item("N")    := "ŋ"
    xsampa.item("j\")   := "ʝ", xsampa.item("E")    := "ɛ", xsampa.item("N\")   := "ɴ"
    xsampa.item("l`")   := "ɭ", xsampa.item("F")    := "ɱ", xsampa.item("O")    := "ɔ"
    xsampa.item("l\")   := "ɺ", xsampa.item("G")    := "ɣ", xsampa.item("O\")   := "ʘ"
    xsampa.item("n``")  := "ɳ", xsampa.item("G\")   := "ɢ", xsampa.item("P")    := "ʋ"
    xsampa.item("p\")   := "ɸ", xsampa.item("G\_<") := "ʛ", xsampa.item("Q")    := "ɒ"
    xsampa.item("r``")  := "ɽ", xsampa.item("H")    := "ɥ", xsampa.item("R")    := "ʁ"
    xsampa.item("r\")   := "ɹ", xsampa.item("H\")   := "ʜ", xsampa.item("R\")   := "ʀ"
    xsampa.item("r\``") := "ɻ", xsampa.item("I")    := "ɪ", xsampa.item("S")    := "ʃ"
    xsampa.item("s``")  := "ʂ", xsampa.item("I\")   := "ɪ̈", xsampa.item("T")   := "θ"
    xsampa.item("t``")  := "ʈ", xsampa.item("J")    := "ɲ", xsampa.item("U")    := "ʊ"
    xsampa.item("s\")   := "ɕ", xsampa.item("J\")   := "ɟ", xsampa.item("U\")   := "ʊ̈"
    xsampa.item("v\")   := "ʋ", xsampa.item("J\_<") := "ʄ", xsampa.item("V")    := "ʌ"
    xsampa.item("x\")   := "ɧ", xsampa.item("K")    := "ɬ", xsampa.item("W")    := "ʍ"
    xsampa.item("z``")  := "ʐ", xsampa.item("K\")   := "ɮ", xsampa.item("X")    := "χ"
    xsampa.item("z\")   := "ʑ", xsampa.item("L")    := "ʎ", xsampa.item("X\")   := "ħ"
    xsampa.item("Y")    := "ʏ", xsampa.item("Z")    := "ʒ", xsampa.item("""")   := "ˈ"
    xsampa.item("%")    := "ˌ", xsampa.item("'")    := "ʲ", xsampa.item(":")    := "ː"
    xsampa.item(":\")   := "ˑ", xsampa.item("-")    := " ", xsampa.item("@")    := "ə"
    xsampa.item("@\")   := "ɘ", xsampa.item("{")    := "æ", xsampa.item("}")    := "ʉ"
    xsampa.item("1")    := "ɨ", xsampa.item("2")    := "ø", xsampa.item("3")    := "ɜ"
    xsampa.item("3\")   := "ɞ", xsampa.item("4")    := "ɾ", xsampa.item("5")    := "ɫ"
    xsampa.item("6")    := "ɐ", xsampa.item("7")    := "ɤ", xsampa.item("8")    := "ɵ"
    xsampa.item("9")    := "œ", xsampa.item("&")    := "ɶ", xsampa.item("?")    := "ʔ"
    xsampa.item("?\")   := "ʕ", xsampa.item("<\")   := "ʢ", xsampa.item(">\")   := "ʡ"
    xsampa.item("^")    := "ꜛ", xsampa.item("!")    := "ꜜ", xsampa.item("!\")   := "ǃ"
    xsampa.item("|")    := "|", xsampa.item("|\")   := "ǀ", xsampa.item("||")   := "‖"
    xsampa.item("|\|\") := "ǁ", xsampa.item("=\")   := "ǂ", xsampa.item("-\")   := "‿"
    xsampa.item("_""")  :=  "̈", xsampa.item("_+")   :=  "̟", xsampa.item("_/") := "̌"
    xsampa.item("_-")   := "̠" , xsampa.item("_/")   :=  "̌", xsampa.item("_0")   := "̥"
    xsampa.item("=")    := "̩" , xsampa.item("_=")   := "̩" , xsampa.item("_>")   := "ʼ"
    xsampa.item("_?\")  := "ˤ", xsampa.item("_\")   := "̂" , xsampa.item("_^")   := "̯"
    xsampa.item("_}")   := "̚" , xsampa.item("``")   := "˞" , xsampa.item("~")    := "̃"
    xsampa.item("_~")   := "̃" , xsampa.item("_A")   := "̘" , xsampa.item("_a")   := "̺"
    xsampa.item("_B")   := "̏" , xsampa.item("_B_L") := "᷅" , xsampa.item("_c")   := "̜"
    xsampa.item("_d")   := "̪" , xsampa.item("_e")   := "̴" , xsampa.item("<F>")  := "↘"
    xsampa.item("_F")   := "̂" , xsampa.item("_G")   := "ˠ", xsampa.item("_H")   := "́"
    xsampa.item("_H_T") := "᷄" , xsampa.item("_h")   := "ʰ", xsampa.item("_j")   := "ʲ"
    xsampa.item("_k")   := "̰" , xsampa.item("_L")   := "̀" , xsampa.item("_l")   := "ˡ"
    xsampa.item("_M")   := "̄" , xsampa.item("_m")   := "̻" , xsampa.item("_N")   := "̼"
    xsampa.item("_n")   := "ⁿ", xsampa.item("_O")   := "̹" , xsampa.item("_o")   := "̞"
    xsampa.item("_q")   := "̙" , xsampa.item("<R>")  := "↗", xsampa.item("_R")   := "̌"
    xsampa.item("_R_F") := "᷈" , xsampa.item("_r")   := "̝" , xsampa.item("_T")   := "̋"
    xsampa.item("_t")   := "̤" , xsampa.item("_v")   := "̬" , xsampa.item("_w")   := "ʷ"
    xsampa.item("_X")   := "̆" , xsampa.item("_x")   := "̽" 
    
    
    :*b0:x[::   
        While (e != "EndKey:]"){
            Input, key, v, ]{BS}{Enter}{Esc}
            e := ErrorLevel
            typed .= key, key := ""
            If (e == "EndKey:Backspace")
                typed := SubStr(typed, 1, (StrLen(typed)-1))
            if (e == "EndKey:Escape" || e == "EndKey:Enter") {
                SendInput % "{BackSpace " (e == "EndKey:Enter" ? StrLen(typed)+3 
                                                               : StrLen(typed)+2) "}"
                newText := typed := e := ""
                return
            }
        }
    
        NewText := xsampaParse(xsampa, typed)
    
        SendInput % "{BackSpace " StrLen(typed)+3 "}" newText
        newText := typed := e := ""
        Hotstring("Reset")
    return
    
    
    xsampaParse(xsampa, typed, NewText:="", pos:=4) {
    
        if (StrLen(typed)) { 
            if (xsampa.Exists(SubStr(typed, 1, pos))) {
                newText .= xsampa.item(SubStr(typed, 1, pos)) 
                typed := SubStr(typed, pos+1)
                return xsampaParse(xsampa, typed, NewText)
            } else if (pos == 1) {            
                newText .= SubStr(typed, 1, pos)
                typed := SubStr(typed, pos+1)
                return xsampaParse(xsampa, typed, NewText)
            } else return xsampaParse(xsampa, typed, NewText, --pos)
    
        } else Return newText    
    }