#NoEnv
SendMode Input
#UseHook
#SingleInstance, force
global PlayBind := 0
global i := 0
global BindsForDelete := []
global BindCmd := []
global FileConfig := % A_MyDocuments "\NeverBind.ini"
global num := 0
IniRead, BindsCount, %FileConfig%, Config, BindsCount
Gui, 1: Font, S8 CDefault Bold, Verdana
Gui, 1: Font, S8 CDefault Bold Italic, Verdana
Gui, 1: Add, Text, x2 y10 w260 h20 , Универсальный биндер для NeverMine
Gui, 1: Add, ListView, x7 y30 w250 h270 vMyListView gMyListView Grid NoSort, Команда|Красткое описание
SetTimer, ReloadList, 300
Gui, 1: Add, Button, x2 y300 w130 h40 gListAdd, Добавить
Gui, 1: Add, Button, x132 y300 w130 h40 gListRemove, Удалить
Gui, 1: Show, , NeverBind
return
HKtoKey(HKey)
{
StringUpper, Hkey, HKey
StringReplace, HKey, HKey, +, ` Shift` , All
StringReplace, HKey, HKey, !, ` Alt` , All
StringReplace, HKey, HKey, ^, ` Ctrl` , All
StringReplace, HKey, HKey, Numpad0, ` Num 0` , All
StringReplace, HKey, HKey, Numpad1, ` Num 1` , All
StringReplace, HKey, HKey, Numpad2, ` Num 2` , All
StringReplace, HKey, HKey, Numpad3, ` Num 3` , All
StringReplace, HKey, HKey, Numpad4, ` Num 4` , All
StringReplace, HKey, HKey, Numpad5, ` Num 5` , All
StringReplace, HKey, HKey, Numpad6, ` Num 6` , All
StringReplace, HKey, HKey, Numpad7, ` Num 7` , All
StringReplace, HKey, HKey, Numpad8, ` Num 8` , All
StringReplace, HKey, HKey, Numpad9, ` Num 9` , All
StringReplace, HKey, HKey, NumpadDiv, ` Num/` , All
StringReplace, HKey, HKey, NumpadDot, ` Num.` , All
StringReplace, HKey, HKey, NumpadAdd, ` Num+` , All
StringReplace, HKey, HKey, NumpadSub, ` Num-` , All
StringReplace, HKey, HKey, NumpadEnter, ` Num Enter` , All
StringReplace, HKey, HKey, &, , All
StringReplace, HKey, HKey, ` ` , ` , All
SubStr(HKey, 2, -1)
RegExMatch(HKey, "(\w)")
return HKey
}
MyListView:
if A_GuiEvent = DoubleClick
{
if( A_EventInfo == 0 )
return
ListViewTarget := A_EventInfo
goto BindEdit
}
return
BindEdit:
{
id := ListViewTarget
IniRead, Count, %FileConfig%, Bind%id%, Count
Gui, 2: Font, S8 CDefault Bold Italic, Verdana
Gui, 2: Font, S8 CDefault Bold Italic, Verdana
Gui, 2: Add, Text, x2 y0 w130 h20 , Описание:
Gui, 2: Add, Edit, x2 y20 w200 h20 vBindName, % BindName
Gui, 2: Add, Text, x2 y40 h20 , Команда [Не Меняется!]:
IniRead, BindCmd, %FileConfig%, Bind%id%, BindCmd
if(BindCmd == "ERROR")
BindCmd := ""
Gui, 2: Add, DropDownList, x-18 y-60 w200 h100 , DropDownList
Gui, 2: Add, Text, x212 y0 w40 h20 , Строк:
Gui, 2: Add, Edit, x212 y20 w60 h20 vCount, % Count
Gui, 2: Add, Edit, x2 y60 w110 h20 vBindCmd, % BindCmd
Gui, 2: Add, Button, x272 y20 w40 h20 gCountEdit, Изм..
Gui, 2: Add, Text, xs, Сообщение:`t`t Задержка Enter
Loop, % Count
{
t := 30*A_Index
IniRead, Msg%A_Index%, %FileConfig%, Bind%id%, Msg%A_Index%
If(Msg%A_Index% == "ERROR")
Msg%A_Index% := ""
Gui, 2: Add, Edit, xs w168 r1 vMsg%A_Index%, % Msg%A_Index%
IniRead, Delay%A_Index%, %FileConfig%, Bind%id%, Delay%A_Index%
if Delay%A_Index% is not number
Delay%A_Index% := 1000
Gui, 2: Add, Edit, x+1 yp w70 r1 vDelay%A_Index%, % Delay%A_Index%
IniRead, Enter%A_Index%, %FileConfig%, Bind%id%, Enter%A_Index%
num := Enter%A_Index%
Gui, 2: Add, DropDownList, x+1 yp w70 vEnterText%A_Index% Choose%num%, Enter|Без Enter
}
Gui, 2: Add, Button, x2 y+3 w312 gBindSave, Сохранить
Gui, 2: Show, w313, Edit - %BindName%
return
}
ListAdd:
{
IniRead, BindsCount, %FileConfig%, Config, BindsCount
if(BindsCount >= 25)
{
MsgBox, 16, NeverBind, Ошибка!`nНельзя создавать больше 25 биндов!
return
}
BindsCount += 1
Count := 1
IniWrite, %BindsCount%, %FileConfig%, Config, BindsCount
IniWrite, %Count%, %FileConfig%, Bind%BindsCount%, Count
IniWrite, New Bind, %FileConfig%, Bind%BindsCount%, BindName
iniWrite, bind%BindsCount%, %FileConfig%, Bind%BindsCount%, BindCmd
IniRead, BindCmd, %FileCOnfig%, Bind%BindsCount%, BindCmd
IniRead, BindName, %FileCOnfig%, Bind%BindsCount%, BindName
LV_Add("", BindCmd, BindName)
return
}
ListRemove:
{
if( !LV_GetNext(1) )
return
MsgBox, 36, Удаление биндов, Вы действительно хотите удалить выделенные бинды?
IfMsgBox No
return
i := 0
BindsForDelete := []
Loop
{
i := LV_GetNext(i - 1)
if not i
break
tmpvar := i + A_Index - 1
BindsForDelete[A_Index] := tmpvar
LV_Delete(i)
IniDelete, %FileConfig%, Bind%tmpvar%
}
OptimizeBinds(BindsForDelete)
return
}
OptimizeBinds(Array)
{
k := 0
Loop % BindsCount
{
i := A_Index
j := A_Index - k
if( inArray(Array, i) )
{
k++
continue
}
if( k == 0 )
continue
IniRead, tmpvar, %FileConfig%, Bind%i%, BindCmd, % ""
IniWrite, % tmpvar <> "ERROR" ? tmpvar : "", %FileConfig%, Bind%j%, BindCmd
IniRead, tmpvar, %FileConfig%, Bind%i%, BindName, % ""
IniWrite, % tmpvar <> "ERROR" ? tmpvar : "", %FileConfig%, Bind%j%, BindName
IniRead, tmpvar, %FileConfig%, Bind%i%, Count, % ""
IniWrite, % tmpvar <> "ERROR" ? tmpvar : "", %FileConfig%, Bind%j%, Count
Loop, % tmpvar
{
IniRead, tmpvar, %FileConfig%, Bind%i%, Msg%A_Index%, % ""
IniWrite, % tmpvar <> "ERROR" ? tmpvar : "", %FileConfig%, Bind%j%, Msg%A_Index%
IniRead, tmpvar, %FileConfig%, Bind%i%, Enter%A_Index%, % ""
IniWrite, % tmpvar <> "ERROR" ? tmpvar : "", %FileConfig%, Bind%j%, Enter%A_Index%
IniRead, tmpvar, %FileConfig%, Bind%i%, Delay%A_Index%, % ""
IniWrite, % tmpvar <> "ERROR" ? tmpvar : "", %FileConfig%, Bind%j%, Delay%A_Index%
}
IniDelete, %FileConfig%, Bind%i%
GuiControl,, MyProgress, +%p%
}
BindsCount -= k
IniWrite, %BindsCount%, %FileConfig%, config, BindsCount
return 1
}
inArray(Array, Search)
{
for Key, Val in Array
{
if (Val = Search)
{
Return 1
}
}
Return 0
}
CountEdit:
{
tmpvar := Count
Gui, 2: Submit, NoHide
if Count is not integer
{
MsgBox, 16, Ошибка, Неверно указано количество строк.
return
}
if(Count < tmpvar)
Loop, % tmpvar - Count
{
i := tmpvar + 1 - A_Index
IniDelete, %FileConfig%, Bind%ListViewTarget%, Msg%i%
IniDelete, %FileConfig%, Bind%ListViewTarget%, Enter%i%
IniDelete, %FileConfig%, Bind%ListViewTarget%, Delay%i%
}
IniWrite, % Count, %FileConfig%, Bind%ListViewTarget%, Count
Gui, 2: Destroy
goto BindEdit
return
}
BindSave:
{
id := ListViewTarget
Gui, 2: Submit, NoHide
IniWrite, % Count, %FileConfig%, Bind%id%, Count
if Count is not number
Count := 0
IniWrite, % BindName, %FileConfig%, Bind%id%, BindName
IniWrite, % BindCmd, %FileConfig%, Bind%id%, BindCmd
j := 0
Loop, % Count
{
i := A_Index - j
if !StrLen(Msg%A_Index%)
{
j++
continue
}
if(EnterText%A_Index% == "Enter")
Enter%A_Index% := 1
else if(EnterText%A_Index% == "Без Enter")
Enter%A_Index% := 2
if(Msg%A_Index% contains "{!}")
{
Msg%A_Index% := RegExReplace(Msg%A_Index%, "{!}", "!")
}
if(Msg%A_Index% contains !)
{
Msg%A_Index% := RegExReplace(Msg%A_Index%, "!", "{!}")
}
IniWrite, % """" Msg%A_Index% """", %FileConfig%, Bind%id%, Msg%i%
IniWrite, % Enter%A_Index%, %FileConfig%, Bind%id%, Enter%A_Index%
tmpvar := ""
IniWrite, % Delay%A_Index%, %FileConfig%, Bind%id%, Delay%i%
}
if( j > 0 )
{
IniRead, Count, %FileConfig%, Bind%id%, Count
IniWrite, % Count - j, %FileConfig%, Bind%id%, Count
}
Gui, 2: Destroy
Gui, 1: -Disabled
Gui, 1: Show
SetTimer, ReloadList, 300
return
}
i := 0
Loop{
Input, loggs, V,{Enter} ; берем все что нажал пользыватель до нажатия enter
IfInString, loggs, Commands[i] ; есть ли там комманда из commands[i]
{
PlayBind := i
send {Enter}
sleep 200
IniRead, Count, %FileConfig%, Bind%PlayBind%, Count, 1
Loop % Count
{
sleep 100
IniRead, Msg%A_Index%, %FileConfig%, Bind%PlayBind%, Msg%A_Index%
IniRead, Delay%A_Index%, %FileConfig%, Bind%PlayBind%, Delay%A_Index%
IniRead, Enter%A_Index%, %FileConfig%, Bind%PlayBind%, Enter%A_Index%
If(Msg%A_Index% >= 0)
{
Msg := Msg%A_Index%
If(Enter%A_Index% == 1)
{
send {t}
sleep 100
send %Msg%{enter}
sleep % Delay%A_Index%
}
If(Enter%A_Index% == 2)
{
send {T}
sleep 100
send %Msg%
sleep % Delay%A_Index%
}
}
}
return
}
i++
if(i == BindsCount + 1) ; если массив закончился обнуляем i
i := 0
Sleep, 30
}
ReloadList:
{
Loop % LV_GetCount()
{
LV_Delete(1)
}
IniRead BindsCount, %FileConfig%, config, BindsCount, 0
If(BindsCount <= 0 )
{
BindsCount += 1
Count := 1
IniWrite, %BindsCount%, %FileConfig%, Config, BindsCount
IniWrite, %Count%, %FileConfig%, Bind%BindsCount%, Count
if(BindsCount == 1)
{
iniWrite, bind1, %FileConfig%, Bind%BindsCount%, BindCmd
}
IniWrite, New Bind, %FileConfig%, Bind%BindsCount%, BindName
LV_Add("", BindCmd, BindName)
return
}
else
{
Loop, % BindsCount
{
IniRead, BindName, %FileConfig%, Bind%A_Index%, BindName
IniRead, BindCmd %FileConfig%, Bind%A_Index%, BindCmd, bind%A_Index%
LV_Add("", (BindCmd == "ERROR" ? "" : BindCmd), BindName)
}
}
SetTimer ReloadList, Off
Return
}
GuiClose:
ExitApp