Автозамена текста из переменной

elscripts

Участник
Автор темы
55
14
Хотелось бы реализовать удобную тему с автозаменой, на форуме смог откопать, но пишет очень медленно, нужно обязательно нажать на пробел, ентер и т.д после написания текста, а хотелось бы чтобы менялось сразу, как например в дефолтной автозамене: ::btw::by the way

Код который использую сейчас:
Код:
Gui, Add, Edit, x82 y199 w120 h30 vHOTKEY1, % hotkey1
        Edit, %HOTKEY1%, Off, UseErrorLevel
        Edit, %HOTKEY1%, label1, On, UseErrorLevel
Gui, Add, Edit, x82 y229 w120 h30 vHOTKEY2, % hotkey2
        Edit, %HOTKEY2%, Off, UseErrorLevel
        Edit, %HOTKEY2%, label2, On, UseErrorLevel
Gui, Add, Edit, x82 y259 w120 h30 vHOTKEY3, % hotkey3
        Edit, %HOTKEY3%, Off, UseErrorLevel
        Edit, %HOTKEY3%, label3, On, UseErrorLevel
Gui, Add, Edit, x82 y289 w120 h30 vHOTKEY4, % hotkey4
        Edit, %HOTKEY4%, Off, UseErrorLevel
        Edit, %HOTKEY4%, label4, On, UseErrorLevel
Gui, Add, Edit, x82 y319 w120 h30 vHOTKEY5, % hotkey5
        Edit, %HOTKEY5%, Off, UseErrorLevel
        Edit, %HOTKEY5%, label5, On, UseErrorLevel
Gui, Add, Edit, x82 y349 w120 h30 vHOTKEY6, % hotkey6
        Edit, %HOTKEY6%, Off, UseErrorLevel
        Edit, %HOTKEY6%, label6, On, UseErrorLevel
Gui, Add, Edit, x82 y379 w120 h30 vHOTKEY7, % hotkey7
        Edit, %HOTKEY7%, Off, UseErrorLevel
        Edit, %HOTKEY7%, label7, On, UseErrorLevel
Gui, Add, Edit, x82 y409 w120 h30 vHOTKEY8, % hotkey8
        Edit, %HOTKEY8%, Off, UseErrorLevel
        Edit, %HOTKEY8%, label8, On, UseErrorLevel
Gui, Add, Edit, x82 y439 w120 h30 vHOTKEY9, % hotkey9
        Edit, %HOTKEY9%, Off, UseErrorLevel
        Edit, %HOTKEY9%, label9, On, UseErrorLevel
Gui, Add, Edit, x82 y469 w120 h30 vHOTKEY10, % hotkey10
        Edit, %HOTKEY10%, Off, UseErrorLevel
        Edit, %HOTKEY10%, label10, On, UseErrorLevel
Gui, Add, Edit, x82 y499 w120 h30 vHOTKEY11, % hotkey11
        Edit, %HOTKEY11%, Off, UseErrorLevel
        Edit, %HOTKEY11%, label11, On, UseErrorLevel
Gui, Add, Edit, x82 y529 w120 h30 vHOTKEY12, % hotkey12
        Edit, %HOTKEY12%, Off, UseErrorLevel
        Edit, %HOTKEY12%, label12, On, UseErrorLevel
Gui, Add, Edit, x392 y199 w120 h30 vHOTKEY13, % hotkey13
        Edit, %HOTKEY13%, Off, UseErrorLevel
        Edit, %HOTKEY13%, label13, On, UseErrorLevel
Gui, Add, Edit, x392 y229 w120 h30 vHOTKEY14, % hotkey14
        Edit, %HOTKEY14%, Off, UseErrorLevel
        Edit, %HOTKEY14%, label14, On, UseErrorLevel
Gui, Add, Edit, x392 y259 w120 h30 vHOTKEY15, % hotkey15
        Edit, %HOTKEY15%, Off, UseErrorLevel
        Edit, %HOTKEY15%, label15, On, UseErrorLevel
Gui, Add, Edit, x392 y289 w120 h30 vHOTKEY16, % hotkey16
        Edit, %HOTKEY16%, Off, UseErrorLevel
        Edit, %HOTKEY16%, label16, On, UseErrorLevel
Gui, Add, Edit, x392 y319 w120 h30 vHOTKEY17, % hotkey17
        Edit, %HOTKEY17%, Off, UseErrorLevel
        Edit, %HOTKEY17%, label17, On, UseErrorLevel
Gui, Add, Edit, x392 y349 w120 h30 vHOTKEY18, % hotkey18
        Edit, %HOTKEY18%, Off, UseErrorLevel
        Edit, %HOTKEY18%, label18, On, UseErrorLevel
Gui, Add, Edit, x392 y379 w120 h30 vHOTKEY19, % hotkey19
        Edit, %HOTKEY19%, Off, UseErrorLevel
        Edit, %HOTKEY19%, label19, On, UseErrorLevel
Gui, Add, Edit, x392 y409 w120 h30 vHOTKEY20, % hotkey20
        Edit, %HOTKEY20%, Off, UseErrorLevel
        Edit, %HOTKEY20%, label20, On, UseErrorLevel
Gui, Add, Edit, x392 y439 w120 h30 vHOTKEY21, % hotkey21
        Edit, %HOTKEY21%, Off, UseErrorLevel
        Edit, %HOTKEY21%, label21, On, UseErrorLevel
Gui, Add, Edit, x392 y469 w120 h30 vHOTKEY22, % hotkey22
        Edit, %HOTKEY22%, Off, UseErrorLevel
        Edit, %HOTKEY22%, label22, On, UseErrorLevel
Gui, Add, Edit, x392 y499 w120 h30 vHOTKEY23, % hotkey23
        Edit, %HOTKEY23%, Off, UseErrorLevel
        Edit, %HOTKEY23%, label23, On, UseErrorLevel
Gui, Add, Edit, x392 y529 w120 h30 vHOTKEY24, % hotkey24
        Edit, %HOTKEY24%, Off, UseErrorLevel
        Edit, %HOTKEY24%, label24, On, UseErrorLevel
Gui, Add, Edit, x682 y199 w120 h30 vHOTKEY25, % hotkey25
        Edit, %HOTKEY25%, Off, UseErrorLevel
        Edit, %HOTKEY25%, label25, On, UseErrorLevel
Gui, Add, Edit, x682 y229 w120 h30 vHOTKEY26, % hotkey26
        Edit, %HOTKEY26%, Off, UseErrorLevel
        Edit, %HOTKEY26%, label26, On, UseErrorLevel
Gui, Add, Edit, x682 y259 w120 h30 vHOTKEY27, % hotkey27
        Edit, %HOTKEY27%, Off, UseErrorLevel
        Edit, %HOTKEY27%, label27, On, UseErrorLevel
Gui, Add, Edit, x682 y289 w120 h30 vHOTKEY28, % hotkey28
        Edit, %HOTKEY28%, Off, UseErrorLevel
        Edit, %HOTKEY28%, label28, On, UseErrorLevel
Gui, Add, Edit, x682 y319 w120 h30 vHOTKEY29, % hotkey29
        Edit, %HOTKEY29%, Off, UseErrorLevel
        Edit, %HOTKEY29%, label29, On, UseErrorLevel
Gui, Add, Edit, x682 y349 w120 h30 vHOTKEY30, % hotkey30
        Edit, %HOTKEY30%, Off, UseErrorLevel
        Edit, %HOTKEY30%, label30, On, UseErrorLevel
Gui, Add, Edit, x682 y379 w120 h30 vHOTKEY31, % hotkey31
        Edit, %HOTKEY31%, Off, UseErrorLevel
        Edit, %HOTKEY31%, label31, On, UseErrorLevel
Gui, Add, Edit, x682 y409 w120 h30 vHOTKEY32, % hotkey32
        Edit, %HOTKEY32%, Off, UseErrorLevel
        Edit, %HOTKEY32%, label32, On, UseErrorLevel
Gui, Add, Edit, x682 y439 w120 h30 vHOTKEY33, % hotkey33
        Edit, %HOTKEY33%, Off, UseErrorLevel
        Edit, %HOTKEY33%, label33, On, UseErrorLevel
Gui, Add, Edit, x682 y469 w120 h30 vHOTKEY34, % hotkey34
        Edit, %HOTKEY34%, Off, UseErrorLevel
        Edit, %HOTKEY34%, label34, On, UseErrorLevel
Gui, Add, Edit, x682 y499 w120 h30 vHOTKEY35, % hotkey35
        Edit, %HOTKEY35%, Off, UseErrorLevel
        Edit, %HOTKEY35%, label35, On, UseErrorLevel
Gui, Add, Edit, x682 y529 w120 h30 vHOTKEY36, % hotkey36
        Edit, %HOTKEY36%, Off, UseErrorLevel
        Edit, %HOTKEY36%, label36, On, UseErrorLevel
Gui, Add, Edit, x232 y199 w140 h30 vtext1, %text1%
Gui, Add, Edit, x232 y229 w140 h30 vtext2, %text2%
Gui, Add, Edit, x232 y259 w140 h30 vtext3, %text3%
Gui, Add, Edit, x232 y289 w140 h30 vtext4, %text4%
Gui, Add, Edit, x232 y319 w140 h30 vtext5, %text5%
Gui, Add, Edit, x232 y349 w140 h30 vtext6, %text6%
Gui, Add, Edit, x232 y379 w140 h30 vtext7, %text7%
Gui, Add, Edit, x232 y409 w140 h30 vtext8, %text8%
Gui, Add, Edit, x232 y439 w140 h30 vtext9, %text9%
Gui, Add, Edit, x232 y469 w140 h30 vtext10, %text10%
Gui, Add, Edit, x232 y499 w140 h30 vtext11, %text11%
Gui, Add, Edit, x232 y529 w140 h30 vtext12, %text12%
Gui, Add, Edit, x532 y199 w140 h30 vtext13, %text13%
Gui, Add, Edit, x532 y229 w140 h30 vtext14, %text14%
Gui, Add, Edit, x532 y259 w140 h30 vtext15, %text15%
Gui, Add, Edit, x532 y289 w140 h30 vtext16, %text16%
Gui, Add, Edit, x532 y319 w140 h30 vtext17, %text17%
Gui, Add, Edit, x532 y349 w140 h30 vtext18, %text18%
Gui, Add, Edit, x532 y379 w140 h30 vtext19, %text19%
Gui, Add, Edit, x532 y409 w140 h30 vtext20, %text20%
Gui, Add, Edit, x532 y439 w140 h30 vtext21, %text21%
Gui, Add, Edit, x532 y469 w140 h30 vtext22, %text22%
Gui, Add, Edit, x532 y499 w140 h30 vtext23, %text23%
Gui, Add, Edit, x532 y529 w140 h30 vtext24, %text24%
Gui, Add, Edit, x812 y199 w140 h30 vtext25, %text25%
Gui, Add, Edit, x812 y229 w140 h30 vtext26, %text26%
Gui, Add, Edit, x812 y259 w140 h30 vtext27, %text27%
Gui, Add, Edit, x812 y289 w140 h30 vtext28, %text28%
Gui, Add, Edit, x812 y319 w140 h30 vtext29, %text29%
Gui, Add, Edit, x812 y349 w140 h30 vtext30, %text30%
Gui, Add, Edit, x812 y379 w140 h30 vtext31, %text31%
Gui, Add, Edit, x812 y409 w140 h30 vtext32, %text32%
Gui, Add, Edit, x812 y439 w140 h30 vtext33, %text33%
Gui, Add, Edit, x812 y469 w140 h30 vtext34, %text34%
Gui, Add, Edit, x812 y499 w140 h30 vtext35, %text35%
Gui, Add, Edit, x812 y529 w140 h30 vtext36, %text36%

Hot1 = %hotkey1%
Str1 = %text1%
Hot2 = %hotkey2%
Str2 = %text2%
Hot3 = %hotkey3%
Str3 = %text3%

Hot4 = %hotkey4%
Str4 = %text4%

Hot5 = %hotkey5%
Str5 = %text5%

Hot6 = %hotkey6%
Str6 = %text6%

Hot7 = %hotkey7%
Str7 = %text7%

Hot8 = %hotkey8%
Str8 = %text8%

Hot9 = %hotkey9%
Str9 = %text9%

Hot10 = %hotkey10%
Str10 = %text10%

Hot11 = %hotkey11%
Str11 = %text11%

Hot12 = %hotkey12%
Str12 = %text12%

Hot13 = %hotkey13%
Str13 = %text13%

Hot14 = %hotkey14%
Str14 = %text14%

Hot15 = %hotkey15%
Str15 = %text15%

Hot16 = %hotkey16%
Str16 = %text16%

Hot17 = %hotkey17%
Str17 = %text17%

Hot18 = %hotkey18%
Str18 = %text18%

Hot19 = %hotkey19%
Str19 = %text19%

Hot20 = %hotkey20%
Str20 = %text20%

Hot21 = %hotkey21%
Str21 = %text21%

Hot22 = %hotkey22%
Str22 = %text22%

Hot23 = %hotkey23%
Str23 = %text23%

Hot24 = %hotkey24%
Str24 = %text24%

Hot25 = %hotkey25%
Str25 = %text25%

Hot26 = %hotkey26%
Str26 = %text26%

Hot27 = %hotkey27%
Str27 = %text27%

Hot28 = %hotkey28%
Str28 = %text28%

Hot29 = %hotkey29%
Str29 = %text29%

Hot30 = %hotkey30%
Str30 = %text30%

Hot31 = %hotkey31%
Str31 = %text31%

Hot32 = %hotkey32%
Str32 = %text32%

Hot33 = %hotkey33%
Str33 = %text33%

Hot34 = %hotkey34%
Str34 = %text34%

Hot35 = %hotkey35%
Str35 = %text35%

Hot36 = %hotkey36%
Str36 = %text36%

  ;  ---  Далее пилить  --- 
#NoEnv
ListLines Off
SetBatchLines -1
Global HotStrings := []

While Hot%A_Index% != ""
    HotStrings[A_Index] := [Hot%A_Index%, Str%A_Index%]
    
EndChars = ()-[]{}:;'"/\`n %A_Tab%,.?!

Loop  {
    Input, chr, I V L1
    SetTimer, Input, -20
}

Input: 
    If (!InStr(EndChars, chr) && (chars .= chr) != "")
        return 
    If Match(chars, match)
        SendInput % "{BS " StrLen(chars) + 1 "}{Raw}" match chr
    chars := ""
    return
    
Match(text, byref match)  {   
    For k, v in HotStrings
        If (text == v[1])
            return 1, match := v[2]
}

(Это часть кода, чтобы было понятнее что из себя выполняет каждое действие)