[
  {
    "path": ".gitignore",
    "content": "__Compiler/\n__Release/\nCKr/\nCurr/\nDump/\nHighChart/\nHist/\nKr/\nSets/\nUnvalid/\nValid/\n*.ico"
  },
  {
    "path": "GUIDefine.ahk",
    "content": "﻿#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\Class_CtlColors.ahk\n#Include, Lib\\Classes\\Class_ImageButton.ahk\n#Include, Lib\\Classes\\Class_GDIplus.ahk\n\n#Include, Lib\\Language.ahk\n\nFolderSet()\n\nIf !Level := LogIn(AdminName := A_Args[1], AdminPass := A_Args[2]) {\n    FileRead, Reciever, Sets\\Login.Hwnd\n    FileOpen(\"Sets\\Login.Request\", \"w\").Write(\"Run|\" A_ScriptFullPath).Close()\n    SendMessage, 0x1000,,,, ahk_id %Reciever%\n    Sleep, 1000\n    MsgBox, 16, % _112, % _114\n    ExitApp\n}\n\nGui, +HwndMain +Resize\nGui, Add, Pic, % \"x0 y0\", Img\\BG.png\nGui, Margin, 10, 10\nGui, Color, 0x7D7D3A\nGui, Font, s14 Bold, Calibri\n\nqw := ((A_ScreenWidth - 255) // 5)\n\nGui, Add, Text, % \"xm+220 y30 vDbcT w\" qw \" h32 Center BackgroundTrans\", % _56 \":\"\nGui, Add, Text, % \"xp+\" qw \" yp wp hp Center BackgroundTrans\", % _57 \":\"\nGui, Add, Text, % \"xp+\" qw \" yp wp hp Center BackgroundTrans\", % _58 \":\"\nGui, Add, Text, % \"xp+\" qw \" yp wp hp Center BackgroundTrans\", % _59 \":\"\nGui, Add, Text, % \"xp+\" qw \" yp wp hp Center BackgroundTrans\", % _176 \":\"\nGui, Font, s15\nGui, Add, Edit, % \"xp-\" qw * 4 \" yp+32 wp Center Border vDbc -E0x200 cBlue\"\nGui, Add, Edit, % \"xp+\" qw \" yp wp Center Border vDnm -E0x200\"\nGui, Add, Edit, % \"xp+\" qw \" yp wp Center Border vDbp -E0x200 Number cRed\"\nGui, Add, Edit, % \"xp+\" qw \" yp wp Center Border vDsp -E0x200 Number cGreen\"\nGui, Add, Edit, % \"xp+\" qw \" yp wp Center Border vDst -E0x200\"\n\nGui, Font, s15\nGui, Add, ListView, % \"xm+220 yp+75 w\" qw * 5 \" h\" A_ScreenHeight - 280 \" Grid vLV2 HwndHCtrl gEdit BackgroundE6E6E6\", % _63 \"|\" _38 \"|\" _40 \"|\" _39 \"|\" _118\n\nLV_ModifyCol(1, qw)\nLV_ModifyCol(2, qw)\nLV_ModifyCol(3, qw)\nLV_ModifyCol(4, qw)\nLV_ModifyCol(5, qw)\n\nGui, Font, s17\nGui, Add, Edit, % \"xp+\" qw*3 \" yp+\" A_ScreenHeight - 275 \" w\" qw*2 \" Center vStockSum -E0x200 HwndHCtrl Border\"\nCtlColors.Attach(HCtrl, \"EAEAB5\")\n\nButtonTheme := [[3, 0x80FF80, 0x5ABB5A, 0x000000, 2,, 0x008000, 1]\n              , [3, 0x44DB44, 0x2F982F, 0x000000, 2,, 0x008000, 1]\n              , [3, 0x1AB81A, 0x107410, 0x000000, 2,, 0x008000, 1]\n              , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]\n\nButtonTheme2 := [[3, 0x00E7E7, 0x02A0A0, 0x000000, 2,, 0x007E80, 1]\n               , [3, 0x02CBCB, 0x028080, 0x000000, 2,, 0x007E80, 1]\n               , [3, 0x03A4A4, 0x036767, 0x000000, 2,, 0x007E80, 1]\n               , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]\n\nButtonTheme3 := [[3, 0xFFC488, 0xBF9264, 0x000000, 2,, 0x804000, 1]\n               , [3, 0xE0AB75, 0x96724E, 0x000000, 2,, 0x804000, 1]\n               , [3, 0xC29465, 0x826344, 0x000000, 2,, 0x804000, 1]\n               , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]\n\nButtonTheme4 := [[3, 0xFF6F6F, 0xBC5454, 0x000000, 2,, 0xFF0000, 1]\n               , [3, 0xDC6262, 0x9C4545, 0x000000, 2,, 0xFF0000, 1]\n               , [3, 0xBF5454, 0x8A3C3C, 0x000000, 2,, 0xFF0000, 1]\n               , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0xFF0000, 1]]\n\nGui, Add, Text, xm+5 ym w190 Center BackgroundTrans, % _200\n\nGui, Font, s14\nGui, Add, Text, wp BackgroundTrans, % _208 \":\"\nGui, Add, DDL, vViewMode wp AltSubmit gLoadProducts, % _209 \"||\" _210\nGui, Add, ListBox, % \"0x100 wp r10 vGroup gDisplayGroup HwndHCtrl\", % _74\nCtlColors.Attach(HCtrl, \"D8D8AD\")\nGui, Font, s13\nGui, Add, Button, % \"wp h30 gAddGroup HwndHCtrl\", % _183\nImageButton.Create(HCtrl, ButtonTheme*)\n                         \nGui, Add, Button, % \"w190 h30 gDelGroup HwndHCtrl\", % _195\nImageButton.Create(HCtrl, ButtonTheme4*)\n\nGui, Add, Button, % \"xm+220 y100 wp h30 gEnter HwndHCtrl\", % _36 \" ↓\"\nImageButton.Create(HCtrl, ButtonTheme*)\n\nGui, Add, Button, % \"xp+\" qw*4 + (qw - 190) \" yp w190 hp gEdit HwndHCtrl\", %  \"↑ \" _131\nImageButton.Create(HCtrl, ButtonTheme2*)\n\nGui, Font, Italic\nGui, Add, Button, % \"xm+220 y\" A_ScreenHeight - 130 \" w100 h30 gFillForms HwndHCtrl\", % _193\nImageButton.Create(HCtrl, ButtonTheme3*)\n                         \nGui, Add, Button, % \"xp+110 yp wp hp gResetAll HwndHCtrl\", % _142\nImageButton.Create(HCtrl, ButtonTheme3*)\n                         \nGui, Add, Button, % \"xp+110 yp wp hp gDelete HwndHCtrl\", % _130\nImageButton.Create(HCtrl, ButtonTheme3*)\n\nGui, Add, Button, % \"xp+110 yp wp hp gEsc HwndHCtrl\", % _169\nImageButton.Create(HCtrl, ButtonTheme3*)\n\nGui, Font\nGui, Font, s12 Bold, Calibri\nLevels := [\"Admin\", \"User\"]\nGui, Add, StatusBar\nSB_SetParts(10, 200, 200)\nSB_SetText(_206 \": \" AdminName, 2)\nSB_SetText(_207 \": \" Levels[Level], 3)\n\nGui, Show, Maximize, Definition GUI\nThemeAdd()\nLoadGroups()\nGuiControl, Choose, Group, |1\nReturn\n\n#Include, GUIDefine_Labels.ahk\n#Include, GUIDefine_Functions.ahk\n#Include, GUIDefine_Hotkeys.ahk"
  },
  {
    "path": "GUIDefine_Functions.ahk",
    "content": "LoadGroups() {\n    Global _74\n    GuiControl,, Group, |\n    GuiControl,, Group, % _74\n    Loop, Files, Sets\\Def\\*, D\n        GuiControl,, Group, % A_LoopFileName\n    GuiControl, Choose, Group, |1\n}\n\nLogIn(Username, Password) {\n    If (FileExist(\"Sets\\Acc.chu\")) {\n        Account := {}\n        FileRead, RawAccount, Sets\\Acc.chu\n        TextAccount := b64Decode(RawAccount)\n        \n        For Each, User in StrSplit(TextAccount, \",\") {\n            LOG := StrSplit(User, \"|\")\n            Account[LOG[1]] := [LOG[2], LOG[3]]\n        }\n        \n        If (Account[Username][1] = Password) {\n            If (Account[Username][2] = \"Admin\")\n                Return, 1\n            Else If (Account[Username][2] = \"User\")\n                Return, 2\n        }\n    }\n    Return, 0\n}\n\nb64Encode(string) {\n    VarSetCapacity(bin, StrPut(string, \"UTF-8\")) && len := StrPut(string, &bin, \"UTF-8\") - 1 \n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    VarSetCapacity(buf, size << 1, 0)\n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    return StrGet(&buf)\n}\n\nb64Decode(string) {\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        throw Exception(\"CryptStringToBinary failed\", -1)\n    VarSetCapacity(buf, size, 0)\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        throw Exception(\"CryptStringToBinary failed\", -1)\n    return StrGet(&buf, size, \"UTF-8\")\n}\n\nLoadProducts() {\n    LV_Delete(), Files := \"\", Loc := {}\n    GuiControl,, StockSum\n    Loop, Files, % \"Sets\\Def\\*.def\", R\n    {\n        Bc := StrReplace(A_LoopFileName, \".def\")\n        Files .= Files != \"\" ? \"`n\" Bc : Bc\n        Loc[\"\" Bc \"\"] := A_LoopFileFullPath\n    }\n\n    Sort, Files, N\n    StockSum := 0\n\n    GuiControlGet, ViewMode,, ViewMode\n    Loop, Parse, Files, `n\n    {\n        If (ViewMode = 2) && !FileExist(\"Sets\\Def\\\" A_LoopField \".def\") {\n            Continue\n        }\n        FileRead, Content, % Loc[\"\" A_LoopField \"\"]\n        Content := StrSplit(Content, \";\"), Content[4] != \"\" ? StockSum += Content[4] * Content[3] : 0\n        LV_Add(, A_LoopField, Content[1], Content[2], Content[3], \"[\" (Content[4] != \"\" ? Content[4] : 0) \"]\")\n        GuiControl,, StockSum, % StockSum \" \" ConvertMillimsToDT(StockSum)\n        \n    }\n    Return, StockSum\n}\n\nConvertMillimsToDT(Value, Sign := \"\") {\n    If (Value + 1 = \"\")\n        Return\n    ValueArr := StrSplit(Value / 1000, \".\")\n    Return, \"[\" ValueArr[1] (ValueArr[2] ? \".\" RTrim(ValueArr[2], 0) : \"\") \" DT]\"\n}\n\nFolderSet() {\n    Array := [ \"Curr\"\n             , \"Sets\"\n             , \"Sets\\Def\"\n             , \"Valid\"\n             , \"Dump\"\n             , \"Kr\"\n             , \"CKr\" \n             , \"Unvalid\" \n             , \"Hist\" ]\n\n    For Every, Folder in Array {\n        If !FolderExist(Folder) {\n            FileCreateDir, % Folder\n        }\n    }\n}\n\nFolderExist(Folder) {\n    Return InStr(FileExist(Folder), \"D\")\n}\n\nThemeAdd() {\n    Loop, 5 {\n        Gui, Add, Text, % \"y0 x\" 208 + A_Index * 2 \" w1 h\" A_ScreenHeight \" HwndHCtrl\"\n        CtlColors.Attach(HCtrl, \"7D7D64\")\n    }\n}\n\nAdd() {\n    Global StockSum, _177, _178\n    GuiControlGet, Dbc,, Dbc\n    \n    ExistedDef := \"\"\n    Loop, Files, % \"Sets\\Def\\\" Dbc \".def\", R\n    {\n        ExistedDef := A_LoopFileFullPath\n    }\n\n    If (ExistedDef != \"\") {\n        FileRead, Content, % ExistedDef\n        MsgBox, 48, % _177, % _178 \"`n`n\" Dbc \" = \" StrSplit(Content, \";\")[1]\n        Return, 0\n    }\n    \n    GuiControlGet, Group,, Group\n    WD := (Group = \"ALL\") ? \"Sets\\Def\\\" : \"Sets\\Def\\\" Group \"\\\"\n\n    GuiControlGet, Dnm,, Dnm\n    GuiControlGet, Dbp,, Dbp\n    GuiControlGet, Dsp,, Dsp\n    GuiControlGet, Dst,, Dst\n\n    LV_Insert(1,, Dbc, Dnm, Dbp, Dsp, \"[\" Dst \"]\")\n    FileOpen(WD Dbc \".def\", \"w\").Write(Dnm \";\" Dbp \";\" Dsp \";\" Dst).Close()\n    \n    GuiControl,, Dbc\n    GuiControl,, Dnm\n    GuiControl,, Dbp\n    GuiControl,, Dsp\n    GuiControl,, Dst\n\n    StockSum += Dsp * Dst\n    GuiControl,, StockSum, % StockSum \" \" ConvertMillimsToDT(StockSum)\n    GuiControl, Focus, Dbc\n\n    FileOpen(\"Sets\\Message.Request\", \"w\").Write(\"Update_Definitions\").Close()\n    FileRead, Reciever, Sets\\GUISell.Hwnd\n    SendMessage, 0x1000,,,, ahk_id %Reciever%\n    Return, 1\n}\n\nModify() {\n    Global Row, _177, _178, StockSum\n    GuiControlGet, Dbc,, Dbc\n    LV_GetText(Bc, Row, 1)\n    ExistedDef := \"\"\n    Loop, Files, % \"Sets\\Def\\\" Dbc \".def\", R\n    {\n        ExistedDef := A_LoopFileFullPath\n    }\n\n    If (Bc != Dbc) && (ExistedDef != \"\") {\n        FileRead, Content, % ExistedDef\n        MsgBox, 48, % _177, % _178 \"`n`n\" Dbc \" = \" StrSplit(Content, \";\")[1]\n        Return, 0\n    }\n\n    ExistedDef := \"\"\n    Loop, Files, % \"Sets\\Def\\\" Bc \".def\", R\n    {\n        ExistedDef := A_LoopFileFullPath\n    }\n\n    If (ExistedDef != \"\") {\n        SplitPath, % ExistedDef,, WD\n        WD .= \"\\\"\n    } Else {\n        GuiControlGet, Group,, Group\n        WD := (Group = \"ALL\") ? \"Sets\\Def\\\" : \"Sets\\Def\\\" Group \"\\\"\n    }\n\n    GuiControlGet, Dnm,, Dnm\n    GuiControlGet, Dbp,, Dbp\n    GuiControlGet, Dsp,, Dsp\n    GuiControlGet, Dst,, Dst\n    \n    FileDelete, % WD Bc \".def\"\n    FileOpen(WD Dbc \".def\", \"w\").Write(Dnm \";\" Dbp \";\" Dsp \";\" Dst).Close()\n    \n    LV_GetText(St, Row, 5)\n    LV_GetText(Sp, Row, 4)\n    StockSum -= Trim(St, \"[]\") * Sp\n    StockSum += Dsp * Dst\n    LV_Modify(Row,, Dbc, Dnm, Dbp, Dsp, \"[\" Dst \"]\")\n\n    GuiControl,, Dbc\n    GuiControl,, Dnm\n    GuiControl,, Dbp\n    GuiControl,, Dsp\n    GuiControl,, Dst\n    GuiControl,, StockSum, % StockSum \" \" ConvertMillimsToDT(StockSum)\n    GuiControl, Focus, Dbc\n\n    FileOpen(\"Sets\\Message.Request\", \"w\").Write(\"Update_Definitions\").Close()\n    FileRead, Reciever, Sets\\GUISell.Hwnd\n    SendMessage, 0x1000,,,, ahk_id %Reciever%\n    Return, 1\n}\n\nVerifyInputs() {\n    Global _181, _182, _177, _178\n    GuiControlGet, Dbc,, Dbc\n    If (Dbc = \"\") {\n        GuiControl, Focus, Dbc\n        ShakeControl(\"Dbc\")\n        Return, 0\n    }\n    GuiControlGet, Dnm,, Dnm\n    If (Dnm = \"\") {\n        GuiControl, Focus, Dnm\n        ShakeControl(\"Dnm\")\n        Return, 0\n    }\n    If InStr(Dnm, \";\") {\n        GuiControl, Focus, Dnm\n        ShakeControl(\"Dnm\")\n        Return, 0\n    }\n    GuiControlGet, Dbp,, Dbp\n    If (Dbp = \"\") {\n        GuiControl, Focus, Dbp\n        ShakeControl(\"Dbp\")\n        Return, 0\n    }\n    GuiControlGet, Dsp,, Dsp\n    If (Dsp = \"\") {\n        GuiControl, Focus, Dsp\n        ShakeControl(\"Dsp\")\n        Return, 0\n    }\n    GuiControlGet, Dst,, Dst\n    If (Dst = \"\") {\n        GuiControl, Focus, Dst\n        ShakeControl(\"Dst\")\n        Return, 0\n    }\n    Return, 1\n}\n\nShakeControl(Ctrl) {\n    GuiControlGet, Pos, Pos, % Ctrl\n    Loop, 5 {\n        GuiControl, Move, % Ctrl, % \"x\" PosX -= 4\n        Sleep, 50\n        GuiControl, Move, % Ctrl, % \"x\" PosX += 4\n        Sleep, 50\n    }\n}"
  },
  {
    "path": "GUIDefine_Hotkeys.ahk",
    "content": "#If WinActive(\"ahk_id \" Main)\n    Enter::\n        If !VerifyInputs()\n            Return\n        If (!EditModOn) {\n            Add()\n            Return\n        }\n        If Modify() {\n            EditModOn := 0\n        }\n    Return\n\n    Delete::\n        If (Row := LV_GetNext()) {\n            LV_GetText(Bc, Row, 1)\n            LV_GetText(St, Row, 5)\n            LV_GetText(Sp, Row, 4)\n        \n            LV_Delete(Row)\n\n            ExistedDef := \"\"\n            Loop, Files, % \"Sets\\Def\\\" Bc \".def\", R\n            {\n                ExistedDef := A_LoopFileFullPath\n            }\n\n            If (ExistedDef != \"\")\n                FileDelete, % ExistedDef\n\n            GuiControlGet, StockSum\n            StockSum -= Trim(St, \"[]\") * Sp\n            GuiControl,, StockSum, % StockSum \" \" ConvertMillimsToDT(StockSum)\n\n            EditModOn := 0\n        }\n    Return\n\n    Esc::\n        GuiControl,, Dbc\n        GuiControl,, Dnm\n        GuiControl,, Dbp\n        GuiControl,, Dsp\n        GuiControl,, Dst\n        EditModOn := 0\n        GuiControl, Focus, Dbc\n        LoadProducts()\n    Return\n    \n    ^!LButton::\n        MouseClick\n        GoSub, FillForms\n    Return\n    \n    ^F::\n        GuiControlGet, Group,, Group\n        GuiControlGet, Dbc,, Dbc\n        GuiControlGet, Dnm,, Dnm\n        GuiControlGet, Dbp,, Dbp\n        GuiControlGet, Dsp,, Dsp\n        GuiControlGet, Dst,, Dst\n        If (Group = \"ALL\") {\n            If (Dbc != \"\") || (Dnm != \"\") || (Dst != \"\") || (Dbp != \"\") || (Dsp != \"\") {\n                LV_Delete()\n                Loop, Files, Sets\\Def\\*.def, R\n                {\n                    FileRead, Content, % A_LoopFileFullPath\n                    Content := StrSplit(Content, \";\")\n                    If InStr(StrReplace(A_LoopFileName, \".def\"), Dbc) && InStr(Content[1], Dnm) && InStr(Content[2], Dbp) && InStr(Content[3], Dsp) && InStr(Content[4], Dst) {\n                        LV_Add(, StrReplace(A_LoopFileName, \".def\"), Content[1], Content[2], Content[3], \"[\" (Content[4] != \"\" ? Content[4] : 0) \"]\")\n                    }\n                }\n            }\n        } Else {\n            If (Dbc != \"\") || (Dnm != \"\") || (Dst != \"\") || (Dbp != \"\") || (Dsp != \"\") {\n                LV_Delete()\n                Loop, Files, Sets\\Def\\%Group%\\*.def\n                {\n                    FileRead, Content, % A_LoopFileFullPath\n                    Content := StrSplit(Content, \";\")\n                    If InStr(StrReplace(A_LoopFileName, \".def\"), Dbc) && InStr(Content[1], Dnm) && InStr(Content[2], Dbp) && InStr(Content[3], Dsp) && InStr(Content[4], Dst) {\n                        LV_Add(, StrReplace(A_LoopFileName, \".def\"), Content[1], Content[2], Content[3], \"[\" (Content[4] != \"\" ? Content[4] : 0) \"]\")\n                    }\n                }\n            }\n        }\n    Return\n#If"
  },
  {
    "path": "GUIDefine_Labels.ahk",
    "content": "DelGroup:\n    GuiControlGet, Group,, Group\n    If (Group != \"ALL\") {\n        Msgbox, 36,% _187, % _194 \" \" Group \" ?\"\n        IfMsgBox, Yes\n        {\n            Msgbox, 36,% _187, % _174\n            IfMsgBox, Yes\n            {\n                FileRemoveDir, % \"Sets\\Def\\\" Group, 1\n                LoadGroups()\n            }\n        }\n    }\nReturn\n\nFillForms:\n    If (Row := LV_GetNext()) {\n        LV_GetText(Dbc, Row, 1)\n        LV_GetText(Dnm, Row, 2)\n        LV_GetText(Dbp, Row, 3)\n        LV_GetText(Dsp, Row, 4)\n        LV_GetText(Dst, Row, 5)\n\n        GuiControl,, Dbc, % Dbc\n        GuiControl,, Dnm, % Dnm\n        GuiControl,, Dbp, % Dbp\n        GuiControl,, Dsp, % Dsp\n        GuiControl,, Dst, % Trim(Dst, \"[]\")\n    }\nReturn\n\nAddGroup:\n    InputBox, Groupname, % _184, % _185,, 300, 130\n    If !InStr(FileExist(\"Sets\\Def\\\" Groupname), \"D\") && (Groupname != \"ALL\") {\n        FileCreateDir, % \"Sets\\Def\\\" Groupname\n        If (!ErrorLevel) {\n            GuiControl,, Group, % Groupname\n        }\n    }\n    Groupname   := Groupname = \"ALL\" ? \"\" : Groupname \"\\\"\n    Row         := 0\n    While (Row := LV_GetNext(Row)) {\n        LV_GetText(Bc, Row, 1)\n        Loop, Files, % \"Sets\\Def\\\" Bc \".def\", R\n            Src := A_LoopFileFullPath\n        FileMove, % Src, % \"Sets\\Def\\\" Groupname Bc \".def\"\n    }\n    GuiControl, ChooseString, Group, % \"|\" (Groupname = \"\" ? \"ALL\" : SubStr(Groupname, 1, -1))\nReturn\n\nResetAll:\n    GuiControlGet, Group,, Group\n    If (Group = \"ALL\") {\n        Loop, Files, Sets\\Def\\*.def, R\n        {\n            FileRead, Content, % A_LoopFileFullPath\n            Content := StrSplit(Content, \";\")\n            FileOpen(A_LoopFileFullPath, \"w\").Write(Content[1] \";\" Content[2] \";\" Content[3] \";0\").Close()\n        }\n        StockSum := LoadProducts()\n    } Else {\n        Loop, Files, Sets\\Def\\%Group%\\*.def\n        {\n            FileRead, Content, % A_LoopFileFullPath\n            Content := StrSplit(Content, \";\")\n            FileOpen(A_LoopFileFullPath, \"w\").Write(Content[1] \";\" Content[2] \";\" Content[3] \";0\").Close()\n        }\n        GoSub, DisplayGroup\n    }\n    \nReturn\n\nDisplayGroup:\n    GuiControlGet, Group,, Group\n    GuiControl,, StockSum\n    If (GROUP != \"ALL\") {\n        LV_Delete(), Files := \"\"\n        Loop, Files, % \"Sets\\Def\\\" Group \"\\*.def\"\n        {\n            Bc := StrReplace(A_LoopFileName, \".def\")\n            Files .= Files != \"\" ? \"`n\" Bc : Bc\n        }\n    \n        Sort, Files, N\n        StockSum := 0\n        \n        Loop, Parse, Files, `n\n        {\n            FileRead, Content, % \"Sets\\Def\\\" Group \"\\\" A_LoopField \".def\"\n            Content := StrSplit(Content, \";\"), Content[4] != \"\" ? StockSum += Content[4] * Content[3] : 0\n            LV_Add(, A_LoopField, Content[1], Content[2], Content[3], \"[\" (Content[4] != \"\" ? Content[4] : 0) \"]\")\n            GuiControl,, StockSum, % StockSum \" \" ConvertMillimsToDT(StockSum)\n        }\n    } Else {\n        StockSum := LoadProducts()\n    }\nReturn\n\nEdit:\n    If (Row := LV_GetNext()) {\n        LV_GetText(Dbc, Row, 1)\n        LV_GetText(Dnm, Row, 2)\n        LV_GetText(Dbp, Row, 3)\n        LV_GetText(Dsp, Row, 4)\n        LV_GetText(Dst, Row, 5)\n\n        GuiControl,, Dbc, % Dbc\n        GuiControl,, Dnm, % Dnm\n        GuiControl,, Dbp, % Dbp\n        GuiControl,, Dsp, % Dsp\n        GuiControl,, Dst, % Trim(Dst, \"[]\")\n\n        EditModOn := 1\n    }\nReturn\n\nGuiClose:\n    IniDelete, Sets\\PID.ini, PID, GUIDefine\nExitApp"
  },
  {
    "path": "GUIDetails.ahk",
    "content": "#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\Class_CtlColors.ahk\n#Include, Lib\\Classes\\Class_ImageButton.ahk\n#Include, Lib\\Classes\\Class_GDIplus.ahk\n\n#Include, Lib\\Language.ahk\n\nFolderSet()\n\nGui, Color, 0xD8D8AD\nGui, -MinimizeBox\nGui, Font, s15 Bold, Calibri\nGui, Margin, 5, 5\nGui, Add, ListBox, w200 h250 0x100 vReInLB gDisplayDetails AltSubmit\nGui, Add, Edit, xp+210 yp w500 h200 ReadOnly vDInfo -E0x200 Border -VScroll\nGui, Add, Edit, xp yp+212 ReadOnly w500 vOverAll -E0x200 Border cGreen Center h38\nGui, Font, s12 Underline\nGui, Add, CheckBox, xm+600 yp+45 vShowMore gShowMore, % _170\nGui, Font, Norm\nGui, Font, s15 Bold\nGui, Add, Text, xm yp+30, % _123 \":\"\nGui, Add, Edit, xp yp+30 w300 vRemise ReadOnly -E0x200 Border cGreen\nGui, Add, Text, xp yp+35, % _124 \":\"\nGui, Add, Edit, xp yp+30 w710 vClient -E0x200 Border ReadOnly cBlue\nGui, Add, Text, xp yp+35 wp, % _125 \":\"\nGui, Add, Edit, xp yp+30 wp vSellDesc cBlue r10 -E0x200 Border ReadOnly -VScroll\nGui, Show, h290\n\nIf (A_Args[1]) {\n    FileRead, Content, %1%\n\n    Content := StrSplit(Content, \"> \")\n    Sells   := StrSplit(Content[2], \"|\")\n\n    Array := {}, OverAll := 0\n    For Each, One in Sells {\n        Section := StrSplit(One, \";\")\n        Array[A_Index] := [Section[1]       ; Barcode\n                         , Section[2]       ; Name\n                         , Section[3]       ; SellStr\n                         , Section[4]       ; Sells\n                         , Section[5]       ; BuyStr\n                         , Section[6]       ; Buys\n                         , Section[7]]      ; Profit\n        GuiControl,, ReInLB, % Array[A_Index][2]\n        OverAll += Section[7]\n    }\n\n    GuiControl,, OverAll, % OverAll \" \" ConvertMillimsToDT(OverAll)\n\n    If (Content[4]) {\n        AddInfo := StrSplit(Content[4], \";\")\n        If (AddInfo[1])\n        GuiControl,, Remise, % AddInfo[1] \" %\"\n        If (AddInfo[2])\n        GuiControl,, Client, % AddInfo[2]\n        If (AddInfo[3])\n        GuiControl,, SellDesc, % AddInfo[3]\n    }\n\n    GuiControl, Choose, ReInLB, |1\n}\nReturn\n\n#Include, GUIDetails_Labels.ahk\n#Include, GUIDetails_Functions.ahk"
  },
  {
    "path": "GUIDetails_Functions.ahk",
    "content": "ConvertMillimsToDT(Value, Sign := \"\") {\n    If (Value = \"...\" || !Value)\n        Return\n    ValueArr := StrSplit(Value / 1000, \".\")\n    Return, \"(\" (Sign ? \" \" Sign \" \" : \"\") ValueArr[1] (ValueArr[2] ? \".\" RTrim(ValueArr[2], 0) : \"\") \" DT)\"\n}\n\nFolderSet() {\n    Array := [ \"Curr\"\n             , \"Sets\"\n             , \"Sets\\Def\"\n             , \"Valid\"\n             , \"Dump\"\n             , \"Kr\"\n             , \"CKr\" \n             , \"Unvalid\" \n             , \"Hist\" ]\n\n    For Every, Folder in Array {\n        If !FolderExist(Folder) {\n            FileCreateDir, % Folder\n        }\n    }\n}\n\nFolderExist(Folder) {\n    Return InStr(FileExist(Folder), \"D\")\n}"
  },
  {
    "path": "GUIDetails_Labels.ahk",
    "content": "GuiClose:\nExitApp\n\nDisplayDetails:\n    GuiControlGet, ReInLB,, ReInLB\n    If (ReInLB) {\n        GuiControl,, DInfo, % _27 \": \" Array[ReInLB][1]\n                       . \"`n\" _38 \": \" Array[ReInLB][2]\n                       . \"`n\" _39 \": \" Array[ReInLB][3] \" = \" Array[ReInLB][4]\n                       . \"`n\" _40 \": \" Array[ReInLB][5] \" = \" Array[ReInLB][6]\n                       . \"`n\" _41 \": \" Array[ReInLB][7]\n    }\n    \nReturn\n\nShowMore:\n    GuiControlGet, ShowMore,, ShowMore\n    If (ShowMore) {\n        Gui, Show, h705 Center\n        GuiControl,, ShowMore, % _171\n    } Else {\n        Gui, Show, h290 Center\n        GuiControl,, ShowMore, % _170\n    }\nReturn"
  },
  {
    "path": "GUIKridi.ahk",
    "content": "#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\Class_CtlColors.ahk\n#Include, Lib\\Classes\\Class_ImageButton.ahk\n#Include, Lib\\Classes\\Class_GDIplus.ahk\n\n#Include, Lib\\Language.ahk\n\nFolderSet()\n\nGui, -MinimizeBox\nGui, Color, 0xD8D8AD\nGui, Margin, 10, 10\nGui, Font, s15 Bold, Calibri\nGui, Add, Edit, w200 vKName -E0x200 Border gCheckKExist\nGui, Font, s13\nGui, Add, Button, xm+210 ym w100 h33 HwndHCtrl gEnter, % _36\nImageButton.Create(HCtrl,[[0, 0x2ECB52, , 0x000000, 0, , 0x28A745, 2]\n                        , [0, 0x31E059, , 0x000000, 0, , 0x28A745, 2]\n                        , [0, 0x37F462, , 0x000000, 0, , 0x28A745, 2]\n                        , [0, 0xD8D8AD, , 0xB2B2B2, 0, , 0xB2B2B2, 2]]* )\nGui, Font, s15\nGui, Add, ListBox, w200 xm ym+40 vKLB h450 gDisplayThisKridi -Multi\nGui, Add, ListView, xm+210 ym+40 w760 h435 Grid cBlue HwndHCtrl -Hdr, Col1|Col2|Col3|Col4|Col5\n\nLV_ModifyCol(1, 0)\nLV_ModifyCol(2, 190)\nLV_ModifyCol(3, 190 \" Center\")\nLV_ModifyCol(4, 190 \" Center\")\nLV_ModifyCol(5, 190 \" Center\")\nGui, Add, Edit, xm+550 ym w200 h33 -E0x200 Border ReadOnly vTotal Center\nGui, Add, Edit, xm+768 ym w200 h33 -E0x200 Border ReadOnly vThisTotal Center cRed HwndE\nCtlColors.Attach(E, \"FFFFFF\", \"000000\")\n\nGui, Show\nLoadKridiUsers()\nReturn\n\n#Include, GUIKridi_Functions.ahk\n#Include, GUIKridi_Labels.ahk\n#Include, GUIKridi_Hotkeys.ahk"
  },
  {
    "path": "GUIKridiM.ahk",
    "content": "#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\Class_CtlColors.ahk\n#Include, Lib\\Classes\\Class_ImageButton.ahk\n#Include, Lib\\Classes\\Class_GDIplus.ahk\n\n#Include, Lib\\Language.ahk\n\nFolderSet()\n\nIf !Level := LogIn(AdminName := A_Args[1], AdminPass := A_Args[2]) {\n    FileRead, Reciever, Sets\\Login.Hwnd\n    FileOpen(\"Sets\\Login.Request\", \"w\").Write(\"Run|\" A_ScriptFullPath).Close()\n    SendMessage, 0x1000,,,, ahk_id %Reciever%\n    Sleep, 1000\n    MsgBox, 16, % _112, % _114\n    ExitApp\n}\n\nGui, +HwndMain +Resize\nGui, Add, Pic, % \"x0 y0\", Img\\BG.png\nGui, Margin, 10, 10\nGui, Color, 0x7D7D3A\nGui, Font, s14 Bold, Calibri\n\nButtonTheme := [[3, 0x80FF80, 0x5ABB5A, 0x000000, 2,, 0x008000, 1]\n              , [3, 0x44DB44, 0x2F982F, 0x000000, 2,, 0x008000, 1]\n              , [3, 0x1AB81A, 0x107410, 0x000000, 2,, 0x008000, 1]\n              , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]\n\nButtonTheme2 := [[3, 0xFF6F6F, 0xBC5454, 0x000000, 2,, 0xFF0000, 1]\n               , [3, 0xDC6262, 0x9C4545, 0x000000, 2,, 0xFF0000, 1]\n               , [3, 0xBF5454, 0x8A3C3C, 0x000000, 2,, 0xFF0000, 1]\n               , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0xFF0000, 1]]\n               \nButtonTheme3 := [[3, 0xFFC080, 0xBE8F60, 0x000000, 2,, 0xFF8000, 1]\n               , [3, 0xE0AA72, 0xA47C53, 0x000000, 2,, 0xFF8000, 1]\n               , [3, 0xC89664, 0x906D48, 0x000000, 2,, 0xFF8000, 1]\n               , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0xFF8000, 1]]\n\nButtonTheme4 := [[3, 0x96C864, 0x739A4C, 0x000000, 2,, 0x80FF00, 1]\n               , [3, 0x8CBB5D, 0x658643, 0x000000, 2,, 0x80FF00, 1]\n               , [3, 0x79A051, 0x56733A, 0x000000, 2,, 0x80FF00, 1]\n               , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x80FF00, 1]]\n\nGui, Add, Button, % \"xm+5 ym+20 gAdd HwndHCtrl w190 h60\", % _198\nImageButton.Create(HCtrl, ButtonTheme* )\n\nGui, Font, s16\nGui, Add, Edit, % \"xm+5 ym+90 wp r2 vAllKridi -E0x200 Border Center ReadOnly HwndHCtrl -VScroll\"\nCtlColors.Attach(HCtrl, \"EAEAB5\")\n\nGui, Font, s14\nqw := ((A_ScreenWidth - 255) // 3)\nGui, Add, ListBox, % \"wp h\" A_ScreenHeight - 340 \" vKLB HwndHCtrl Multi gShowKridiInfo 0x100\"\nCtlColors.Attach(HCtrl, \"EAEAB5\")\nGui, Font, s16\nGui, Add, Button, % \"gDelete HwndHCtrl wp h60\", % _191\nImageButton.Create(HCtrl, ButtonTheme2* )\n\nGui, Font, s14\nGui, Add, ListView, % \"xm+421 ym+20 w\" qw * 3 - 391 \" h\" A_ScreenHeight - 200 \" vLV\", % \"|\" _38 \"|\" _68 \"|\" _39\n\nLV_ModifyCol(1, \"0 Center\")\nLV_ModifyCol(2, qw - 130)\nLV_ModifyCol(3, qw - 130)\nLV_ModifyCol(4, qw - 130)\n\nGui, Font, s16\nGui, Add, Edit, % \"xp-201 yp w190 r2 vThisKridi -E0x200 Border Center ReadOnly HwndHCtrl -VScroll\"\nCtlColors.Attach(HCtrl, \"FFC080\")\n\nGui, Font, s14\nGui, Add, ListBox, % \"wp h\" A_ScreenHeight - 425 \" vKDate gSelectFromLv AltSubmit HwndHCtrl Multi 0x100\"\nCtlColors.Attach(HCtrl, \"FFC080\")\n\nGui, Font, s16\nGui, Add, Edit, % \"wp r2 vSubThisKridi -E0x200 Border Center ReadOnly HwndHCtrl -VScroll\"\nCtlColors.Attach(HCtrl, \"FFC080\")\n\nGui, Add, Edit, % \"wp vKridi -E0x200 Border Center HwndHCtrl -VScroll Number\"\nCtlColors.Attach(HCtrl, \"FFFFFF\")\n\nGui, Add, Button, % \"wp h30 HwndHCtrl gKridiOut\", % _29\nImageButton.Create(HCtrl, ButtonTheme3*)\n\nGui, Add, Edit, % \"xm+\" qw * 3 - 391 + 12 + 421 \" ym+20 wp r2 vPay -E0x200 Border Center ReadOnly HwndHCtrl -VScroll\"\nCtlColors.Attach(HCtrl, \"96C864\")\n\nGui, Font, s14\nGui, Add, ListBox, % \"wp h\" A_ScreenHeight - 425 \" vPDate HwndHCtrl AltSubmit gShowPayVal 0x100\"\nCtlColors.Attach(HCtrl, \"96C864\")\n\nGui, Font, s16\nGui, Add, Edit, % \"wp r2 vThisPay -E0x200 Border Center ReadOnly HwndHCtrl -VScroll\"\nCtlColors.Attach(HCtrl, \"96C864\")\n\nGui, Add, Edit, % \"wp vPayBack -E0x200 Border Center HwndHCtrl -VScroll Number\"\nCtlColors.Attach(HCtrl, \"FFFFFF\")\n\nGui, Add, Button, % \"wp h30 HwndHCtrl gPayOut\", % _186\nImageButton.Create(HCtrl, ButtonTheme4*)\n\nGui, Font, s20\nGui, Add, Edit, % \"vBalance xm+421 y\" A_ScreenHeight - 160 \" w\" qw * 3 - 391 \" -E0x200 Border Center HwndHCtrl ReadOnly\"\nCtlColors.Attach(HCtrl, \"D8D8AD\", \"FF0000\")\n\nGui, Font, s12\nLevels := [\"Admin\", \"User\"]\nGui, Add, StatusBar\nSB_SetParts(10, 200, 200)\nSB_SetText(_206 \": \" AdminName, 2)\nSB_SetText(_207 \": \" Levels[Level], 3)\n\nGui, Show, Maximize, Review GUI\nThemeAdd()\nLoadKridis()\nReturn\n\n#Include, GUIKridiM_Hotkeys.ahk\n#Include, GUIKridiM_Functions.ahk\n#Include, GUIKridiM_Labels.ahk"
  },
  {
    "path": "GUIKridiM_Functions.ahk",
    "content": "FolderSet() {\n    Array := [ \"Curr\"\n             , \"Sets\"\n             , \"Sets\\Def\"\n             , \"Valid\"\n             , \"Dump\"\n             , \"Kr\"\n             , \"CKr\" \n             , \"Unvalid\" \n             , \"Hist\" ]\n\n    For Every, Folder in Array {\n        If !FolderExist(Folder) {\n            FileCreateDir, % Folder\n        }\n    }\n}\n\nFolderExist(Folder) {\n    Return InStr(FileExist(Folder), \"D\")\n}\n\nLogIn(Username, Password) {\n    If (FileExist(\"Sets\\Acc.chu\")) {\n        Account := {}\n        FileRead, RawAccount, Sets\\Acc.chu\n        TextAccount := b64Decode(RawAccount)\n        \n        For Each, User in StrSplit(TextAccount, \",\") {\n            LOG := StrSplit(User, \"|\")\n            Account[LOG[1]] := [LOG[2], LOG[3]]\n        }\n        \n        If (Account[Username][1] = Password) {\n            If (Account[Username][2] = \"Admin\")\n                Return, 1\n            Else If (Account[Username][2] = \"User\")\n                Return, 2\n        }\n    }\n    Return, 0\n}\n\nb64Encode(string) {\n    VarSetCapacity(bin, StrPut(string, \"UTF-8\")) && len := StrPut(string, &bin, \"UTF-8\") - 1 \n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    VarSetCapacity(buf, size << 1, 0)\n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    return StrGet(&buf)\n}\n\nb64Decode(string) {\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        throw Exception(\"CryptStringToBinary failed\", -1)\n    VarSetCapacity(buf, size, 0)\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        throw Exception(\"CryptStringToBinary failed\", -1)\n    return StrGet(&buf, size, \"UTF-8\")\n}\n\nThemeAdd() {\n    Loop, 5 {\n        Gui, Add, Text, % \"y0 x\" 208 + A_Index * 2 \" w1 h\" A_ScreenHeight \" HwndHCtrl\"\n        CtlColors.Attach(HCtrl, \"7D7D64\")\n    }\n}\n\nConvertMillimsToDT(Value, Sign := \"\") {\n    If (Value = \"...\" || !Value)\n        Return\n    ValueArr := StrSplit(Value / 1000, \".\")\n    Return, \"[\" (Sign ? Sign \" \" : \"\") ValueArr[1] (ValueArr[2] ? \".\" RTrim(ValueArr[2], 0) : \"\") \" DT]\"\n}\n\nLoadKridis(ChooseName := \"\") {\n    GuiControl,, KLB, |\n    GuiControl,, SelectFromLv, |\n    LV_Delete()\n\n    GuiControl,, SubThisKridi\n    GuiControl,, ThisKridi\n    GuiControl,, AllKridi\n    GuiControl,, ThisPay\n    GuiControl,, PayBack\n    GuiControl,, Pay\n    GuiControl,, PDate\n    GuiControl,, Balance\n    \n    AK := 0\n    Loop, Files, Kr\\*, D\n    {\n        Name := A_LoopFileName\n        Loop, Files, % \"Kr\\\" Name \"\\*.sell\"\n        {\n            FileRead, Content, % A_LoopFileFullPath\n            AK += StrSplit(StrSplit(Content, \"> \")[3], \";\")[1]\n        }\n        GuiControl,, KLB, % Name\n        GuiControl,, AllKridi, % AK \"`n\" ConvertMillimsToDT(AK)\n    }\n    \n    If (ChooseName = \"\")\n        GuiControl, Choose, KLB, |1\n    Else {\n        GuiControl, ChooseString, KLB, |%ChooseName%\n    }\n}\n\nKridiDates(KLB) {\n    LV_Delete()\n    GuiControl,, KDate, |\n\n    DateRow := {}, ItemSum := {}, I := 0, TK := 0\n    Loop, Files, % \"Kr\\\" KLB \"\\*.sell\"\n    {\n        FileRead, Content, % A_LoopFileFullPath\n        Content := StrSplit(Content, \"> \")\n        Date    := StrSplit(Content[1], \"|\")[2]\n        \n        DateRow[++I]  := []\n        ItemSum[I]    := StrSplit(Content[3], \";\")[1]\n        TK      += ItemSum[I]\n        \n        GuiControl,, ThisKridi, % TK \"`n\" ConvertMillimsToDT(TK)\n        GuiControl,, KDate, % Date\n        \n        Sells   := StrSplit(Trim(Content[2], \"|\"), \"|\")\n        \n        For Every, Sell in Sells {\n            SubSell := StrSplit(Sell, \";\")\n            Row := LV_Add(, SubSell[1], SubSell[2], SubSell[3], SubSell[4])\n            DateRow[I].Push(Row)\n        }\n    }\n    GuiControl,, SubThisKridi\n    Return, [DateRow, ItemSum, TK]\n}\n\nPayDates(KLB) {\n    P := 0, PayVal := {}\n    GuiControl,, PDate, |\n    GuiControl,, Pay\n    GuiControl,, ThisPay\n    Loop, Files, % \"Kr\\\" KLB \"\\*.pay\"\n    {\n        FileRead, Content, % A_LoopFileFullPath\n        P               += Content\n        PayVal[A_Index] := Content\n        \n        GuiControl,, Pay, % P \"`n\" ConvertMillimsToDT(P)\n        \n        FormatTime, oTime, % StrReplace(A_LoopFileName, \".pay\"), yyyy/MM/dd HH:mm:ss\n        GuiControl,, PDate, % oTime\n    }\n    Return, [PayVal, P]\n}"
  },
  {
    "path": "GUIKridiM_Hotkeys.ahk",
    "content": "#If WinActive(\"ahk_id \" Main)\n    Delete::\n        GuiControlGet, KLB,, KLB\n        If (KLB) {\n            MsgBox, 36, % _187, % KLB \" \" _190\n            IfMsgBox, Yes\n            {\n                MsgBox, 36, % _187, % _189\n                IfMsgBox, Yes\n                {\n                    FileMoveDir, % \"Kr\\\" KLB, % \"CKr\\\", 1\n                    LoadKridis()\n                }\n            }\n        }\n    Return\n#If"
  },
  {
    "path": "GUIKridiM_Labels.ahk",
    "content": "ShowKridiInfo:\n    GuiControlGet, KLB,, KLB\n    If (KLB) {\n        DateRow := KridiDates(KLB)\n        PayVal := PayDates(KLB)\n        Ba := DateRow[3] - PayVal[2]\n        GuiControl,, Balance, % KLB \": \" Ba \" \" ConvertMillimsToDT(Ba)\n    }\nReturn\n\nPayOut:\n    GuiControlGet, PayBack,, PayBack\n    If (PayBack) {\n        GuiControlGet, KLB,, KLB\n        MsgBox, 36, % _187, % KLB \" \" _188 \" \" PayBack \" \" ConvertMillimsToDT(PayBack)\n        IfMsgBox, Yes\n        {\n            MsgBox, 36, % _187, % _189\n            IfMsgBox, Yes\n            {\n                FileAppend, % PayBack, % \"Kr\\\" KLB \"\\\" A_Now \".pay\"\n                GuiControl,, PayBack\n                PayVal := PayDates(KLB)\n                Ba := DateRow[3] - PayVal[2]\n                GuiControl,, Balance, % KLB \": \" Ba \" \" ConvertMillimsToDT(Ba)\n            }\n        }\n        \n    }\nReturn\n\nKridiOut:\n    GuiControlGet, Kridi,, Kridi\n    If (Kridi > 0) {\n        GuiControlGet, KLB,, KLB\n        MsgBox, 36, % _187, % KLB \" \" _197 \" \" Kridi \" \" ConvertMillimsToDT(PayBack)\n        IfMsgBox, Yes\n        {\n            MsgBox, 36, % _187, % _189\n            IfMsgBox, Yes\n            {\n                FormatTime, OutTime, % Now := A_Now, yyyy/MM/dd HH:mm:ss\n                FileAppend, % AdminName \"|\" OutTime \"> > \" Kridi \";\" Kridi \";0\", % \"Kr\\\" KLB \"\\\" A_Now \".sell\"\n                GuiControl,, Kridi\n                DateRow := KridiDates(KLB)\n                Ba := DateRow[3] - PayVal[2]\n                GuiControl,, Balance, % KLB \": \" Ba \" \" ConvertMillimsToDT(Ba)\n            }\n        }\n    }\nReturn\n\nSelectFromLV:\n    GuiControlGet, KDate,, KDate\n    If (!KDate)\n        Return\n    Loop, % LV_GetCount() {\n        LV_Modify(A_Index, \"-Select\")\n    }\n    If (!InStr(KDate, \"|\")) {\n        For Each, Row in DateRow[1][KDate] {\n            LV_Modify(Row, \"Select\")\n        }\n        GuiControl, Focus, LV\n    } Else {\n        For Each, Date in StrSplit(KDate, \"|\") {\n            For Each, Row in DateRow[1][Date] {\n                LV_Modify(Row, \"Select\")\n            }\n            GuiControl, Focus, LV\n        }\n    }\n    \n    GuiControl,, SubThisKridi, % DateRow[2][KDate] \"`n\" ConvertMillimsToDT(DateRow[2][KDate])\nReturn\n\nShowPayVal:\n    GuiControlGet, PDate,, PDate\n    If (PDate) {\n        GuiControl,, ThisPay, % PayVal[1][PDate] \"`n\" ConvertMillimsToDT(PayVal[1][PDate])\n    }\nReturn\n\nAdd:\n    InputBox, PersonName, Name?, Person Name?,, 300, 130\n    Validity := ErrorLevel\n    If (Validity = 0) {\n        If (PersonName != \"\") && (PersonName ~= \"\\b\\w+\\b\") && !InStr(FileExist(\"Kr\\\" PersonName), \"D\") {\n            FileCreateDir, % \"Kr\\\" PersonName\n            LoadKridis(PersonName)\n        } Else {\n            MsgBox, 16, % _13, % _199\n        }\n    }\nReturn\n\nKUpdateVal:\n\nReturn\n\nGUIClose:\n    IniDelete, Sets\\PID.ini, PID, GUIKridiM\nExitApp"
  },
  {
    "path": "GUIKridi_Functions.ahk",
    "content": "LoadKridiUsers() {\n    GuiControl, , KLB, |\n    Loop, Files, % \"Kr\\*\", D\n        GuiControl,, KLB, % A_LoopFileName\n\n    TotalValue := 0\n    Obj := FileOpen(\"Dump\\tmp.sell\", \"r\")\n    While !Obj.AtEOF() {\n        Line := Obj.ReadLine()\n        Col     := StrSplit(Line, \",\")\n        LV_Add(, Col[1], Col[2], Col[3], Col[4], Col[5])\n        TotalValue += Col[5]\n    }\n    Obj.Close()\n    GuiControl,, Total, % \"+\" TotalValue \" \" ConvertMillimsToDT(TotalValue, \"+\")\n}\n\nSetExplorerTheme(HCTL) {\n    If (DllCall(\"GetVersion\", \"UChar\") > 5) {\n        VarSetCapacity(ClassName, 1024, 0)\n        If DllCall(\"GetClassName\", \"Ptr\", HCTL, \"Str\", ClassName, \"Int\", 512, \"Int\") {\n            Return !DllCall(\"UxTheme.dll\\SetWindowTheme\", \"Ptr\", HCTL, \"WStr\", \"Explorer\", \"Ptr\", 0)\n        }\n    }\n   Return False\n}\n\nConvertMillimsToDT(Value, Sign := \"\") {\n    If (Value = \"...\" || !Value)\n        Return\n    ValueArr := StrSplit(Value / 1000, \".\")\n    Return, \"(\" (Sign ? \" \" Sign \" \" : \"\") ValueArr[1] (ValueArr[2] ? \".\" RTrim(ValueArr[2], 0) : \"\") \" DT)\"\n}\n\nFolderSet() {\n    Array := [ \"Curr\"\n             , \"Sets\"\n             , \"Sets\\Def\"\n             , \"Valid\"\n             , \"Dump\"\n             , \"Kr\"\n             , \"CKr\" \n             , \"Unvalid\" \n             , \"Hist\" ]\n\n    For Every, Folder in Array {\n        If !FolderExist(Folder) {\n            FileCreateDir, % Folder\n        }\n    }\n}\n\nFolderExist(Folder) {\n    Return InStr(FileExist(Folder), \"D\")\n}"
  },
  {
    "path": "GUIKridi_Hotkeys.ahk",
    "content": "#If WinActive(\"ahk_id \" Kridi)\n    Enter::\n        GuiControlGet, KName,, KName\n        If (KName = \"\")\n            GuiControlGet, KName,, KLB\n            \n        If (KName != \"\") {\n            FileOpen(\"Dump\\Kridi.sell\", \"w\").Write(KName).Close()\n            ;FileDelete, % \"Dump\\Kridi.sell\"\n            ExitApp\n        }\n    Return\n#If"
  },
  {
    "path": "GUIKridi_Labels.ahk",
    "content": "GuiClose:\n    FileDelete, % \"Dump\\Kridi.sell\"\nExitApp\n\nCheckKExist:\n    GuiControlGet, KName,, KName\n    GuiControl, Choose, KLB, 0\n    GuiControl, ChooseString, KLB, % \"|\" KName\nReturn\n\nDisplayThisKridi:\n    MaxValue := 0\n    GuiControlGet, KLB,, KLB\n    Loop, Files, % \"Kr\\\" KLB \"\\*.sell\"\n    {\n        FileRead, Content, % A_LoopFileFullPath\n        Content := StrSplit(Content, \"> \")[3]\n        MaxValue += StrSplit(Content, \";\")[1]\n    }\n    GuiControl,, ThisTotal, % MaxValue \" \" ConvertMillimsToDT(MaxValue)\nReturn"
  },
  {
    "path": "GUIReview.ahk",
    "content": "﻿#SingleInstance, Force\nSetBatchLines, -1\n#NoEnv\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\Class_CtlColors.ahk\n#Include, Lib\\Classes\\Class_ImageButton.ahk\n#Include, Lib\\Classes\\Class_GDIplus.ahk\n\n#Include, Lib\\Language.ahk\n\nFolderSet()\n\nIf !Level := LogIn(AdminName := A_Args[1], AdminPass := A_Args[2]) {\n    FileRead, Reciever, Sets\\Login.Hwnd\n    FileOpen(\"Sets\\Login.Request\", \"w\").Write(\"Run|\" A_ScriptFullPath).Close()\n    SendMessage, 0x1000,,,, ahk_id %Reciever%\n    Sleep, 1000\n    MsgBox, 16, % _112, % _114\n    ExitApp\n}\n\nGui, +HwndMain +Resize\nGui, Add, Pic, % \"x0 y0\", Img\\BG.png\nGui, Margin, 10, 10\nGui, Color, 0x7D7D3A\nGui, Font, s14 Bold Italic, Calibri\n\nButtonTheme := [[3, 0x80FF80, 0x5ABB5A, 0x000000, 2,, 0x008000, 1]\n              , [3, 0x44DB44, 0x2F982F, 0x000000, 2,, 0x008000, 1]\n              , [3, 0x1AB81A, 0x107410, 0x000000, 2,, 0x008000, 1]\n              , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]\n\nGui, Font, Norm\nGui, Font, s15 Bold\n\nqw := ((A_ScreenWidth - 255) / 4)\n\nGui, Add, Text, % \"xm+5 ym w190 vProfByProductText BackgroundTrans\", % _202 \":\"\nGui, Add, DDL, xp yp+30 wp vProfByProduct gShowTheInfo AltSubmit, % _203 \"||\" _204\n\nGui, Add, Text, wp vShowTheInfo BackgroundTrans, % _156 \":\"\nGui, Add, DDL, xp yp+30 wp vProfByName gShowTheInfo\n\nGui, Add, DateTime, w190 vBegin Center h30, yyyy/MM/dd\nGui, Add, DateTime, wp vEnd Center hp, yyyy/MM/dd\n\nGui, Font, Norm\nGui, Font, s13 Bold italic\n\nGui, Add, Button, wp gCheckTheListBox HwndHCtrl h30, % \"↓ \" _172\nImageButton.Create(HCtrl, ButtonTheme*)\n\nGui, Add, ListBox, % \"0x100 wp h\" A_ScreenHeight - 410 \" vDates HwndHCtrl gShowTheInfo Multi\"\nCtlColors.Attach(HCtrl, \"D8D8AD\", \"404000\")\n\nGui, Font, s12\nGui, Add, Edit, % \"xm+220 ym+10 w\" qw*2 \" vOverview -E0x200 HwndHCtrl\"\nCtlColors.Attach(HCtrl, \"000000\", \"FFFF00\")\n\nGui, Font, Norm\nGui, Font, s15 Bold\nGui, Add, Progress, % \"xm+\" A_ScreenWidth - 240 \" yp cC3C378 vPB w200 hp\", 0\nGui, Add, ListView, % \"xm+220 yp+40 w\" qw*4 \" h\" A_ScreenHeight - 200 \" Grid HwndHLV -Multi BackgroundE6E6E6 gShowDetails\", % _70 \"|\" _72 \"|\" _39 \"|\" _40 \"|\" _41 \"|Notused\"\nGlobal HLV\n\nLV_ModifyCol(1, 0)\nLV_ModifyCol(2, qw)\nLV_ModifyCol(3, qw)\nLV_ModifyCol(4, qw)\nLV_ModifyCol(5, qw)\n\nGui, Add, Edit, % \"xp+\" qw + 4 \" yp+\" A_ScreenHeight - 190 \" -E0x200 ReadOnly vSPr w\" qw - 4 \" Border HwndHCtrl Center\"\nCtlColors.Attach(HCtrl, \"EAEAB5\", \"000000\")\n\nGui, Add, Edit, % \"xp+\" qw \" yp -E0x200 ReadOnly vCPr wp Border HwndHCtrl Center\"\nCtlColors.Attach(HCtrl, \"EAEAB5\", \"FF0000\")\n\nGui, Add, Edit, % \"xp+\" qw \" yp -E0x200 ReadOnly vOAProfit wp Border HwndHCtrl Center\"\nCtlColors.Attach(HCtrl, \"EAEAB5\", \"008000\")\n\nGui, Add, Button, % \"xm+220 yp w\" qw \" hp vSinceBegin HwndHCtrl gCalculateAll\", % _85 \" ↑\"\nImageButton.Create(HCtrl, ButtonTheme*)\n\nGui, Add, Button, xm+5 yp w190 gChart vChart HwndHCtrl hp, % \"→ \" _173 \" ←\"\nImageButton.Create(HCtrl, ButtonTheme*)\n\nGui, Font, s12\nLevels := [\"Admin\", \"User\"]\nView := [\"Normal\", \"More Details\"]\nGui, Add, StatusBar\nSB_SetParts(10, 200, 200)\nSB_SetText(_206 \": \" AdminName, 2)\nSB_SetText(_207 \": \" Levels[Level], 3)\n\nGui, Show, Maximize, Review GUI\nThemeAdd()\n\nGlobal LVContent, Header := 1\nLoadAllSells()\nAnalyzeUsers()\nAnalyzeDates()\nGuiControl, Choose, Dates, |1\nReturn\n\n#Include, GUIReview_Hotkeys.ahk\n#Include, GUIReview_Functions.ahk\n#Include, GUIReview_Labels.ahk"
  },
  {
    "path": "GUIReview_Functions.ahk",
    "content": "FolderSet() {\n    Array := [ \"Curr\"\n             , \"Sets\"\n             , \"Sets\\Def\"\n             , \"Valid\"\n             , \"Dump\"\n             , \"Kr\"\n             , \"CKr\" \n             , \"Unvalid\" \n             , \"Hist\" ]\n\n    For Every, Folder in Array {\n        If !FolderExist(Folder) {\n            FileCreateDir, % Folder\n        }\n    }\n}\n\nFolderExist(Folder) {\n    Return InStr(FileExist(Folder), \"D\")\n}\n\nLogIn(Username, Password) {\n    If (FileExist(\"Sets\\Acc.chu\")) {\n        Account := {}\n        FileRead, RawAccount, Sets\\Acc.chu\n        TextAccount := b64Decode(RawAccount)\n        \n        For Each, User in StrSplit(TextAccount, \",\") {\n            LOG := StrSplit(User, \"|\")\n            Account[LOG[1]] := [LOG[2], LOG[3]]\n        }\n        \n        If (Account[Username][1] = Password) {\n            If (Account[Username][2] = \"Admin\")\n                Return, 1\n            Else If (Account[Username][2] = \"User\")\n                Return, 2\n        }\n    }\n    Return, 0\n}\n\nb64Encode(string) {\n    VarSetCapacity(bin, StrPut(string, \"UTF-8\")) && len := StrPut(string, &bin, \"UTF-8\") - 1 \n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    VarSetCapacity(buf, size << 1, 0)\n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    return StrGet(&buf)\n}\n\nb64Decode(string) {\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        throw Exception(\"CryptStringToBinary failed\", -1)\n    VarSetCapacity(buf, size, 0)\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        throw Exception(\"CryptStringToBinary failed\", -1)\n    return StrGet(&buf, size, \"UTF-8\")\n}\n\nSetExplorerTheme(HCTL) {\n    If (DllCall(\"GetVersion\", \"UChar\") > 5) {\n        VarSetCapacity(ClassName, 1024, 0)\n        If DllCall(\"GetClassName\", \"Ptr\", HCTL, \"Str\", ClassName, \"Int\", 512, \"Int\") {\n            Return !DllCall(\"UxTheme.dll\\SetWindowTheme\", \"Ptr\", HCTL, \"WStr\", \"Explorer\", \"Ptr\", 0)\n        }\n    }\n    Return False\n}\n\nThemeAdd() {\n    Loop, 5 {\n        Gui, Add, Text, % \"y0 x\" 208 + A_Index * 2 \" w1 h\" A_ScreenHeight \" HwndHCtrl\"\n        CtlColors.Attach(HCtrl, \"7D7D64\")\n    }\n}\n\nAddToList(File) {\n    FileRead, Content, % File\n    SplitPath, % File, OutFileName\n    Date := SubStr(OutFileName, 1, 8)\n    DataAll  := StrSplit(Content, \"> \")\n\n    DateUser := StrSplit(DataAll[1], \"|\")\n    If (DateUser.Length() = 2) && !LVContent[\"Users\"].HasKey(\"\" DateUser[1] \"\") {\n        LVContent[\"Users\"][\"\" DateUser[1] \"\"] := \"\"\n    }\n\n    Data     := StrSplit(DataAll[3], \";\")\n    If (Data[1] Data[2] Data[3] ~= \"\\b\\d+\\b\") {\n        Names := \"\", Items := {}\n        For Each, Prod in StrSplit(Trim(DataAll[2], \"|\"), \"|\") {\n            Info := StrSplit(Prod, \";\")\n            If !Items.HasKey(\"\" Info[1] \"\") {\n                Items[\"\" Info[1] \"\"] := [Info[2], 0, 0, 0, 0]\n            }\n            Items[\"\" Info[1] \"\"][2] += StrSplit(Info[3], \"x\")[2]\n            Items[\"\" Info[1] \"\"][3] += Info[4]\n            Items[\"\" Info[1] \"\"][4] += Info[6]\n            Items[\"\" Info[1] \"\"][5] += Info[7]\n            Names .= Names ? \" | \" Info[2] : Info[2]\n        }\n\n        C1 := [Date, File]\n        C2 := DateUser\n        C3 := \"+ \" Data[1] \" \" ConvertMillimsToDT(Data[1], \"+\")\n        C4 := \"- \" Data[2] \" \" ConvertMillimsToDT(Data[2], \"+\")\n        C5 := \"+ \" Data[3] \" \" ConvertMillimsToDT(Data[3], \"+\")\n        C6 := Names\n        C7 := Items\n        C8 := Data\n\n        LVContent[\"Lines\"].Push([C1, C2, C3, C4, C5, C6, C7, C8])\n        If !LVContent[\"Dates\"].HasKey(\"\" Date \"\") {\n            LVContent[\"Dates\"][\"\" Date \"\"] := \"\"\n        }\n    }\n    GuiControl,, PB, +1\n}\n\nGetFilesCount() {\n    FilesNum := 0\n    Loop, Files, Valid\\*.sell, R\n        FilesNum += 1\n    Loop, Files, Curr\\*.sell, R\n        FilesNum += 1\n    Return, FilesNum\n}\n\nLoadAllSells() {\n    LVContent   := { \"Lines\"  : []\n                   , \"Users\"  : {}\n                   , \"Dates\"  : {} }\n\n    GuiControl,, SPr\n    GuiControl,, CPr\n    GuiControl,, OAProfit\n\n    GuiControl, , PB, 0\n    Range := GetFilesCount()\n    GuiControl, +Range0-%Range%, PB\n    \n    Loop, Files, Valid\\*.sell, R\n        AddToList(A_LoopFileFullPath)\n    \n    Loop, Files, Curr\\*.sell, R\n        AddToList(A_LoopFileFullPath)\n}\n\nConvertMillimsToDT(Value, Sign := \"\") {\n    If (Value = \"...\" || !Value)\n        Return\n    ValueArr := StrSplit(Value / 1000, \".\")\n    Return, \"[\" (Sign ? Sign \" \" : \"\") ValueArr[1] (ValueArr[2] ? \".\" RTrim(ValueArr[2], 0) : \"\") \" DT]\"\n}\n\nUpdateSumValues(DataSum) {\n    GuiControl,, SPr, % \"+ \" DataSum[1] \" \" ConvertMillimsToDT(DataSum[1], \"+\")\n    GuiControl,, CPr, % \"- \" DataSum[2] \" \" ConvertMillimsToDT(DataSum[2], \"-\")\n    GuiControl,, OAProfit, % \"+ \" DataSum[3] \" \" ConvertMillimsToDT(DataSum[3], \"+\")\n}\n\nAnalyzeUsers() {\n    Global _74\n    GuiControl,, ProfByName, |\n    GuiControl,, ProfByName, % _74\n    For User in LVContent[\"Users\"] {\n        GuiControl,, ProfByName, % User\n    }\n    GuiControl, Choose, ProfByName, 1\n}\n\nAnalyzeDates() {\n    GuiControl,, Dates, |\n    For Date in LVContent[\"Dates\"] {\n        FormatTime, ThisDay, % Date, yyyy/MM/dd\n        GuiControl,, Dates, % \"-- \" ThisDay \" --\"\n    }\n}\n\nUpdateHeaders() {\n    Global\n    LV_Delete()\n    If (ProfByProduct = 1) && (Header = 2) {\n        For Each, Title in [[_70, 0], [_72, qw], [_39, qw], [_40, qw], [_41, qw]]\n            LV_ModifyCol(Each, Title[2], Title[1])\n        Header := 1\n    } \n    If (ProfByProduct = 2) && (Header = 1) {\n        For Each, Title in [[_63, sqw := qw*4 / 6], [_38, sqw], [_68, sqw, \" Integer Left\"], [_39, sqw, \" Integer Left\"], [_40, sqw, \" Integer Left\"], [_41, sqw, \" Integer Left\"]]\n            LV_ModifyCol(Each, Title[2] Title[3], Title[1])\n        Header := 2\n    }\n}"
  },
  {
    "path": "GUIReview_Hotkeys.ahk",
    "content": "#If WinActive(\"ahk_id \" Main)\nEnter::\n    GuiControlGet, Begin,, Begin\n    GuiControlGet, End,, End\n    GuiControl, Choose, Dates, 0\n\n    While (End >= Begin) {\n        FormatTime, FBegin, % Begin, yyyy/MM/dd\n        GuiControl, ChooseString, Dates, % \"|-- \" FBegin \" --\"\n        Begin += 1, Days\n    }\nReturn"
  },
  {
    "path": "GUIReview_Labels.ahk",
    "content": "ShowDetails:\n    GuiControlGet, ProfByProduct,, ProfByProduct\n    If (!(Row := LV_GetNext()) || ProfByProduct = 2)\n        Return\n    LV_GetText(FileName, LV_GetNext(), 1)\n    Run, % \"GUIDetails.\" (A_IsCompiled ? \"exe\" : \"ahk\") \" \" FileName\nReturn\n\nCalculateAll:\n    For Date in LVContent[\"Dates\"] {\n        GuiControl, Choose, Dates, % A_Index\n    }\n\nShowTheInfo:\n    GuiControlGet, ProfByProduct,, ProfByProduct\n    GuiControlGet, ProfByName,, ProfByName\n    GuiControlGet, Dates,, Dates\n\n    GuiControl,, Overview, % View[ProfByProduct] \" | \" ProfByName \" | \" Dates\n\n    ProfByName := (ProfByName = _74) ? \"\" : ProfByName\n    UpdateHeaders()\n\n    DataSum := [0, 0, 0]\n    If (ProfByProduct = 1) {\n        For Each, Line in LVContent[\"Lines\"] {\n            FormatTime, ThisDay, % Line[1][1], '--' yyyy/MM/dd '--'\n            UName := (Line[2].Length() = 2) ? Line[2][1] : \"\"\n\n            If InStr(Dates, ThisDay) && InStr(UName, ProfByName) {\n                LV_Add(, Line[1][2], Line[2][1] (Line[2][2] ? \" | \" Line[2][2] : \"\"), Line[3], Line[4], Line[5], Line[6])\n                DataSum[1] += Line[8][1]\n                DataSum[2] += Line[8][2]\n                DataSum[3] += Line[8][3]\n                UpdateSumValues(DataSum)\n            }\n        }\n    }\n\n    If (ProfByProduct = 2) {\n        Info := {}\n        For Each, Line in LVContent[\"Lines\"] {\n            FormatTime, ThisDay, % Line[1][1], '--' yyyy/MM/dd '--'\n            UName := (Line[2].Length() = 2) ? Line[2][1] : \"\"\n            If InStr(Dates, ThisDay) && InStr(UName, ProfByName) {\n                For Barcode, Detail in Line[7] {\n                    If !Info.HasKey(\"\" Barcode \"\") {\n                        Info[\"\" Barcode \"\"] := [ LV_Add(, Barcode, Detail[1], Detail[2], Detail[3], Detail[4], Detail[5])\n                                               , Detail[1]\n                                               , Detail[2]\n                                               , Detail[3]\n                                               , Detail[4]\n                                               , Detail[5] ]\n                    } Else {\n                        Info[\"\" Barcode \"\"][3] += Detail[2]\n                        Info[\"\" Barcode \"\"][4] += Detail[3]\n                        Info[\"\" Barcode \"\"][5] += Detail[4]\n                        Info[\"\" Barcode \"\"][6] += Detail[5]\n                        LV_Modify(  Info[\"\" Barcode \"\"][1]\n                                  ,,\n                                  ,\n                                  , Info[\"\" Barcode \"\"][3]\n                                  , Info[\"\" Barcode \"\"][4]\n                                  , Info[\"\" Barcode \"\"][5]\n                                  , Info[\"\" Barcode \"\"][6] )\n                    }\n                }\n                DataSum[1] += Line[8][1]\n                DataSum[2] += Line[8][2]\n                DataSum[3] += Line[8][3]\n                UpdateSumValues(DataSum)\n            }\n        }\n    }\nReturn\n\nCheckTheListBox:\n    GuiControlGet, Begin,, Begin\n    GuiControlGet, End,, End\n    GuiControl, Choose, Dates, |0\n\n    While (End >= Begin) {\n        FormatTime, FBegin, % Begin, yyyy/MM/dd\n        GuiControl, ChooseString, Dates, % \"|-- \" FBegin \" --\"\n        Begin += 1, Days\n    }\nReturn\n\nChart:\n    GuiControl, Disabled, Chart\n    GuiControlGet, ProfByProduct,, ProfByProduct\n    If (ProfByProduct = 1) {\n        If (RowCount := LV_GetCount()) {\n            Dummy := {}\n            Loop, % RowCount {\n                LV_GetText(F, A_Index, 1)\n                LV_GetText(S, A_Index, 3)\n                LV_GetText(B, A_Index, 4)\n                LV_GetText(P, A_Index, 5)\n\n                SplitPath, % F,,,, O\n\n                RegExMatch(S, \"\\d+\", S)\n                RegExMatch(B, \"\\d+\", B)\n                RegExMatch(P, \"\\d+\", P)\n\n                If !Dummy.HasKey(\"\" (O := SubStr(O, 1, 8)) \"\") {\n                    Dummy[\"\" O \"\"] := [0, 0, 0]\n                }\n\n                Dummy[\"\" O \"\"][1] += S\n                Dummy[\"\" O \"\"][2] += B\n                Dummy[\"\" O \"\"][3] += P\n            }\n\n            Dates   := \"\"\n            Sells   := \"\"\n            Costs   := \"\"\n            Profits := \"\"\n\n            For Each, Date in Dummy {\n                FormatTime, D, % Each, yyyy/MM/dd\n                Dates   .= Dates   != \"\"  ? \",'\"  D \"'\"    : \"'\" D \"'\"\n                Sells   .= Sells   != \"\"  ? \",\"  Date[1]   : Date[1]\n                Costs   .= Costs   != \"\"  ? \",\"  Date[2]   : Date[2]\n                Profits .= Profits != \"\"  ? \",\"  Date[3]   : Date[3] \n            }\n            Dates   := \"[\" Dates   \"]\"\n            Sells   := \"[\" Sells   \"]\"\n            Costs   := \"[\" Costs   \"]\"\n            Profits := \"[\" Profits \"]\"\n\n            FileCopy, HighChart\\template\\Chart.html, Template.html, 1\n            FileCopy, HighChart\\template\\Chart.css, Template.css, 1\n            FileCopy, HighChart\\template\\Chart.js, Template.js, 1\n\n            FileRead, JS, Template.js\n\n            JS := StrReplace(JS, \"'[CASH_HELPER_DATES_HOLDER]'\", Dates)\n            JS := StrReplace(JS, \"'[CASH_HELPER_SELLS_HOLDER]'\", Sells)\n            JS := StrReplace(JS, \"'[CASH_HELPER_BUYS_HOLDER]'\", Costs)\n            JS := StrReplace(JS, \"'[CASH_HELPER_PROFITS_HOLDER]'\", Profits)\n\n            FileOpen(\"Template.js\"  , \"w\").Write(JS).Close()\n            Run, Template.html\n        }\n    }\n    GuiControl, Enabled, Chart\nReturn\n\nGuiClose:\n    IniDelete, Sets\\PID.ini, PID, GUIReview\nExitApp"
  },
  {
    "path": "GUISell.ahk",
    "content": "﻿#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\n#NoEnv\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\Class_CtlColors.ahk\n#Include, Lib\\Classes\\Class_ImageButton.ahk\n#Include, Lib\\Classes\\Class_GDIplus.ahk\n\n#Include, Lib\\Language.ahk\n\nFolderSet()\nGlobal UserPic\nIf !Level := LogIn(AdminName := A_Args[1], AdminPass := A_Args[2]) {\n    FileRead, Reciever, Sets\\Login.Hwnd\n    FileOpen(\"Sets\\Login.Request\", \"w\").Write(\"Run|\" A_ScriptFullPath).Close()\n    SendMessage, 0x1000,,,, ahk_id %Reciever%\n    Sleep, 1000\n    MsgBox, 16, % _112, % _114\n    ExitApp\n}\nGui, +HwndMain +Resize\nGui, Add, Pic, % \"x0 y0\", Img\\BG.png\nGui, Add, Pic, % \"x\" A_ScreenWidth - 120 \" ym w80 h80\", % UserPic ? UserPic : \"Img\\UserLogo.png\"\nGui, Margin, 10, 10\nGui, Color, 0x7D7D3A\nGui, Font, s14 Bold Italic, Calibri\n\nGui, Add, Text, xm+5 ym w190 BackgroundTrans, % _205 \":\"\nGui, Add, ListBox, 0x100 w190 r10 vSearch gWriteToBc AltSubmit HwndHCtrl\nCtlColors.Attach(HCtrl, \"D8D8AD\", \"404000\")\n\nGui, Font, s18 norm Bold\nGui, Add, Edit, % \"xp y\" A_ScreenHeight - 450 \" w190 vItemsSold r2 -E0x200 ReadOnly Center -VScroll Hidden HwndHCtrl\", 0\nCtlColors.Attach(HCtrl, \"EAEAB5\", \"FF0000\")\nGui, Add, Edit, % \"xp yp+70 w190 vSoldP -E0x200 r2 ReadOnly Center -VScroll cGreen Hidden HwndHCtrl\", 0\nCtlColors.Attach(HCtrl, \"EAEAB5\", \"008000\")\nGui, Add, Edit, % \"xp yp+70 w190 vCostP -E0x200 r2 ReadOnly Center -VScroll cRed Hidden HwndHCtrl\", 0\nCtlColors.Attach(HCtrl, \"EAEAB5\", \"FF0000\")\nGui, Add, Edit, % \"xp yp+70 w190 vProfitP -E0x200 r2 ReadOnly Center -VScroll cGreen Hidden HwndHCtrl\", 0\nCtlColors.Attach(HCtrl, \"EAEAB5\", \"008000\")\n\nButtonTheme := [[3, 0x80FF80, 0x5ABB5A, 0x000000, 2,, 0x008000, 1]\n              , [3, 0x44DB44, 0x2F982F, 0x000000, 2,, 0x008000, 1]\n              , [3, 0x1AB81A, 0x107410, 0x000000, 2,, 0x008000, 1]\n              , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]\n\nGui, Font, s25\npw := (A_ScreenWidth - 235) / 3\nGui, Add, Edit, % \"x225 ym+85 w\" pw \" h45 vGivenMoney -E0x200 gCalc Center Border Hidden\"\nCtlColors.Attach(HCtrl, \"EAEAB5\", \"FF0000\")\n\nGui, Add, Edit, % \"xp+\" pw \" yp wp h45 vAllSum -E0x200 ReadOnly Center Border cGreen Hidden HwndHCtrl\"\nCtlColors.Attach(HCtrl, \"EAEAB5\", \"000000\")\n\nGui, Add, Edit, % \"xp+\" pw \" yp wp h45 vChange -E0x200 ReadOnly Center Border cRed Hidden HwndHCtrl\"\nCtlColors.Attach(HCtrl, \"EAEAB5\", \"FF0000\")\n\nGui, Font, s25\nGui, Add, Edit, % \"x225 y30 w\" pw \" -VScroll vBc Center -E0x200 gAnalyzeAvail Border HwndHCtrl \"\nSetEditCueBanner(HCtrl, _201)\nGui, Add, Button, % \"xp+\" pw + 5 \" yp vAddEnter gEnter w80 hp HwndHCtrl Disabled\", % \"→\"\nImageButton.Create(HCtrl, ButtonTheme*)\n\nGui, Add, Edit, % \"xp-\" (pw + 5) \" yp+85 w\" pw \" vNm h45 -E0x200 ReadOnly Center HwndHCtrl Border\"\nCtlColors.Attach(HCtrl, \"C5C585\")\n\nGui, Add, Edit, % \"xp+\" pw \" yp wp h45 vQn Center -E0x200 ReadOnly HwndHCtrl Border cRed\"\nCtlColors.Attach(HCtrl, \"C5C585\")\n\nGui, Add, Edit, % \"xp+\" pw \" wp h45 -E0x200 ReadOnly Center HwndHCtrl Border vSum\"\nCtlColors.Attach(HCtrl, \"C5C585\")\n\nGui, Add, Button, % \"vAddUp xp-\" pw/2 + 50 \" yp+70 gUp HwndHCtrl w50 h30 Disabled\", % \"+\"\nImageButton.Create(HCtrl, ButtonTheme*)\n\nGui, Add, Button, % \"vAddDown xp+50 yp gDown HwndHCtrl wp hp Disabled\", % \"-\"\nImageButton.Create(HCtrl, ButtonTheme*)\nGui, Font, s16\nGui, Add, Text, % \"x225 yp w\" pw - 31 \" h30 vTransc HwndTHCtrl Center gViewLastTrans Hidden\"\nCtlColors.Attach(THCtrl, \"B2B2B2\")\nGui, Add, Pic, % \"x\" 225 + pw - 31 \" yp w30 h30 vTranscOK  gViewLastTrans Hidden\", Img\\Idle.png\n\nGui, Font, s18\nGui, Add, ListView, % \"HwndHCtrl x225 yp+37 w\" pw*3 \" h\" A_ScreenHeight - 380 \" vListView Grid \", % _63 \"|\" _61 \"|\" _38 \"|\" _68 \"|\" _69\n\nLV_ModifyCol(1, \"0 Center\")\nLV_ModifyCol(2, Level = 1? pw / 2 : 0)\nLV_ModifyCol(3, (Level = 1? pw / 2 : pw) \" Center\")\nLV_ModifyCol(4, pw \" Center\")\nLV_ModifyCol(5, pw \" Center\")\n\n;Gui, Font, s15\nGui, Add, Edit, % \"xp+\" pw*2 \" yp-50 w\" pw \" vThisListSum -E0x200 ReadOnly HwndHCtrl Center\"\nCtlColors.Attach(HCtrl, \"D8D8AD\", \"FF0000\")\n\nGui, Font, s12\n\nGui, Add, Button, % \"vAddSell x225 y\" A_ScreenHeight - 150 \" gSpace w100 hp HwndHCtrl Disabled\", % _115\nImageButton.Create(HCtrl, ButtonTheme*)\n\nGui, Add, Button, % \"vAddDelete xp+100 yp gDelete HwndHCtrl wp hp Disabled\", % _130\nImageButton.Create(HCtrl, ButtonTheme* )\n\nGui, Add, Button, % \"vAddSubmit xp+100 yp gEnter w100 hp HwndHCtrl Disabled\", % _168\nImageButton.Create(HCtrl, ButtonTheme*)\n\nGui, Add, Button, % \"vSubKridi xp+100 yp gSubKridi HwndHCtrl wp hp Disabled\", % _29\nImageButton.Create(HCtrl, ButtonTheme* )\n\nGui, Add, Button, % \"vCancel xp+100 yp gEsc HwndHCtrl wp hp Disabled\", % _169\nImageButton.Create(HCtrl, ButtonTheme* )\n\nGui, Font, s15\n\n;Gui, Add, Pic, % \"x\" A_ScreenWidth - 70 \" yp\", Img\\User.png\n\n;Gui, Add, Edit, % \"xp-200 yp w200 vUser hp -E0x200 ReadOnly HwndHCtrl Border -VScroll\", % _206 \": \" AdminName\n;                                                                                               . \"`n\" _207 \": \" Levels[Level]\n;CtlColors.Attach(HCtrl, \"C5C585\")\n\nGui, Add, Button, % \"xm+15 y\" A_ScreenHeight - 160 \" w30 h25 vSession1 HwndHCtrl gSession1 \", 1\nImageButton.Create(HCtrl, ButtonTheme*)\nGui, Add, Button, % \"xp+35 yp wp hp vSession2 HwndHCtrl gSession2 \", 2\nImageButton.Create(HCtrl, ButtonTheme*)\nGui, Add, Button, % \"xp+35 yp wp hp vSession3 HwndHCtrl gSession3 \", 3\nImageButton.Create(HCtrl, ButtonTheme*)\nGui, Add, Button, % \"xp+35 yp wp hp vSession4 HwndHCtrl gSession4 \", 4\nImageButton.Create(HCtrl, ButtonTheme*)\nGui, Add, Button, % \"xp+35 yp wp hp vSession5 HwndHCtrl gSession5 \", 5\nImageButton.Create(HCtrl, ButtonTheme*)\nGui, Add, Button, % \"xm+15 yp+35 wp hp vSession6 HwndHCtrl gSession6 \", 6\nImageButton.Create(HCtrl, ButtonTheme*)\nGui, Add, Button, % \"xp+35 yp wp hp vSession7 HwndHCtrl gSession7 \", 7\nImageButton.Create(HCtrl, ButtonTheme*)\nGui, Add, Button, % \"xp+35 yp wp hp vSession8 HwndHCtrl gSession8 \", 8\nImageButton.Create(HCtrl, ButtonTheme*)\nGui, Add, Button, % \"xp+35 yp wp hp vSession9 HwndHCtrl gSession9 \", 9\nImageButton.Create(HCtrl, ButtonTheme*)\nGui, Add, Button, % \"xp+35 yp wp hp vSession10 HwndHCtrl gSession10 \", 10\nImageButton.Create(HCtrl, ButtonTheme*)\n\nGui, Font, s12\nLevels := [\"Admin\", \"User\"]\nGui, Add, StatusBar\nSB_SetParts(10, 200, 200)\nSB_SetText(_206 \": \" AdminName, 2)\nSB_SetText(_207 \": \" Levels[Level], 3)\n\nGui, Show, Maximize, Sell GUI\nOnMessage(0x1000, \"Message\")\nFileOpen(\"Sets\\GUISell.Hwnd\", \"w\").Write(Main).Close()\n\nThemeAdd()\n\nGuiControl, Disabled, Session1\nSelling     := 0\nProdDefs    := LoadDefinitions()\nSession     := 1\nIf FileExist(\"Dump\\\" Session \".session\") {\n    RestoreSession()\n    CalculateSum()\n}\nCheckLatestSells()\nCurrentProfit := CalculateCurrent()\n\nReturn\n\n#Include, GUISell_Hotkeys.ahk\n#Include, GUISell_Functions.ahk\n#Include, GUISell_Labels.ahk"
  },
  {
    "path": "GUISell_Functions.ahk",
    "content": "ConvertMillimsToDT(Value, Sign := \"\") {\n    If (Value = \"...\" || !Value)\n        Return\n    ValueArr := StrSplit(Value / 1000, \".\")\n    Return, \"[\" (Sign ? Sign \" \" : \"\") ValueArr[1] (ValueArr[2] ? \".\" RTrim(ValueArr[2], 0) : \"\") \" DT]\"\n}\n\nRestoreSession() {\n    Global Session\n    If LV_GetCount() {\n        LV_Delete()\n        GuiControl, Disabled, AddUp\n        GuiControl, Disabled, AddDown\n        GuiControl, Disabled, AddSell\n        GuiControl, Disabled, AddDelete\n    }\n\n    If FileExist(\"Dump\\\" Session \".session\") {\n        Obj := FileOpen(\"Dump\\\" Session \".session\", \"r\")\n        While !Obj.AtEOF() {\n            Line := Trim(Obj.ReadLine(), \"`n\")\n            Col := StrSplit(Line, \",\")\n            LV_Add(, Col[1], Col[2], Col[3], Col[4], Col[5])\n        }\n        Obj.Close()\n        If LV_GetCount() {\n            GuiControl, Enabled, AddUp\n            GuiControl, Enabled, AddDown\n            GuiControl, Enabled, AddSell\n            GuiControl, Enabled, AddDelete\n        }\n    }\n    GuiControl, Focus, Bc\n}\n\nWriteSession() {\n    Global Session\n    Obj := FileOpen(\"Dump\\\" Session \".session\", \"w\")\n    Loop, % LV_GetCount() {\n        LV_GetText(Col1, A_Index, 1)\n        LV_GetText(Col2, A_Index, 2)\n        LV_GetText(Col3, A_Index, 3)\n        LV_GetText(Col4, A_Index, 4)\n        LV_GetText(Col5, A_Index, 5)\n        Obj.WriteLine(Col1 \",\" Col2 \",\" Col3 \",\" Col4 \",\" Col5)\n    }\n    Obj.Close()\n}\n\nSetExplorerTheme(HCTL) {\n    If (DllCall(\"GetVersion\", \"UChar\") > 5) {\n        VarSetCapacity(ClassName, 1024, 0)\n        If DllCall(\"GetClassName\", \"Ptr\", HCTL, \"Str\", ClassName, \"Int\", 512, \"Int\") {\n            Return !DllCall(\"UxTheme.dll\\SetWindowTheme\", \"Ptr\", HCTL, \"WStr\", \"Explorer\", \"Ptr\", 0)\n        }\n    }\n    Return False\n}\n\nLoadDefinitions() {\n    Definitions := {}\n    Loop, Files, Sets\\Def\\*.Def, R\n    {\n        FileRead, Content, % A_LoopFileFullPath\n        Content := StrSplit(Content, \";\")\n        Definitions[\"\" StrReplace(A_LoopFileName, \".def\") \"\"] := { \"Name\" : Content[1]\n            , \"BuyPrice\" : Content[2]\n            , \"SellPrice\" : Content[3]\n        , \"Quantity\" : Content[4] }\n    }\n    Return, Definitions\n}\n\nCalculateSum() {\n    Global AdditionalInfo\n    CharSum := 0\n    Loop, % LV_GetCount() {\n        LV_GetText(ThisCharSum, A_Index, 5)\n        CharSum += ThisCharSum\n    }\n    If (CharSum) {\n        GuiControlGet, Remise, , Remise\n        CharSumRemise := CharSum\n        If (Remise) && (AdditionalInfo) {\n            CharSumRemise -= Round(Remise / 100 * CharSum)\n        }\n        GuiControl, , ThisListSum, % CharSumRemise \" \" ConvertMillimsToDT(CharSumRemise)\n        GuiControl, , AllSum, % CharSumRemise\n    } Else {\n        GuiControl, , ThisListSum\n    }\n}\n\nCartView() {\n    Global Selling\n    Selling := 0\n    GuiControl, , AllSum\n    GuiControl, , Change\n    GuiControl, , GivenMoney\n    GuiControl, Hide, GivenMoney\n    GuiControl, Hide, AllSum\n    GuiControl, Hide, Change\n    GuiControl, Show, Bc\n    GuiControl, Show, AddEnter\n    GuiControl, Show, Nm\n    GuiControl, Show, Qn\n    GuiControl, Show, Sum\n    LV_Delete()\n    GuiControl, Focus, Bc\n}\n\nSellView() {\n    Global Selling\n    Selling := 1\n    GuiControl, Hide, Bc\n    GuiControl, Hide, AddEnter\n    GuiControl, Hide, Nm\n    GuiControl, Hide, Qn\n    GuiControl, Hide, Sum\n    GuiControl, Show, GivenMoney\n    GuiControl, Show, AllSum\n    GuiControl, Show, Change\n    GuiControl, Focus, GivenMoney\n}\n\nTrancsView(Tranc, View) {\n    Global _126, THCtrl, CountToHide := 1\n    If (View) {\n        GuiControl, Show, Transc\n        GuiControl, Show, TranscOK\n        If (Tranc) {\n            FormatTime, Now, % A_Now, yyyy/MM/dd 'at' HH:mm:ss\n            CtlColors.Change(THCtrl, \"008000\", \"FFFFFF\")\n            GuiControl, , Transc, % Now\n            GuiControl, , TranscOK, Img\\OK.png\n            SetTimer, TranscHide, 1000\n        } Else {\n            CtlColors.Change(THCtrl, \"CCCCCC\")\n            GuiControl, , Transc\n            GuiControl, , TranscOK, Img\\Idle.png\n        }\n    } Else {\n        GuiControl, Hide, Transc\n        GuiControl, Hide, TranscOK\n    }\n}\n\nCheckLatestSells() {\n    Global ProdDefs, SearchList := []\n    GuiControl,, Search, |\n    If FileExist(\"Dump\\Last.sell\") {\n        Loop, Read, Dump\\Last.sell\n        {\n            If (ProdDefs[\"\" Trim(A_LoopReadLine, \"`n\") \"\"] != \"\") {\n                GuiControl,, Search, % \" -- \" ProdDefs[\"\" Trim(A_LoopReadLine, \"`n\") \"\"][\"Name\"] \" -- \"\n                SearchList.Push(\"\" A_LoopReadLine \"\")\n            }\n        }\n    }\n}\n\nCalculateCurrent() {\n    Global _37\n    S := B := P := I := 0\n    Loop, Files, Curr\\*.sell\n    {\n        FileRead, Content, % A_LoopFileFullPath\n        Content := StrSplit(StrSplit(Content, \"> \")[2], \"|\")\n        For Each, One in Content {\n            F := StrSplit(One, \";\")\n            I += StrSplit(F[3], \"x\")[2]\n            S += F[4]\n            B += F[6]\n            P += F[7]\n        }\n    }\n\n    GuiControl,, ItemsSold, % I \" \" _37\n    GuiControl,, SoldP, % S \"`n\" ConvertMillimsToDT(S)\n    GuiControl,, CostP, % B \"`n\" ConvertMillimsToDT(B)\n    GuiControl,, ProfitP, % P \"`n\" ConvertMillimsToDT(P)\n\n    Return, [I, S, B, P]\n}\n\nLogIn(Username, Password) {\n    If (FileExist(\"Sets\\Acc.chu\")) {\n        Account := {}\n        FileRead, RawAccount, Sets\\Acc.chu\n        TextAccount := b64Decode(RawAccount)\n\n        For Each, User in StrSplit(TextAccount, \",\") {\n            LOG := StrSplit(User, \"|\")\n            Account[LOG[1]] := [LOG[2], LOG[3], LOG[4]]\n        }\n\n        If (Account[Username][1] = Password) {\n            If (Account[Username][3]) {\n                UserPic := Account[Username][3]\n            }\n            If (Account[Username][2] = \"Admin\")\n                Return, 1\n            Else If (Account[Username][2] = \"User\")\n                Return, 2\n        }\n    }\n    Return, 0\n}\n\nb64Encode(string) {\n    VarSetCapacity(bin, StrPut(string, \"UTF-8\")) && len := StrPut(string, &bin, \"UTF-8\") - 1 \n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    VarSetCapacity(buf, size << 1, 0)\n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    return StrGet(&buf)\n}\n\nb64Decode(string) {\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        throw Exception(\"CryptStringToBinary failed\", -1)\n    VarSetCapacity(buf, size, 0)\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        throw Exception(\"CryptStringToBinary failed\", -1)\n    return StrGet(&buf, size, \"UTF-8\")\n}\n\nGUISellHistory(Text) {\n    FormatTime, OutTime, % A_Now, yyyy/MM/dd HH:mm:ss\n    Obj := FileOpen(\"Hist\\SellHistory.Hist\", \"a\")\n    Obj.WriteLine(OutTime \" ==> \" Text)\n    Obj.Close()\n}\n\nFolderSet() {\n    Array := [ \"Curr\"\n    , \"Sets\"\n    , \"Sets\\Def\"\n    , \"Valid\"\n    , \"Dump\"\n    , \"Kr\"\n    , \"CKr\" \n    , \"Unvalid\" \n    , \"Hist\" ]\n\n    For Every, Folder in Array {\n        If !FolderExist(Folder) {\n            FileCreateDir, % Folder\n        }\n    }\n}\n\nFolderExist(Folder) {\n    Return InStr(FileExist(Folder), \"D\")\n}\n\nThemeAdd() {\n    Loop, 5 {\n        Gui, Add, Text, % \"y0 x\" 208 + A_Index * 2 \" w1 h\" A_ScreenHeight \" HwndHCtrl\"\n        CtlColors.Attach(HCtrl, \"7D7D64\")\n    }\n}\n\nMessage() {\n    Global ProdDefs\n    FileRead, Message, Sets\\Message.Request\n    If (Message = \"Update_Definitions\") {\n        ProdDefs := LoadDefinitions()\n    }\n}\n\nSetEditCueBanner(HWND, Cue) {\n    Static EM_SETCUEBANNER := (0x1500 + 1)\n    Return DllCall(\"User32.dll\\SendMessageW\", \"Ptr\", HWND, \"Uint\", EM_SETCUEBANNER, \"Ptr\", True, \"WStr\", Cue)\n}\n\nInsertLineAtStart(File, Text) {\n    rText := FileOpen(\"Dump\\Last.sell\", \"r\").Read(5000)\n    FileOpen(\"Dump\\Last.sell\", \"w\").Write(Text \"`n\" rText).Close()\n}\n"
  },
  {
    "path": "GUISell_Hotkeys.ahk",
    "content": "#If WinActive(\"ahk_id \" Main)\n    Enter::\n        GuiControlGet, Bc, , Bc\n        GuiControl, Disabled, Bc\n        If (!Selling) {\n            Barcode := Bc\n            If (ProdDefs[\"\" Barcode \"\"][\"Name\"] != \"\")\n            && (ProdDefs[\"\" Barcode \"\"][\"SellPrice\"] != \"\") \n            && (ProdDefs[\"\" Barcode \"\"][\"Quantity\"] != \"\") {\n                Nm                  := ProdDefs[\"\" Barcode \"\"][\"Name\"]\n                SellPrice           := ProdDefs[\"\" Barcode \"\"][\"SellPrice\"]\n                ThisCurrQuantity    := ProdDefs[\"\" Barcode \"\"][\"Quantity\"] ? ProdDefs[\"\" Barcode \"\"][\"Quantity\"] : 0\n                QuantitySumArg      := SellPrice \"x1\"\n\n                JobDone             := 0\n                Loop, % LV_GetCount() {\n                    LV_GetText(ThisBc, Row := A_Index, 1)\n                    If (ThisBc = Barcode) {\n                        LV_GetText(AddedCurrQuantity, Row, 2), AddedCurrQuantity := StrSplit(AddedCurrQuantity, \"  >>  \")\n                        LV_GetText(AddedQuantitySumArg, Row, 4), AddedQuantitySumArg := StrSplit(AddedQuantitySumArg, \"x\"), QuantitySumArg := AddedQuantitySumArg[1] \"x\" AddedQuantitySumArg[2] + 1\n                        LV_GetText(PreviousSum, Row, 5)\n                        SellPrice := ProdDefs[\"\" Barcode \"\"][\"SellPrice\"]\n                        LV_Modify(Row,,, AddedCurrQuantity[1] \"  >>  \" AddedCurrQuantity[2] - 1,, QuantitySumArg, PreviousSum + SellPrice)\n                        JobDone := 1\n                        Break\n                    }\n                }\n                If (!JobDone) {\n                    LV_Add(\"\", Barcode, ThisCurrQuantity \"  >>  \" ThisCurrQuantity - 1, Nm, QuantitySumArg, SellPrice)\n                }\n                CalculateSum()\n                WriteSession()\n                GuiControl, Enabled, AddUp\n                GuiControl, Enabled, AddDown\n                GuiControl, Enabled, AddSell\n                GuiControl, Enabled, AddDelete\n            }\n        } Else {\n            FormatTime, OutTime, % (Now := A_Now), yyyy/MM/dd HH:mm:ss\n            SellOBJ := FileOpen(LastestSO := \"Curr\\\" Now \".sell\", \"w\")\n            SellOBJ.Write(AdminName \"|\" OutTime)\n            \n            I := Sum := Cost := 0\n            Loop, % LV_GetCount() {\n                LV_GetText(Bc, A_Index, 1)\n                LV_GetText(Qn, A_Index, 4)\n                Qn := StrSplit(Qn, \"x\")[2]\n\n                If (!Qn) || (!Bc) {\n                    MsgBox, 16, % _13, % _160 \"`nRow: \" A_Index\n                    Continue\n                }\n\n                ProdDefs[\"\" Bc \"\"][\"Quantity\"] -= Qn\n\n                FileRead, Content, % \"Sets\\Def\\\" Bc \".def\"\n                Content := StrSplit(Content, \";\")\n\n                DefObj := FileOpen(\"Sets\\Def\\\" Bc \".def\", \"w\")\n                DefObj.Write(Content[1] \";\" Content[2] \";\" Content[3] \";\" Content[4] - Qn)\n                DefObj.Close()\n\n                Name    := ProdDefs[\"\" Bc \"\"][\"Name\"]\n                SellStr := ProdDefs[\"\" Bc \"\"][\"SellPrice\"] \"x\" Qn\n                Sell    := ProdDefs[\"\" Bc \"\"][\"SellPrice\"] * Qn\n                Sum     += Sell\n                BuyStr  := ProdDefs[\"\" Bc \"\"][\"BuyPrice\"] \"x\" Qn\n                Buy     := ProdDefs[\"\" Bc \"\"][\"BuyPrice\"] * Qn\n\n                Cost += Buy\n                SellOBJ.Write(((A_Index > 1) ? \"|\" : \"> \") Bc \";\" Name \";\" SellStr \";\" Sell \";\" BuyStr \";\" Buy \";\" Sell - Buy)\n\n                I += Qn\n                InsertLineAtStart(\"Dump\\Last.sell\", Bc)\n            }\n            \n            SellOBJ.Write(\"> \" Sum \";\" Cost \";\" Sum - Cost)\n            SellOBJ.Close()\n            \n            If FileExist(\"Dump\\Kridi.sell\") {\n                FileRead, Content, Dump\\Kridi.sell\n                If !InStr(FileExist(\"Kr\\\" Content), \"D\") {\n                    FileCreateDir, % \"Kr\\\" Content\n                }\n                FileMove, % LastestSO, % \"Kr\\\" Content\n                FileDelete, % \"Dump\\Kridi.sell\"\n                LastestSO := StrReplace(LastestSO, \"Curr\\\", \"Kr\\\" Content \"\\\")\n            }\n            \n            Selling := 0\n            GuiControl, Disabled, AddEnter\n            GuiControl, Disabled, AddUp\n            GuiControl, Disabled, AddDown\n            GuiControl, Disabled, AddSell\n            GuiControl, Disabled, AddSubmit\n            If (Level = 1)\n                GuiControl, Disabled, SubKridi\n            GuiControl, Disabled, AddDelete\n            GuiControl, Disabled, Cancel\n            \n            GuiControl,, AllSum\n            GuiControl,, Change\n            GuiControl,, GivenMoney\n            GuiControl, Hide, GivenMoney\n            GuiControl, Hide, AllSum\n            GuiControl, Hide, Change\n            \n            GuiControl, Show, Bc\n            GuiControl, Show, AddEnter\n            GuiControl, Show, Nm\n            GuiControl, Show, Qn\n            GuiControl, Show, Sum\n            LV_Delete()\n            \n            WriteSession()\n            CalculateSum()\n            TrancsView(1, 1)\n            CheckLatestSells()\n            \n            CurrentProfit[1] += I\n            CurrentProfit[2] += Sum\n            CurrentProfit[3] += Cost\n            CurrentProfit[4] += Sum - Cost\n\n            GuiControl,, ItemsSold, % (CurrentProfit[1]) \" \" _37\n            GuiControl,, SoldP,     % (CurrentProfit[2]) \"`n\" ConvertMillimsToDT(CurrentProfit[2])\n            GuiControl,, CostP,     % (CurrentProfit[3]) \"`n\" ConvertMillimsToDT(CurrentProfit[3])\n            GuiControl,, ProfitP,   % (CurrentProfit[4]) \"`n\" ConvertMillimsToDT(CurrentProfit[4])\n        }\n        GuiControl, Enabled, Bc\n        GuiControl, , Bc\n        GuiControl, Focus, Bc\n        Sleep, 125\n    Return\n\n    Space::\n        GuiControlGet, FocusedControl, FocusV\n        If (FocusedControl ~= \"Client|SellDesc\") {\n            SendInput, {Space}\n        } Else {\n            If LV_GetCount() {\n                SellView()\n                AllSum := 0\n                Loop, % LV_GetCount() {\n                    LV_GetText(ThisAllSum, A_Index, 5)\n                    AllSum += ThisAllSum\n                }\n                GuiControl, , AllSum, % AllSum\n                GuiControl, Disabled, AddUp\n                GuiControl, Disabled, AddDown\n                GuiControl, Disabled, AddDelete\n                GuiControl, Disabled, AddSell\n                If (Level = 1)\n                    GuiControl, Enabled, SubKridi\n                GuiControl, Enabled, AddSubmit\n                GuiControl, Enabled, Cancel\n                GuiControl, Focus, GivenMoney\n                CalculateSum()\n                Selling := 1\n            } Else {\n                GuiControl, Focus, Bc\n            }\n        }\n        Sleep, 125\n    Return\n\n    Left::\n        If !(--Session) {\n            Session += 10\n        }\n\n        Loop, 10 {\n            If (A_Index = Session) {\n                GuiControl, Disabled, Session%A_Index%\n            } Else {\n                GuiControl, Enabled, Session%A_Index%\n            }\n        }\n\n        RestoreSession()\n        CalculateSum()\n        Sleep, 125\n    Return\n\n    Right::\n        If (++Session = 11) {\n            Session -= 10\n        }\n\n        Loop, 10 {\n            If (A_Index = Session) {\n                GuiControl, Disabled, Session%A_Index%\n            } Else {\n                GuiControl, Enabled, Session%A_Index%\n            }\n        }\n\n        RestoreSession()\n        CalculateSum()\n        Sleep, 125\n    Return\n\n    Up::\n        If (Row := LV_GetNext()) {\n            LV_GetText(ThisQn, Row, 4)\n            LV_GetText(ThisBc, Row, 1)\n            VQ := StrSplit(ThisQn, \"x\")\n            LV_Modify(Row,,, ProdDefs[\"\" ThisBc \"\"][\"Quantity\"] \"  >>  \" ProdDefs[\"\" ThisBc \"\"][\"Quantity\"] - (VQ[2] + 1),, VQ[1] \"x\" VQ[2] + 1, VQ[1] * (VQ[2] + 1))\n        } Else If (Row := LV_GetCount()) {\n            LV_GetText(ThisQn, Row, 4)\n            LV_GetText(ThisBc, Row, 1)\n            VQ := StrSplit(ThisQn, \"x\")\n            LV_Modify(Row,,, ProdDefs[\"\" ThisBc \"\"][\"Quantity\"] \"  >>  \" ProdDefs[\"\" ThisBc \"\"][\"Quantity\"] - (VQ[2] + 1),, VQ[1] \"x\" VQ[2] + 1, VQ[1] * (VQ[2] + 1))\n        }\n        CalculateSum()\n        WriteSession()\n        Sleep, 125\n    Return\n\n    Down::\n        GuiControlGet, Focused, FocusV\n        If (Row := LV_GetNext()) {\n            LV_GetText(ThisQn, Row, 4)\n            LV_GetText(ThisBc, Row, 1)\n            VQ := StrSplit(ThisQn, \"x\")\n            If (VQ[2] > 1) {\n                LV_Modify(Row,,, ProdDefs[\"\" ThisBc \"\"][\"Quantity\"] \"  >>  \" ProdDefs[\"\" ThisBc \"\"][\"Quantity\"] - (VQ[2] - 1),, VQ[1] \"x\" VQ[2] - 1, VQ[1] * (VQ[2] - 1))\n            }\n        } Else If (Row := LV_GetCount()) {\n            LV_GetText(ThisQn, Row, 4)\n            LV_GetText(ThisBc, Row, 1)\n            VQ := StrSplit(ThisQn, \"x\")\n            If (VQ[2] > 1) {\n                LV_Modify(Row,,, ProdDefs[\"\" ThisBc \"\"][\"Quantity\"] \"  >>  \" ProdDefs[\"\" ThisBc \"\"][\"Quantity\"] - (VQ[2] - 1),, VQ[1] \"x\" VQ[2] - 1, VQ[1] * (VQ[2] - 1))\n            }\n        }\n        CalculateSum()\n        WriteSession()\n        Sleep, 125\n    Return\n\n    Delete::\n        If (LV_GetCount()) {\n            If (Row := LV_GetNext()) {\n                LV_Delete(Row)\n                CalculateSum()\n            } Else {\n                LV_Delete(1)\n                CalculateSum()\n            }\n            If (!LV_GetCount()) {\n                GuiControl, Disabled, AddEnter\n                GuiControl, Disabled, AddUp\n                GuiControl, Disabled, AddDown\n                GuiControl, Disabled, AddSell\n                GuiControl, Disabled, AddSubmit\n                GuiControl, Disabled, SubKridi\n                GuiControl, Disabled, AddDelete\n                GuiControl, Disabled, Cancel\n                LV_Delete()\n                GuiControl, Focus, Bc\n            }\n        }\n        WriteSession()\n        Sleep, 125\n    Return\n\n    Esc::\n        If (Selling) {\n            Selling := 0\n            \n            GuiControl, Disabled, AddEnter\n            GuiControl, Disabled, AddUp\n            GuiControl, Disabled, AddDown\n            GuiControl, Disabled, AddSell\n            GuiControl, Disabled, AddSubmit\n            GuiControl, Disabled, SubKridi\n            GuiControl, Disabled, AddDelete\n            GuiControl, Disabled, Cancel\n            \n            GuiControl,, AllSum\n            GuiControl,, Change\n            GuiControl,, GivenMoney\n            GuiControl, Hide, GivenMoney\n            GuiControl, Hide, AllSum\n            GuiControl, Hide, Change\n\n            GuiControl,, Bc\n            GuiControl, Show, Bc\n            GuiControl, Show, AddEnter\n            GuiControl, Show, Nm\n            GuiControl, Show, Qn\n            GuiControl, Show, Sum\n            ;LV_Delete()\n            GuiControl, Focus, Bc\n            WriteSession()\n            CalculateSum()\n        }\n        CheckLatestSells()\n        Sleep, 125\n    Return\n\n    ^F::\n        GuiControlGet, Bc,, Bc\n        GuiControl,, Search, |\n        SearchList := []\n        For Every, Product in ProdDefs {\n            If InStr(Product[\"Name\"], Bc) {\n                SearchList.Push(\"\" Every \"\")\n                GuiControl, , Search, % Product[\"Name\"]\n            }\n        }\n        Sleep, 125\n    Return\n\n    Tab::\n        If (Level = 1) {\n            GuiControlGet, Visi, Visible, ItemsSold\n            Action := (Visi) ? \"Hide\" : \"Show\"\n\n            GuiControl, % Action, ItemsSold\n            GuiControl, % Action, SoldP\n            GuiControl, % Action, CostP\n            GuiControl, % Action, ProfitP\n        } Else {\n            SendInput, {Tab}\n        }\n        Sleep, 125\n    Return\n#If"
  },
  {
    "path": "GUISell_Labels.ahk",
    "content": "GuiClose:\n    IniDelete, Sets\\PID.ini, PID, GUISell\nExitApp\n\nLaunchKeyboard:\n    Run, osk.exe\nReturn\n\nSubKridi:\n    Obj := FileOpen(\"Dump\\tmp.sell\", \"w\")\n    Loop, % LV_GetCount() {\n        LV_GetText(C1, A_Index, 1)\n        LV_GetText(C2, A_Index, 2)\n        LV_GetText(C3, A_Index, 3)\n        LV_GetText(C4, A_Index, 4)\n        LV_GetText(C5, A_Index, 5)\n        Obj.Write(C1 \",\" C2 \",\" C3 \",\" C4 \",\" C5 \"`n\")\n    }\n    Obj.Close()\n\n    RunWait, % \"GUIKridi\" (A_IsCompiled ? \".exe\" : \".ahk\")\n    GoSub, Enter\nReturn\n\nCalc:\n    GuiControlGet, GivenMoney,, GivenMoney\n    GuiControlGet, AllSum,, AllSum\n    GuiControl, , Change\n\n    Change := GivenMoney - AllSum\n    If GivenMoney is Digit\n    {\n        GuiControl, , Change, % (Change >= 0) ? Change : 0\n    }\nReturn\n\nAnalyzeAvail:\n    GuiControlGet, Bc,, Bc\n    If (Bc != \"\") {\n        If (ProdDefs.HasKey(\"\" Bc \"\")) {\n            GuiControl, , Nm,   % ProdDefs[\"\" Bc \"\"][\"Name\"]\n            GuiControl, , Qn,   % ProdDefs[\"\" Bc \"\"][\"Quantity\"]\n            GuiControl, , Sum,  % ProdDefs[\"\" Bc \"\"][\"SellPrice\"]\n            GuiControl, Enabled, AddEnter\n        } Else {\n            GuiControl, , Nm\n            GuiControl, , Sum\n            GuiControl, , Qn\n            GuiControl, Disabled, AddEnter\n        }\n    } Else {\n        GuiControl, , Nm\n        GuiControl, , Sum\n        GuiControl, , Qn\n        GuiControl, Disabled, AddEnter\n    }\nReturn\n\nRemise:\n    GuiControlGet, Remise, , Remise\n    If (Remise > 100) \n        GuiControl, , Remise, % Remise := \"\"\n    CalculateSum()\nReturn\n\nClient:\n    SellDesc:\n        CalculateSum()\n    Return\nReturn\n\nAdditionalInfo:\n    If (AdditionalInfo := !AdditionalInfo) {\n        GuiControl, Enabled, Remise\n        GuiControl, Enabled, Client\n        GuiControl, Enabled, SellDesc\n        GuiControl, ,AdditionalInfoPic, % \"Img\\MIE.png\"\n    } Else {\n        GuiControl, Disabled, Remise\n        GuiControl, Disabled, Client\n        GuiControl, Disabled, SellDesc\n        GuiControl, ,AdditionalInfoPic, % \"Img\\MID.png\"\n    }\n    CalculateSum()\nReturn\n\nViewLastTrans:\n    If (LastestSO) {\n        Run, % \"GUIDetails\" (A_IsCompiled ? \".exe\" : \".ahk\") \" \" LastestSO\n    }\nReturn\n\nSession1:\n    Session := 1\n    Loop, 10 {\n        If (A_Index = 1) {\n            GuiControl, Disabled, Session%A_Index%\n        } Else {\n            GuiControl, Enabled, Session%A_Index%\n        }\n    }\n\n    RestoreSession()\n    CalculateSum()\nReturn\n\nSession2:\n    Session := 2\n    Loop, 10 {\n        If (A_Index = 2) {\n            GuiControl, Disabled, Session%A_Index%\n        } Else {\n            GuiControl, Enabled, Session%A_Index%\n        }\n    }\n\n    RestoreSession()\n    CalculateSum()\nReturn\n\nSession3:\n    Session := 3\n    Loop, 10 {\n        If (A_Index = 3) {\n            GuiControl, Disabled, Session%A_Index%\n        } Else {\n            GuiControl, Enabled, Session%A_Index%\n        }\n    }\n\n    RestoreSession()\n    CalculateSum()\nReturn\n\nSession4:\n    Session := 4\n    Loop, 10 {\n        If (A_Index = 4) {\n            GuiControl, Disabled, Session%A_Index%\n        } Else {\n            GuiControl, Enabled, Session%A_Index%\n        }\n    }\n\n    RestoreSession()\n    CalculateSum()\nReturn\n\nSession5:\n    Session := 5\n    Loop, 10 {\n        If (A_Index = 5) {\n            GuiControl, Disabled, Session%A_Index%\n        } Else {\n            GuiControl, Enabled, Session%A_Index%\n        }\n    }\n\n    RestoreSession()\n    CalculateSum()\nReturn\n\nSession6:\n    Session := 6\n    Loop, 10 {\n        If (A_Index = 6) {\n            GuiControl, Disabled, Session%A_Index%\n        } Else {\n            GuiControl, Enabled, Session%A_Index%\n        }\n    }\n\n    RestoreSession()\n    CalculateSum()\nReturn\n\nSession7:\n    Session := 7\n    Loop, 10 {\n        If (A_Index = 7) {\n            GuiControl, Disabled, Session%A_Index%\n        } Else {\n            GuiControl, Enabled, Session%A_Index%\n        }\n    }\n\n    RestoreSession()\n    CalculateSum()\nReturn\n\nSession8:\n    Session := 8\n    Loop, 10 {\n        If (A_Index = 8) {\n            GuiControl, Disabled, Session%A_Index%\n        } Else {\n            GuiControl, Enabled, Session%A_Index%\n        }\n    }\n\n    RestoreSession()\n    CalculateSum()\nReturn\n\nSession9:\n    Session := 9\n    Loop, 10 {\n        If (A_Index = 9) {\n            GuiControl, Disabled, Session%A_Index%\n        } Else {\n            GuiControl, Enabled, Session%A_Index%\n        }\n    }\n\n    RestoreSession()\n    CalculateSum()\nReturn\n\nSession10:\n    Session := 10\n    Loop, 10 {\n        If (A_Index = 10) {\n            GuiControl, Disabled, Session%A_Index%\n        } Else {\n            GuiControl, Enabled, Session%A_Index%\n        }\n    }\n\n    RestoreSession()\n    CalculateSum()\nReturn\n\nWriteToBc:\n    GuiControlGet, Search,, Search\n    If (Search) {\n        GuiControl,, Bc, % SearchList[Search]\n    }\nReturn\n\nTranscHide:\n    If (++CountToHide = 30) {\n        SetTimer, TranscHide, Off\n        CountToHide := 0\n        GuiControl, Hide, Transc\n        GuiControl, Hide, TranscOK\n    }\nReturn"
  },
  {
    "path": "GUISubmit.ahk",
    "content": "﻿#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\Class_CtlColors.ahk\n#Include, Lib\\Classes\\Class_ImageButton.ahk\n#Include, Lib\\Classes\\Class_GDIplus.ahk\n\n#Include, Lib\\Language.ahk\n\nFolderSet()\n\nIf !Level := LogIn(AdminName := A_Args[1], AdminPass := A_Args[2]) {\n    FileRead, Reciever, Sets\\Login.Hwnd\n    FileOpen(\"Sets\\Login.Request\", \"w\").Write(\"Run|\" A_ScriptFullPath).Close()\n    SendMessage, 0x1000,,,, ahk_id %Reciever%\n    Sleep, 1000\n    MsgBox, 16, % _112, % _114\n    ExitApp\n}\n\nGui, +HwndMain +Resize\nGui, Add, Pic, % \"x0 y0\", Img\\BG.png\nGui, Margin, 10, 10\nGui, Color, 0x7D7D3A\nGui, Font, s14 Bold, Calibri\n\nGui, Add, Text, % \"xm+5 ym w190 vProfByProductText BackgroundTrans\", % _202 \":\"\nGui, Add, DDL, xp yp+30 wp vProfByProduct gShowTheInfo AltSubmit, % _203 \"||\" _204\n\nGui, Add, Text, % \"wp vProfByNameText BackgroundTrans\", % _156 \":\"\nGui, Add, DDL, xp yp+30 wp vProfByName gShowTheInfo\n\nGui, Add, Text, % \"wp vDatesText BackgroundTrans\", % _72 \":\"\nGui, Font, Italic\nGui, Add, ListBox, % \"0x100 wp h\" A_ScreenHeight - 330 \" vDates HwndHCtrl gShowTheInfo Multi\"\nCtlColors.Attach(HCtrl, \"D8D8AD\", \"404000\")\n\nGui, Font, Norm\nGui, Font, s15 Bold\n\nqw := ((A_ScreenWidth - 255) / 2)\n\nButtonTheme := [[3, 0x80FF80, 0x5ABB5A, 0x000000, 2,, 0x008000, 1]\n              , [3, 0x44DB44, 0x2F982F, 0x000000, 2,, 0x008000, 1]\n              , [3, 0x1AB81A, 0x107410, 0x000000, 2,, 0x008000, 1]\n              , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]\n\nGui, Add, Button, % \"x\" A_ScreenWidth - 327 \" ym+40 vEnsBtn w300 h40 HwndHCtrl gValid\", % _9\nImageButton.Create(HCtrl, ButtonTheme*)\n\nGui, Font, s12 Italic\nGui, Add, Edit, % \"xm+220 yp+10 w\" qw \" vOverview -E0x200 HwndHCtrl\"\nCtlColors.Attach(HCtrl, \"000000\", \"FFFF00\")\n\nGui, Font, Norm\nGui, Font, s15 Bold\nGui, Add, ListView, % \"w\" (qw * 2) \" h\" A_ScreenHeight - 240 \" vLV Grid gShowDetails HwndHCtrl BackgroundE6E6E6 -Multi\", % _70 \"|\" _71 \"|\" _39 \"|\" _40 \"|\" _41 \"|\" _79\n\nLV_ModifyCol(1, \"0\")\nLV_ModifyCol(2, qw)\nLV_ModifyCol(3, 0)\nLV_ModifyCol(4, 0)\nLV_ModifyCol(5, 0)\nLV_ModifyCol(6, qw)\n\nGui, Font, s20\nGui, Add, Edit, % \"xm+220 y\" A_ScreenHeight - 132 \" w\" (qw * 2) / 3 \" vSold Center -E0x200 ReadOnly cGreen Border HwndHCtrl\"\nCtlColors.Attach(HCtrl, \"EAEAB5\", \"404000\")\nGui, Font, s15\nGui, Add, Button, xm+5 yp w190 gChart vChart HwndHCtrl h40, % \"→ \" _173 \" ←\"\nImageButton.Create(HCtrl, ButtonTheme*)\n\nGui, Font, s20\nGui, Add, Edit, % \"xp+\" (qw * 2)/3 + 215 \" yp w\" (qw * 2) / 3 \" h40 vBought -E0x200 ReadOnly Center cRed Border HwndHCtrl\"\nCtlColors.Attach(HCtrl, \"EAEAB5\", \"FF0000\")\nGui, Add, Edit, % \"xp+\" (qw * 2)/3 \" yp wp hp vProfitEq -E0x200 ReadOnly Center cGreen Border HwndHCtrl\"\nCtlColors.Attach(HCtrl, \"EAEAB5\", \"008000\")\nThemeAdd()\n\nGui, Font, s12\nLevels := [\"Admin\", \"User\"]\nView := [\"Normal\", \"More Details\"]\nGui, Add, StatusBar\nSB_SetParts(10, 200, 200)\nSB_SetText(_206 \": \" AdminName, 2)\nSB_SetText(_207 \": \" Levels[Level], 3)\nGui, Show, Maximize, Submit GUI\nGlobal LVContent, Header := 1\nLoadAllSells()\nAnalyzeUsers()\nAnalyzeDates()\nGuiControl, Choose, Dates, |1\nReturn\n\n#Include, GUISubmit_Hotkeys.ahk\n#Include, GUISubmit_Functions.ahk\n#Include, GUISubmit_Labels.ahk"
  },
  {
    "path": "GUISubmit_Functions.ahk",
    "content": "ThemeAdd() {\n    Loop, 5 {\n        Gui, Add, Text, % \"y0 x\" 208 + A_Index * 2 \" w1 h\" A_ScreenHeight \" HwndHCtrl\"\n        CtlColors.Attach(HCtrl, \"7D7D64\")\n    }\n}\n\nLogIn(Username, Password) {\n    If (FileExist(\"Sets\\Acc.chu\")) {\n        Account := {}\n        FileRead, RawAccount, Sets\\Acc.chu\n        TextAccount := b64Decode(RawAccount)\n\n        For Each, User in StrSplit(TextAccount, \",\") {\n            LOG := StrSplit(User, \"|\")\n            Account[LOG[1]] := [LOG[2], LOG[3]]\n        }\n\n        If (Account[Username][1] = Password) {\n            If (Account[Username][2] = \"Admin\")\n                Return, 1\n            Else If (Account[Username][2] = \"User\")\n                Return, 2\n        }\n    }\n    Return, 0\n}\n\nb64Encode(string) {\n    VarSetCapacity(bin, StrPut(string, \"UTF-8\")) && len := StrPut(string, &bin, \"UTF-8\") - 1 \n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    VarSetCapacity(buf, size << 1, 0)\n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    return StrGet(&buf)\n}\n\nb64Decode(string) {\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        throw Exception(\"CryptStringToBinary failed\", -1)\n    VarSetCapacity(buf, size, 0)\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        throw Exception(\"CryptStringToBinary failed\", -1)\n    return StrGet(&buf, size, \"UTF-8\")\n}\n\nConvertMillimsToDT(Value, Sign := \"\") {\n    If (Value = \"...\" || !Value)\n        Return\n    ValueArr := StrSplit(Value / 1000, \".\")\n    Return, \"[\" (Sign ? Sign \" \" : \"\") ValueArr[1] (ValueArr[2] ? \".\" RTrim(ValueArr[2], 0) : \"\") \" DT]\"\n}\n\nAddToList(File, DataSum) {\n    FileRead, Content, % File\n    SplitPath, % File, OutFileName\n    Date := SubStr(OutFileName, 1, 8)\n    DataAll  := StrSplit(Content, \"> \")\n\n    DateUser := StrSplit(DataAll[1], \"|\")\n    If (DateUser.Length() = 2) && !LVContent[\"Users\"].HasKey(\"\" DateUser[1] \"\") {\n        LVContent[\"Users\"][\"\" DateUser[1] \"\"] := \"\"\n    }\n\n    Data     := StrSplit(DataAll[3], \";\")\n    If (Data[1] Data[2] Data[3] ~= \"\\b\\d+\\b\") {\n        Names := \"\", Items := {}\n        For Each, Prod in StrSplit(Trim(DataAll[2], \"|\"), \"|\") {\n            Info := StrSplit(Prod, \";\")\n            If !Items.HasKey(\"\" Info[1] \"\") {\n                Items[\"\" Info[1] \"\"] := [Info[2], 0, 0, 0, 0]\n            }\n            Items[\"\" Info[1] \"\"][2] += StrSplit(Info[3], \"x\")[2]\n            Items[\"\" Info[1] \"\"][3] += Info[4]\n            Items[\"\" Info[1] \"\"][4] += Info[6]\n            Items[\"\" Info[1] \"\"][5] += Info[7]\n            Names .= Names ? \" | \" Info[2] : Info[2]\n        }\n\n        C1 := [\"\" Date \"\", File]\n        C2 := DateUser\n        C3 := \"+ \" Data[1] \" \" ConvertMillimsToDT(Data[1], \"+\")\n        C4 := \"- \" Data[2] \" \" ConvertMillimsToDT(Data[2], \"+\")\n        C5 := \"+ \" Data[3] \" \" ConvertMillimsToDT(Data[3], \"+\")\n        C6 := Names\n        C7 := Items\n        C8 := Data\n\n        LVContent[\"Lines\"].Push([C1, C2, C3, C4, C5, C6, C7, C8])\n        If !LVContent[\"Dates\"].HasKey(\"\" Date \"\") {\n            LVContent[\"Dates\"][\"\" Date \"\"] := \"\"\n        }\n    }\n}\n\nLoadAllSells() {\n    DataSum     := [0, 0, 0]\n    LVContent   := { \"Lines\"  : []\n                   , \"Users\"  : {}\n                   , \"Dates\"  : {} }\n\n    GuiControl,, Sold\n    GuiControl,, Bought\n    GuiControl,, ProfitEq\n    Loop, Files, Curr\\*.sell, R\n        DataSum := AddToList(A_LoopFileFullPath, DataSum)\n}\n\nAnalyzeUsers() {\n    Global _74\n    GuiControl,, ProfByName, |\n    GuiControl,, ProfByName, % _74\n    For User in LVContent[\"Users\"] {\n        GuiControl,, ProfByName, % User\n    }\n    GuiControl, Choose, ProfByName, 1\n}\n\nAnalyzeDates() {\n    GuiControl,, Dates, |\n    For Date in LVContent[\"Dates\"] {\n        FormatTime, ThisDay, % Date, yyyy/MM/dd\n        GuiControl,, Dates, % \"-- \" ThisDay \" --\"\n    }\n}\n\nUpdateHeaders() {\n    Global\n    LV_Delete()\n    If (ProfByProduct = 1) && (Header = 2) {\n        For Each, Title in [[_70, 0], [_71, qw], [_39, 0], [_40, 0], [_41, 0], [_79, qw]]\n            LV_ModifyCol(Each, Title[2], Title[1])\n        Header := 1\n    } \n    If (ProfByProduct = 2) && (Header = 1) {\n        For Each, Title in [[_63, sqw := qw / 3], [_38, sqw], [_68, sqw, \" Integer Left\"], [_39, sqw, \" Integer Left\"], [_40, sqw, \" Integer Left\"], [_41, sqw, \" Integer Left\"]]\n            LV_ModifyCol(Each, Title[2] Title[3], Title[1])\n        Header := 2\n    }\n}\n\nUpdateSumValues(DataSum) {\n    GuiControl,, Sold, % \"+ \" DataSum[1] \" \" ConvertMillimsToDT(DataSum[1], \"+\")\n    GuiControl,, Bought, % \"- \" DataSum[2] \" \" ConvertMillimsToDT(DataSum[2], \"-\")\n    GuiControl,, ProfitEq, % \"+ \" DataSum[3] \" \" ConvertMillimsToDT(DataSum[3], \"+\")\n}\n\nFolderSet() {\n    Array := [ \"Curr\"\n    , \"Sets\"\n    , \"Sets\\Def\"\n    , \"Valid\"\n    , \"Dump\"\n    , \"Kr\"\n    , \"CKr\" \n    , \"Unvalid\" \n    , \"Hist\" ]\n\n    For Every, Folder in Array {\n        If !FolderExist(Folder) {\n            FileCreateDir, % Folder\n        }\n    }\n}\n\nFolderExist(Folder) {\n    Return InStr(FileExist(Folder), \"D\")\n}"
  },
  {
    "path": "GUISubmit_Hotkeys.ahk",
    "content": ""
  },
  {
    "path": "GUISubmit_Labels.ahk",
    "content": "Valid:\n    MsgBox, 33, % _174, % _175\n    IfMsgBox, OK\n    {\n        FileCreateDir, % \"Valid\\\" (Now := A_Now)\n        Loop, % LV_GetCount() {\n            LV_GetText(File, A_Index, 1)\n            FileMove, % File, % \"Valid\\\" Now\n        }\n        LoadAllSells()\n        AnalyzeUsers()\n        AnalyzeDates()\n    }\nReturn\n\nChart:\n    GuiControl, Disabled, Chart\n    GuiControlGet, ProfByProduct,, ProfByProduct\n    If (ProfByProduct = 1){\n        If (RowCount := LV_GetCount()) {\n            Dummy := {}\n            Loop, % RowCount {\n                LV_GetText(F, A_Index, 1)\n                LV_GetText(S, A_Index, 3)\n                LV_GetText(B, A_Index, 4)\n                LV_GetText(P, A_Index, 5)\n\n                SplitPath, % F,,,, O\n\n                RegExMatch(S, \"\\d+\", S)\n                RegExMatch(B, \"\\d+\", B)\n                RegExMatch(P, \"\\d+\", P)\n\n                If !Dummy.HasKey(\"\" (O := SubStr(O, 1, 8)) \"\") {\n                    Dummy[\"\" O \"\"] := [0, 0, 0]\n                }\n\n                Dummy[\"\" O \"\"][1] += S\n                Dummy[\"\" O \"\"][2] += B\n                Dummy[\"\" O \"\"][3] += P\n            }\n\n            Dates   := \"\"\n            Sells   := \"\"\n            Costs   := \"\"\n            Profits := \"\"\n\n            For Each, Date in Dummy {\n                FormatTime, D, % Each, yyyy/MM/dd\n                Dates   .= Dates   != \"\"  ? \",'\"  D \"'\"    : \"'\" D \"'\"\n                Sells   .= Sells   != \"\"  ? \",\"  Date[1]   : Date[1]\n                Costs   .= Costs   != \"\"  ? \",\"  Date[2]   : Date[2]\n                Profits .= Profits != \"\"  ? \",\"  Date[3]   : Date[3] \n            }\n            Dates   := \"[\" Dates   \"]\"\n            Sells   := \"[\" Sells   \"]\"\n            Costs   := \"[\" Costs   \"]\"\n            Profits := \"[\" Profits \"]\"\n\n            FileCopy, HighChart\\template\\Chart.html, Template.html, 1\n            FileCopy, HighChart\\template\\Chart.css, Template.css, 1\n            FileCopy, HighChart\\template\\Chart.js, Template.js, 1\n\n            FileRead, JS, Template.js\n\n            JS := StrReplace(JS, \"'[CASH_HELPER_DATES_HOLDER]'\", Dates)\n            JS := StrReplace(JS, \"'[CASH_HELPER_SELLS_HOLDER]'\", Sells)\n            JS := StrReplace(JS, \"'[CASH_HELPER_BUYS_HOLDER]'\", Costs)\n            JS := StrReplace(JS, \"'[CASH_HELPER_PROFITS_HOLDER]'\", Profits)\n\n            FileOpen(\"Template.js\"  , \"w\").Write(JS).Close()\n            Run, Template.html\n        }\n    }\n    GuiControl, Enabled, Chart\nReturn\n\nShowDetails:\n    GuiControlGet, ProfByProduct,, ProfByProduct\n    If !(Row := LV_GetNext()) || ProfByProduct = 2\n        Return\n    LV_GetText(FileName, Row, 1)\n    Run, % \"GUIDetails.\" (A_IsCompiled ? \"exe\" : \"ahk\") \" \" FileName\nReturn\n\nShowTheInfo:\n    GuiControlGet, ProfByProduct,, ProfByProduct\n    GuiControlGet, ProfByName,, ProfByName\n    GuiControlGet, Dates,, Dates\n\n    GuiControl,, Overview, % View[ProfByProduct] \" | \" ProfByName \" | \" Dates\n\n    ProfByName := (ProfByName = _74) ? \"\" : ProfByName\n    UpdateHeaders()\n\n    DataSum := [0, 0, 0]\n    Info    := {}\n    If (ProfByProduct = 1) {\n        For Each, Line in LVContent[\"Lines\"] {\n            FormatTime, ThisDay, % SubStr(Line[1][1], 1, 8), '--' yyyy/MM/dd '--'\n            UName := (Line[2].Length() = 2) ? Line[2][1] : \"\"\n\n            If InStr(Dates, ThisDay) && InStr(UName, ProfByName) {\n                LV_Add(, Line[1][2], Line[2][1] (Line[2][2] ? \" | \" Line[2][2] : \"\"), Line[3], Line[4], Line[5], Line[6])\n                DataSum[1] += Line[8][1]\n                DataSum[2] += Line[8][2]\n                DataSum[3] += Line[8][3]\n                UpdateSumValues(DataSum)\n            }\n        }\n    }\n\n    If (ProfByProduct = 2) {\n        For Each, Line in LVContent[\"Lines\"] {\n            FormatTime, ThisDay, % SubStr(Line[1][1], 1, 8), '--' yyyy/MM/dd '--'\n            UName := (Line[2].Length() = 2) ? Line[2][1] : \"\"\n            If InStr(Dates, ThisDay) && InStr(UName, ProfByName) {\n                For Barcode, Detail in Line[7] {\n                    If !Info.HasKey(\"\" Barcode \"\") {\n                        Info[\"\" Barcode \"\"] := [LV_Add(, Barcode, Detail[1], Detail[2], Detail[3], Detail[4], Detail[5])\n                                              , Detail[1]\n                                              , Detail[2]\n                                              , Detail[3]\n                                              , Detail[4]\n                                              , Detail[5]]\n                    } Else {\n                        Info[\"\" Barcode \"\"][3] += Detail[2]\n                        Info[\"\" Barcode \"\"][4] += Detail[3]\n                        Info[\"\" Barcode \"\"][5] += Detail[4]\n                        Info[\"\" Barcode \"\"][6] += Detail[5]\n                        LV_Modify(Info[\"\" Barcode \"\"][1],,,, Info[\"\" Barcode \"\"][3], Info[\"\" Barcode \"\"][4], Info[\"\" Barcode \"\"][5], Info[\"\" Barcode \"\"][6])\n                    }\n                }\n                DataSum[1] += Line[8][1]\n                DataSum[2] += Line[8][2]\n                DataSum[3] += Line[8][3]\n                UpdateSumValues(DataSum)\n            }\n        }\n    }\nReturn\n\nGuiClose:\n    IniDelete, Sets\\PID.ini, PID, GUISubmit\nExitApp"
  },
  {
    "path": "GUIUpdate.ahk",
    "content": "﻿#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\n#NoEnv\nSetWorkingDir, % A_ScriptDir\n\nGui, Font, Bold s12, Consolas\nGui, +HwndMain -Border +Resize\nFileRead, Version, LVersion.txt\nGui, Add, Text, w300 Center, % \"Cash Helper v\" Version\nGui, Add, Text, w300 Center vDownloadInfo cRed\nGui, Add, Progress, xp yp+50 wp h15 +0x00000008 HwndPB -Smooth\nDllCall(\"User32.dll\\SendMessage\", \"Ptr\", PB, \"Int\", 0x00000400 + 10, \"Ptr\", 1, \"Ptr\", 50)\nSetTimer, CheckSize, 1000\nGui, Show\nReturn\n\nCheckSize:\n    FileGetSize, Size, % A_Temp \"\\Install.exe\", B\n    GuiControl,, DownloadInfo, % \"↓ \" Round(Size/1000000, 2) \" mb...\"\nReturn\n\nGuiClose:\nExitApp"
  },
  {
    "path": "GUIUser.ahk",
    "content": "﻿#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\Class_CtlColors.ahk\n#Include, Lib\\Classes\\Class_ImageButton.ahk\n#Include, Lib\\Classes\\Class_GDIplus.ahk\n\n#Include, Lib\\Language.ahk\n\nFolderSet()\n\nIf !Level := LogIn(AdminName := A_Args[1], AdminPass := A_Args[2]) {\n    FileRead, Reciever, Sets\\Login.Hwnd\n    FileOpen(\"Sets\\Login.Request\", \"w\").Write(\"Run|\" A_ScriptFullPath).Close()\n    SendMessage, 0x1000,,,, ahk_id %Reciever%\n    Sleep, 1000\n    MsgBox, 16, % _112, % _114\n    ExitApp\n}\n\nGui, +HwndMain +Resize\nGui, Add, Pic, % \"x0 y0\", Img\\BG.png\nGui, Margin, 10, 10\nGui, Color, 0x7D7D3A\nGui, Font, s12 Bold, Calibri\n\nButtonTheme := [[3, 0x80FF80, 0x5ABB5A, 0x000000, 2,, 0x008000, 1]\n              , [3, 0x44DB44, 0x2F982F, 0x000000, 2,, 0x008000, 1]\n              , [3, 0x1AB81A, 0x107410, 0x000000, 2,, 0x008000, 1]\n              , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]\n\nButtonTheme2 := [[3, 0xFF6F6F, 0xBC5454, 0x000000, 2,, 0xFF0000, 1]\n               , [3, 0xDC6262, 0x9C4545, 0x000000, 2,, 0xFF0000, 1]\n               , [3, 0xBF5454, 0x8A3C3C, 0x000000, 2,, 0xFF0000, 1]\n               , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0xFF0000, 1]]\nqw := (A_ScreenWidth - 20) / 3\nGui, Add, GroupBox, % \"BackgroundTrans xm+5 ym w\" qw \" h\" A_ScreenHeight - 100, % _156\n\nGui, Add, Button, % \"HwndHCtrl xp+\" qw - 320 \" yp+30 w150 gAddUser h30\", % _89 \" [++]\"\nImageButton.Create(HCtrl, ButtonTheme* )\n\nGui, Add, Button, % \"HwndHCtrl xp+160 yp wp gDelUser h30\", % _91 \" [--]\"\nImageButton.Create(HCtrl, ButtonTheme2* )\n\nGui, Add, ListView, % \"AltSubmit xm+15 ym+65 w\" qw - 20 \" h\" A_ScreenHeight - 180 \" gShowInfo c804000\", % _38 \"|\" _88 \"|\" _207\nLV_ModifyCol(1, (qw-20) / 3)\nLV_ModifyCol(2, (qw-20) / 3)\nLV_ModifyCol(3, (qw-20) / 3)\nGui, Add, GroupBox, % \"BackgroundTrans xm+\" qw + 10 \" ym w\" qw \" h\" A_ScreenHeight - 100, % _211\nGui, Add, Text, xp+10 yp+30 BackgroundTrans, % _214 \": \"\nGui, Add, Pic, % \"xp+\" ((qw - 220) / 2) \" yp+30 w200 h200 vUserPic Border BackgroundTrans gChooseAPic\", Img\\UserLogo.png\nGui, Add, Text, % \"xp-\" ((qw - 220) / 2) \" yp+220 BackgroundTrans\" , % _87 \": \"\nGui, Add, Edit, % \"vUN w\" qw - 20 \" -E0x200 Border cGreen\"\nGui, Add, Text, BackgroundTrans , % _88 \": \"\nGui, Add, Edit, % \"w\" qw - 20 \" vPW -E0x200 Border cRed\"\nGui, Add, Text, BackgroundTrans , % _207 \": \"\nGui, Add, DDL, % \"w\" qw - 20 \" vLVL -E0x200 Border\", %_212%|%_213%\nGui, Add, Button, % \"HwndHCtrl xp yp+50 wp gSaveChanges h30\", % _62\nImageButton.Create(HCtrl, ButtonTheme* )\n\nGui, Add, GroupBox, % \"BackgroundTrans xm+\" (qw + 8) * 2 \" ym w\" qw - 15 \" h\" A_ScreenHeight - 100, % _215\nGui, Add, CheckBox, % \"BackgroundTrans Center xp+10 yp+30 wp-20\", % _216\nGui, Add, CheckBox, % \"BackgroundTrans Center wp\", % _222\nGui, Add, CheckBox, % \"BackgroundTrans Center wp\", % _223\nGui, Add, CheckBox, % \"BackgroundTrans Center wp\", % _217\nGui, Add, CheckBox, % \"BackgroundTrans Center wp\", % _218\nGui, Add, CheckBox, % \"BackgroundTrans Center wp\", % _219\nGui, Add, CheckBox, % \"BackgroundTrans Center wp\", % _220\nGui, Add, CheckBox, % \"BackgroundTrans Center wp\", % _221\n\nGlobal UserList\nLoadAccounts()\n\nGui, Font, s12\nLevels := [\"Admin\", \"User\"]\nGui, Add, StatusBar\nSB_SetParts(10, 200, 200)\nSB_SetText(_206 \": \" AdminName, 2)\nSB_SetText(_207 \": \" Levels[Level], 3)\nGui, Show, Maximize, GUI User\nReturn\n\n#Include, GUIUser_Functions.ahk\n#Include, GUIUser_Hotkeys.ahk\n#Include, GUIUser_Labels.ahk"
  },
  {
    "path": "GUIUser_Functions.ahk",
    "content": "﻿FolderSet() {\n    Array := [ \"Curr\"\n             , \"Sets\"\n             , \"Sets\\Def\"\n             , \"Valid\"\n             , \"Dump\"\n             , \"Kr\"\n             , \"CKr\" \n             , \"Unvalid\" \n             , \"Hist\" ]\n\n    For Every, Folder in Array {\n        If !FolderExist(Folder) {\n            FileCreateDir, % Folder\n        }\n    }\n}\n\nFolderExist(Folder) {\n    Return InStr(FileExist(Folder), \"D\")\n}\n\nLogIn(Username, Password) {\n    If (FileExist(\"Sets\\Acc.chu\")) {\n        Account := {}\n        FileRead, RawAccount, Sets\\Acc.chu\n        TextAccount := b64Decode(RawAccount)\n        \n        For Each, User in StrSplit(TextAccount, \",\") {\n            LOG := StrSplit(User, \"|\")\n            Account[LOG[1]] := [LOG[2], LOG[3]]\n        }\n        \n        If (Account[Username][1] = Password) {\n            If (Account[Username][2] = \"Admin\")\n                Return, 1\n            Else If (Account[Username][2] = \"User\")\n                Return, 2\n        }\n    }\n    Return, 0\n}\n\nUpdateAccounts() {\n    Data := \"\"\n    For User, Info in UserList {\n        Data .= Data != \"\" ? \",\" User \"|\" Info[1] \"|\" Info[2] (Info[3] != \"\" ? \"|\" Info[3] : \"\") : User \"|\" Info[1] \"|\" Info[2] (Info[3] != \"\" ? \"|\" Info[3] : \"\")\n    }\n    If (Data != \"\")\n        FileOpen(\"Sets\\Acc.chu\", \"w\").Write(b64Encode(Data)).Close()\n    Else {\n        FileDelete, Sets\\Acc.chu\n        FileDelete, Sets\\RAcc.chu\n        FileRead, Reciever, Sets\\Login.Hwnd\n        FileOpen(\"Sets\\Login.Request\", \"w\").Write(\"Reload\").Close()\n        SendMessage, 0x1000,,,, ahk_id %Reciever%\n        ExitApp\n    }\n}\n\nLoadAccounts() {\n    UserList := {}\n    LV_Delete()\n    If FileExist(\"Sets\\Acc.chu\") {\n        FileRead, RawAccount, Sets\\Acc.chu\n        Account := b64Decode(RawAccount)\n        For Every, Acc in StrSplit(Account, \",\") {\n            Info := StrSplit(Acc, \"|\")\n            UserList[Info[1]] := [Info[2], Info[3], Info[4]]\n            LV_Add(, Info[1], Info[2], Info[3])\n        }\n    }\n}\n\nNoAdminsLeft(Nm) {\n    tmp := UserList\n    tmp.Delete(Nm)\n    For User, Info in tmp {\n        If (Info[2] = \"ADMIN\") {\n            Return, 0\n        }\n    }\n    Return, 1\n}\n\nb64Encode(string) {\n    VarSetCapacity(bin, StrPut(string, \"UTF-8\")) && len := StrPut(string, &bin, \"UTF-8\") - 1 \n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    VarSetCapacity(buf, size << 1, 0)\n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    return StrGet(&buf)\n}\n\nb64Decode(string) {\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        throw Exception(\"CryptStringToBinary failed\", -1)\n    VarSetCapacity(buf, size, 0)\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        throw Exception(\"CryptStringToBinary failed\", -1)\n    return StrGet(&buf, size, \"UTF-8\")\n}"
  },
  {
    "path": "GUIUser_Hotkeys.ahk",
    "content": "﻿#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.\n; #Warn  ; Enable warnings to assist with detecting common errors.\nSendMode Input  ; Recommended for new scripts due to its superior speed and reliability.\nSetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.\n"
  },
  {
    "path": "GUIUser_Labels.ahk",
    "content": "﻿ShowInfo:\n    If (R := LV_GetNext()) {\n        LV_GetText(Nm, R, 1)\n        LV_GetText(Pw, R, 2)\n        LV_GetText(Lv, R, 3)\n        GuiControl,, UN, % Nm\n        GuiControl,, PW, % Pw\n        GuiControl, ChooseString, LVL, % Lv\n        If (UserList[Nm][3]) {\n            GuiControl,, UserPic, % UserList[Nm][3]\n        } Else {\n            GuiControl,, UserPic, Img\\UserLogo.png\n        }\n    }\nReturn\n\nDelUser:\n    If (R := LV_GetNext()) {\n        LV_GetText(Nm, R, 1)\n        If NoAdminsLeft(Nm) {\n            MsgBox, 33, % _174, % _224\n            IfMsgBox, Cancel\n                Return\n        }\n        MsgBox, 33, % _174, % _91 \" '\" Nm \"'\"\n        IfMsgBox, OK\n        {\n            UserList.Delete(Nm)\n            UpdateAccounts()\n            LoadAccounts()\n        }\n    }\nReturn\n\nAddUser:\n    InputBox, UN, % _87, % _87,, 300, 130\n    InputBox, PW, % _88, % _88,, 300, 130\n    LVL := \"USER\"\n    \n    If (UN != \"\") && (PW != \"\") && !UserList.HasKey(UN) {\n        UserList[UN] := [PW, LVL]\n        UpdateAccounts()\n        LoadAccounts()\n    } Else {\n        Msgbox, 16, % _13, % _225\n    }\nReturn\n\nSaveChanges:\n    GuiControlGet, UN,, UN\n    GuiControlGet, PW,, PW\n    GuiControlGet, LVL,, LVL\n    \n    If (R := LV_GetNext()) && (UN != \"\" && UN = Nm) && (PW != \"\") {\n        UserList[Nm][1] := PW\n        UserList[Nm][2] := LVL\n        UpdateAccounts()\n        LoadAccounts()\n    } Else {\n        Msgbox, 16, % _13, % _225\n    }\nReturn\n\nChooseAPic:\n    if !(R := LV_GetNext()) {\n        Return\n    }\n    LV_GetText(Nm, R, 1)\n    FileSelectFile, UserPic\n    iF (UserPic != \"\") {\n        GuiControl,, UserPic, % UserPic\n        SplitPath, % UserPic,,, OutExt\n        FileCopy, % UserPic, % \"Img\\Users\\\" Nm \".\" OutExt, 1\n        UserList[Nm][3] := \"Img\\Users\\\" Nm \".\" OutExt\n    } Else {\n        GuiControl,, UserPic, Img\\UserLogo.png\n        FileDelete, % UserList[Nm][3]\n        UserList[Nm].RemoveAt(3)\n    }\nReturn\n\nGuiClose:\n    IniDelete, Sets\\PID.ini, PID, GUIUser\nExitApp"
  },
  {
    "path": "GenerateRelease.ahk",
    "content": "﻿#Requires AutoHotkey v1.1\n#NoEnv\nSendMode Input\nSetWorkingDir %A_ScriptDir%\nSetBatchLines, -1\n\n#Persistent\n#SingleInstance, Force\n\n7zipExitCode:= {  0\t    : \"No error\"\n                , 1\t    : \"Warning (Non fatal error(s)). For example, one or more files were locked by some other application, so they were not compressed.\"\n                , 2\t    : \"Fatal error\"\n                , 7\t    : \"Command line error\"\n                , 8\t    : \"Not enough memory for operation\"\n                , 255\t: \"User stopped the process\"}\n\nGui, Add, ListBox, w100 r10 vCompileAHK, % \"StartUp\"\n                                        . \"|Import\"\n                                        . \"|GUIUser\"\n                                        . \"|GUISubmit\"\n                                        . \"|GUISell\"\n                                        . \"|GUIReview\"\n                                        . \"|GUIKridiM\"\n                                        . \"|GUIKridi\"\n                                        . \"|GUIDetails\"\n                                        . \"|GUIDefine\"\n                                        . \"|GUIUpdate\"\n                                        . \"|Uninstall\"\n\nGui, Add, ListBox, xp+110 wp hp vCopyRES, % \"Img\"\n                                         . \"|Lib\"\n\nGui, Add, ListBox, xp+110 wp hp vCompressF, % \"HighChart\"\n                                           . \"|CH-Install\"\n\nGui, Add, Button, xm wp gCompileSel, Compile\nGui, Add, Button, xp yp+25 wp gCompileAll, Compile All\n\nGui, Add, Button, xp+110 yp-25 wp gCopySel, Copy\nGui, Add, Button, xp yp+25 wp gCopyAll, Copy All\n\nGui, Add, Button, xp+110 yp-25 wp gCompressSel, Compress\nGui, Add, Button, xp yp+25 wp gCompressAll, Compress All\n\nGui, Add, Edit, xm w320 vLog -VScroll -HScroll ReadOnly\nFileRead, Version, Version.txt\nGui, Add, Edit, Center cRed vVersion w100, % Version \nGui, Add, Button, wp, Prepare All\nGui, Show,, Create a release\nReturn\n\nCompileSel:\n    GuiControlGet, CompileAHK\n    If (CompileAHK) {\n        For Each, Script in StrSplit(CompileAHK, \"|\") {\n            CompileScript(Script)\n        }\n    }\nReturn\n\nCompileAll:\n    CompileScript(\"StartUp\")\n    CompileScript(\"Import\")\n    CompileScript(\"GUIUser\")\n    CompileScript(\"GUISubmit\")\n    CompileScript(\"GUISell\")\n    CompileScript(\"GUIReview\")\n    CompileScript(\"GUIKridiM\")\n    CompileScript(\"GUIKridi\")\n    CompileScript(\"GUIDetails\")\n    CompileScript(\"GUIDefine\")\n    CompileScript(\"GUIUpdate\")\n    CompileScript(\"Uninstall\")\nReturn\n\nCopySel:\n    GuiControlGet, CopyRES\n    If (CopyRES)\n        PrepareResource(CopyRES)\nReturn\n\nCopyAll:\n    PrepareResource(\"Img\")\n    PrepareResource(\"Lib\")\nReturn\n\nCompressSel:\n    GuiControlGet, CompressF\n    Switch CompressF {\n        Case \"HighChart\":\n            GuiControl,, Log, Compressing into HighChart...\n            FileDelete, __Release\\HighChart.zip\n            RunWait, %ComSpec% /c __Compiler\\7za.exe a -aoa __Release\\HighChart.zip HighChart\\\n            If (ErrorLevel) {\n                Msgbox, 16, Error, % \"Error Code: \" ErrorLevel \"`n\" 7zipExitCode[ErrorLevel]\n            } ELse {\n                GuiControl,, Log, Compressing into HighChart.zip... - OK!\n            }\n        Return\n\n        Case \"CH-Install\":\n            GuiControl,, Log, Compressing into CH-Install.zip...\n            FileDelete, __Release\\CH-Install.zip\n            FileDelete, __Release\\Install.exe\n            GuiControlGet, Version\n            FileOpen(\"Version.txt\", \"w\").Write(Version).Close()\n            FileCopy, Version.txt, __Release\\Version.txt, 1\n            RunWait, %ComSpec% /c cd __Release && ..\\__Compiler\\7za.exe a -aoa CH-Install.zip *\n            If (E := ErrorLevel) {\n                Msgbox, 16, Error, % \"Error Code: \" E \"`n\" 7zipExitCode[E]\n            } ELse {\n                GuiControl,, Log, Compressing into CH-Install.zip... - OK!\n            }\n        Return\n    }\nReturn\n\nCompressAll:\n    GuiControl,, Log, Compressing into HighChart...\n    FileDelete, __Release\\HighChart.zip\n    RunWait, %ComSpec% /c __Compiler\\7za.exe a -aoa __Release\\HighChart.zip HighChart\\\n    If (ErrorLevel) {\n        Msgbox, 16, Error, % \"Error Code: \" ErrorLevel \"`n\" 7zipExitCode[ErrorLevel]\n    } ELse {\n        GuiControl,, Log, Compressing into HighChart.zip... - OK!\n    }\n    \n    GuiControl,, Log, Compressing into CH-Install.zip...\n    FileDelete, __Release\\CH-Install.zip\n    FileDelete, __Release\\Install.exe\n    GuiControlGet, Version\n    FileOpen(\"Version.txt\", \"w\").Write(Version).Close()\n    FileCopy, Version.txt, __Release\\Version.txt, 1\n    RunWait, %ComSpec% /c cd __Release && ..\\__Compiler\\7za.exe a -aoa CH-Install.zip *\n    If (ErrorLevel) {\n        Msgbox, 16, Error, % \"Error Code: \" ErrorLevel \"`n\" 7zipExitCode[ErrorLevel]\n    } ELse {\n        GuiControl,, Log, Compressing into CH-Install.zip... - OK!\n    }\nReturn\n\nButtonPrepareAll:\n    GoSub, CompileAll\n    GoSub, CopyAll\n    GoSub, CompressAll\n    CompileScript(\"Install\")\n    GuiControl,, Log, %A_ScriptDir%\\__Release\\Install.exe\nReturn\n\nGuiClose:\nExitApp\n\nCompileScript(AHKName, MoveTo := \"\") {\n    GuiControlGet, Log\n    RunWait, % \"\"\"__Compiler\\Ahk2Exe.exe\"\"\"\n             . \" /in   \"\"\"    AHKName \".ahk\"\"\"\n             . \" /out  \"\"\"    AHKName \".exe\"\"\"\n             . \" /icon \"      (FileExist(AHKName \".ico\") ? AHKName \".ico\" : \"Default.ico\")\n             . \" /base \"\"__Compiler\\Unicode 32-bit.bin\"\"\"\n    If (!ErrorLevel) {\n        GuiControl,, Log, % \"Compiling \" AHKName \" - OK!\"\n        If (!MoveTo)\n            FileMove, %AHKName%.exe, __Release\\%AHKName%.exe, 1\n        Else \n            FileMove, %AHKName%.exe, __Release\\%AHKName%.exe, 1\n    }\n    Else\n        Msgbox, 16, Error, % \"Compiling \" AHKName \".ahk... - ERROR!\"\n}\n\nPrepareResource(Element) {\n    GuiControl,, Log, % \"Copying \" Element \"...\"\n    Sleep, 250\n    If !InStr(FileExist(Element), \"D\") {\n        FileCopy, % Element, % \"__Release\\\" Element, 1\n    } Else {\n        FileCopyDir, % Element, % \"__Release\\\" Element, 1\n    }\n    If (!ErrorLevel)\n        GuiControl,, Log, % \"Copying \" Element \".. - OK!\"\n    Else\n        Msgbox, 16, Error, % \"Copying \" Element \"... - ERROR!\"\n}"
  },
  {
    "path": "Import.ahk",
    "content": "#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\nGui, Font, Bold s10, Consolas\nGui, Add, Button, w300 gImportAccounts, 1 - Import Accounts\nGui, Add, Button, wp gImportRAccounts Disabled, 2 - Import Remembered Account\nGui, Add, Button, wp gImportPD, 3 - Import Product Definitions\nGui, Add, Button, wp gImportKridi, 4 - Import Kridis\nGui, Add, Button, wp gImportKridiKO, 5 - Import Kridis From Kridi Organizer\nGui, Add, Button, wp gImportSells, 6 - Import Sells\nGui, Show,, Load Custom Setting\nReturn\n\nGuiClose:\nExitApp\n\n;---------------------------\n\nImportKridiKO:\n    FileSelectFolder, Folder\n    If (Folder) {\n        InputBox, Responsable, Responsable, Responsable User Name,, 300, 120\n        If (Responsable != \"\") {\n            Loop, Files, % Folder \"\\*.txt\"\n            {\n                FileRead, CurrentAmount, % A_LoopFileFullPath\n                If (CurrentAmount = \"\")\n                    Continue\n                SplitPath, % A_LoopFileFullPath,,,, Name\n                Name := Trim(Name, \" \")\n                If !InStr(FileExist(\"Kr\\\" Name), \"D\") {\n                    FileCreateDir, % \"Kr\\\" Name\n                }\n                If (CurrentAmount != \"\") {\n                    Result := Eval(CurrentAmount)\n                    Amount := StrJoin(Result, \"`n\")\n                    FormatTime, OutTime, % Now := A_Now, yyyy/MM/dd HH:mm:ss\n                    FileOpen(\"Kr\\\" Name \"\\\" Now \".sell\", \"w\").Write(Responsable \"|\" OutTime \"> > \" Amount \";\" Amount \";0\").Close()\n                }\n                \n            }\n        }\n    Msgbox, % \"OK\"\n    Run, Kr\n    }\nReturn\n\nImportRAccounts:\n    FileSelectFile, File,,, Select Remembered Account File\n    If (File) {\n        Out .= StrReplace(DB_Read(File), \";\", \"|\")\n        Msgbox % \"Data to be encoded:`n\" Out\n        FileOpen(\"Sets\\RAcc.chu\", \"w\").Write(b64Encode(Out)).Close()\n    }\nReturn\n\nImportAccounts:\n    FileSelectFile, File,,, Select Accounts File\n    If (File) {\n        Out := \"\"\n        A := StrSplit(DB_Read(File), \";\")\n        A.RemoveAt(1)\n        \n        Out .= A[1] \"|\" A[2] \"|Admin\"\n        \n        Loop, 2\n            A.RemoveAt(1)\n            \n        For Each, Element in A {\n            UP := StrSplit(Element, \"/\")\n            Out .= \",\" UP[1] \"|\" UP[2] \"|User\"\n        }\n        \n        Msgbox % \"Data to be encoded:`n\" Out\n        \n        If !InStr(FileExist(\"Sets\"), \"D\") {\n            FileCreateDir, Sets\n        }\n        \n        FileOpen(\"Sets\\Acc.chu\", \"w\").Write(b64Encode(Out)).Close()\n        Msgbox % \"OK\"\n        Run, Sets\n    }\nReturn\n\nImportSells:\n    FileSelectFolder, Folder\n    If (Folder) {\n        SplitPath, % Folder,,,, oFolder\n        FileCopyDir, % Folder, % oFolder, 1\n        Run, % oFolder\n        Msgbox % \"Copied:`n-> \" Folder \"`n-> \" oFolder\n        \n        Loop, Files, %oFolder%\\*.db, R\n        {\n            RD := DB_Read(A_LoopFileFullPath)\n            If (RD) {\n                SplitPath, % A_LoopFileFullPath,, OutDir,, OutNameNoExt\n                FileOpen(OutDir \"\\\" OutNameNoExt \".sell\", \"w\").Write(RD).Close()\n            }\n        }\n        \n        Loop, Files, %oFolder%\\*.db, R\n            FileDelete, % A_LoopFileFullPath\n        Msgbox % \"OK\"\n    }\nReturn\n\nImportKridi:\n    FileSelectFolder, Folder\n    If (Folder) {\n        Folders := []\n        Loop, Files, %Folder%\\*, D\n            Folders.Push(A_LoopFileFullPath)\n\n        If !InStr(FileExist(\"Kr\"), \"D\") {\n            FileCreateDir, % \"Kr\"\n        }\n        \n        For Every, Dir in Folders {\n            SplitPath, % Dir, OutFileName, OutDir\n            Msgbox % \"Moving:`n-> \" Dir \"`n-> Kr\\\" DecodeAlpha(OutFileName)\n            FileCopyDir, % Dir, % \"Kr\\\" DecodeAlpha(OutFileName)\n        }\n        Msgbox % \"OK\"\n        Run, Kr\n    }\nReturn\n\nImportPD:\n    FileSelectFile, File\n    If (File) {\n        SplitPath, % File,, OutDir\n\n        If !InStr(FileExist(\"Sets\\Def\"), \"D\") {\n            FileCreateDir, % \"Sets\\Def\"\n        }\n        \n        Msgbox % \"Data to be encoded:`n\" Out := DB_Read(File)\n        \n        For each, one in StrSplit(DB_Read(File), \"|\") {\n            _one := StrSplit(one, \";\")\n            If (_one[1] && _one[2] && _one[3] && _one[4]) {\n                FileOpen(\"Sets\\Def\\\" _one[1] \".def\", \"w\").Write(_one[2] \";\" _one[3] \";\" _one[4] \";\" (_one[5] ? _one[5] : 0)).Close()\n            }\n        }\n        Msgbox % \"OK\"\n        Run, Sets\\Def\n    }\nReturn\n\nb64Encode(string) {\n    VarSetCapacity(bin, StrPut(string, \"UTF-8\")) && len := StrPut(string, &bin, \"UTF-8\") - 1 \n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    VarSetCapacity(buf, size << 1, 0)\n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    return StrGet(&buf)\n}\n\nDB_Read(FileName, FastMode := 0) {\n    DBObj := FileOpen(FileName, \"r\")\n    If !(FastMode) {\n        Hedr := \"\"\n        Loop, 14 {\n            Hedr .= Chr(DBObj.ReadChar())\n        }\n        If (Hedr != \"CH-26259084-DB\")\n            Return, 0\n        Info := \"\"\n        DBObj.Pos := 1024\n        Loop {\n            Info .= (ThisChar := Chr(DBObj.ReadChar()))\n        } Until (ThisChar = \"\")\n    } Else {\n        DBObj.RawRead(Data, Len := DBObj.Length())\n        Pos := 1023, Info := \"\"\n        While (Byte := NumGet(Data, Pos += 1, \"Char\")) {\n            Info .= Chr(Byte)\n        }\n        DBObj.Close()\n    }\nReturn, Decode(Info)\n}\n\nDecode(string) {\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        Return\n    VarSetCapacity(buf, size, 0)\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        Return\nreturn, StrGet(&buf, size, \"UTF-8\")\n}\n\nDecodeAlpha(Str) {\n    DecStr := \"\"\n    Loop, Parse, Str\n    {\n        If (A_LoopField ~= \"[B-Zb-z]\") || (A_LoopField ~= \"[1-9]\")\n            DecStr .= Chr(Asc(A_LoopField) - 1)\n        Else If (A_LoopField = \"A\")\n            DecStr .= Chr(Asc(A_LoopField) + 25)\n        Else If (A_LoopField = \"0\")\n            DecStr .= \"9\"\n        Else\n            DecStr .= A_LoopField\n    }\nReturn, DecStr\n}\n\nEncode(string) {\n    VarSetCapacity(bin, StrPut(string, \"UTF-8\")) && len := StrPut(string, &bin, \"UTF-8\") - 1\n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size))\n        Return\n    VarSetCapacity(buf, size << 1, 0)\n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size))\n        Return\nreturn, StrGet(&buf)\n}\n\nEncodeAlpha(Str) {\n    EncStr := \"\"\n    Loop, Parse, Str\n    {\n        If (A_LoopField ~= \"[A-Ya-y]\") || (A_LoopField ~= \"[0-8]\")\n            EncStr .= Chr(Asc(A_LoopField) + 1)\n        Else If (A_LoopField = \"Z\")\n            EncStr .= Chr(Asc(A_LoopField) - 25)\n        Else If (A_LoopField = \"9\")\n            EncStr .= \"0\"\n        Else\n            EncStr .= A_LoopField\n    }\nReturn, EncStr\n}\n\n;=======================================================================================\n;\n; Function:\t\t\tEval\n; Description:\t\tEvaluate Expressions in Strings.\n; Return value:\t\tAn array (object) with the result of each expression.\n;\n; Author:\t\t\tPulover [Rodolfo U. Batista]\n; Credits:\t\t\tExprEval() by Uberi\n;\n;=======================================================================================\n;\n; Parameters:\n;\n;\t$x:\t\t\t\tThe input string to be evaluated. You can enter multiple expressions\n;\t\t\t\t\t\tseparated by commas (inside the string).\n;\t_CustomVars:\tAn optional Associative Array object containing variables names\n;\t\t\t\t\t  as keys and values to replace them.\n;\t\t\t\t\tFor example, setting it to {A_Index: A_Index} inside a loop will replace\n;\t\t\t\t\t\toccurrences of A_Index with the correct value for the iteration.\n;\t_Init:\t\t\tUsed internally for the recursive calls. If TRUE it resets the static\n;\t\t\t\t\t\tobject _Objects, which holds objects references to be restored.\n;\n;=======================================================================================\nEval($x, _CustomVars := \"\", _Init := true)\n{\n\tStatic _Objects, $Quote := Chr(2)\n\t_Elements := {}\n\tIf (_Init)\n\t\t_Objects := {}\n\t\n\t; Strip off comments\n\t$x := RegExReplace($x, \"U)/\\*.*\\*/\"), $x := RegExReplace($x, \"U)\\s;.*(\\v|$)\")\n\t\n\t; Replace brackets, braces, parenthesis and literal strings\n\t\n\tWhile (RegExMatch($x, \"sU)\"\".*\"\"\", _String))\n\t\t_Elements[\"&_String\" A_Index \"_&\"] := _String\n\t,\t$x := RegExReplace($x, \"sU)\"\".*\"\"\", \"&_String\" A_Index \"_&\",, 1)\n\tWhile (RegExMatch($x, \"\\[([^\\[\\]]++|(?R))*\\]\", _Bracket))\n\t\t_Elements[\"&_Bracket\" A_Index \"_&\"] := _Bracket\n\t,\t$x := RegExReplace($x, \"\\[([^\\[\\]]++|(?R))*\\]\", \"&_Bracket\" A_Index \"_&\",, 1)\n\tWhile (RegExMatch($x, \"\\{[^\\{\\}]++\\}\", _Brace))\n\t\t_Elements[\"&_Brace\" A_Index \"_&\"] := _Brace\n\t,\t$x := RegExReplace($x, \"\\{[^\\{\\}]++\\}\", \"&_Brace\" A_Index \"_&\",, 1)\n\tWhile (RegExMatch($x, \"\\(([^()]++|(?R))*\\)\", _Parent))\n\t\t_Elements[\"&_Parent\" A_Index \"_&\"] := _Parent\n\t,\t$x := RegExReplace($x, \"\\(([^()]++|(?R))*\\)\", \"&_Parent\" A_Index \"_&\",, 1)\n\t\n\t; Split multiple expressions\n\t$z := StrSplit($x, \",\", \" `t\")\n\t\n\tFor $i, $v in $z\n\t{\n\t\t; Check for Ternary expression and evaluate\n\t\tIf (RegExMatch($z[$i], \"([^\\?:=]+?)\\?([^\\?:]+?):(.*)\", _Match))\n\t\t{\n\t\t\tLoop, 3\n\t\t\t{\n\t\t\t\t$o := A_Index, _Match%$o% := Trim(_Match%$o%)\n\t\t\t,\t_Match%$o% := RestoreElements(_Match%$o%, _Elements)\n\t\t\t}\n\t\t\tEvalResult := Eval(_Match1, _CustomVars, false)\n\t\t,\t$y := EvalResult[1]\n\t\t\tIf ($y)\n\t\t\t{\n\t\t\t\tEvalResult := Eval(_Match2, _CustomVars, false)\n\t\t\t,\t$y := StrJoin(EvalResult,, true, false)\n\t\t\t,\tObjName := RegExReplace(_Match2, \"\\W\", \"_\")\n\t\t\t\tIf (IsObject($y))\n\t\t\t\t\t_Objects[ObjName] := $y\n\t\t\t\t$z[$i] := StrReplace($z[$i], _Match, IsObject($y) ? \"\"\"<~#\" ObjName \"#~>\"\"\" : $y)\n\t\t\t}\n\t\t\tElse\n\t\t\t{\n\t\t\t\tEvalResult := Eval(_Match3, _CustomVars, false)\n\t\t\t,\t$y := StrJoin(EvalResult,, true, false)\n\t\t\t,\tObjName := RegExReplace(_Match3, \"\\W\", \"_\")\n\t\t\t\tIf (IsObject($y))\n\t\t\t\t\t_Objects[ObjName] := $y\n\t\t\t\t$z[$i] := StrReplace($z[$i], _Match, IsObject($y) ? \"\"\"<~#\" ObjName \"#~>\"\"\" : $y)\n\t\t\t}\n\t\t}\n\t\t\n\t\t_Pos := 1\n\t\t; Check for Object calls\n\t\tWhile (RegExMatch($z[$i], \"([\\w%]+)(\\.|&_Bracket|&_Parent\\d+_&)[\\w\\.&%]+(.*)\", _Match, _Pos))\n\t\t{\n\t\t\tAssignParse(_Match, VarName, Oper, VarValue)\n\t\t\tIf (Oper != \"\")\n\t\t\t{\n\t\t\t\tVarValue := RestoreElements(VarValue, _Elements)\n\t\t\t,\tEvalResult := Eval(VarValue, _CustomVars, false)\n\t\t\t,\tVarValue := StrJoin(EvalResult)\n\t\t\t\tIf (!IsObject(VarValue))\n\t\t\t\t\tVarValue := RegExReplace(VarValue, \"\"\"{2,2}\", \"\"\"\")\n\t\t\t}\n\t\t\tElse\n\t\t\t\t_Match := StrReplace(_Match, _Match3), VarName := _Match\n\n\t\t\tVarName := RestoreElements(VarName, _Elements)\n\t\t\t\n\t\t\tIf _Match1 is Number\n\t\t\t{\n\t\t\t\t_Pos += StrLen(_Match1)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t\n\t\t\t$y := ParseObjects(VarName, _CustomVars, Oper, VarValue)\n\t\t,\tObjName := RegExReplace(_Match, \"\\W\", \"_\")\n\t\t\t\n\t\t\tIf (IsObject($y))\n\t\t\t\t_Objects[ObjName] := $y\n\t\t\tElse If $y is not Number\n\t\t\t{\n\t\t\t\t$y := \"\"\"\" StrReplace($y, \"\"\"\", $Quote) \"\"\"\"\n\t\t\t,\tHidString := \"&_String\" (ObjCount(_Elements) + 1) \"_&\"\n\t\t\t,\t_Elements[HidString] := $y\n\t\t\t,\t$y := HidString\n\t\t\t}\n\t\t\t$z[$i] := StrReplace($z[$i], _Match, IsObject($y) ? \"\"\"<~#\" ObjName \"#~>\"\"\" : $y,, 1)\n\t\t}\n\t\t\n\t\t; Assign Arrays\n\t\tWhile (RegExMatch($z[$i], \"&_Bracket\\d+_&\", $pd))\n\t\t{\n\t\t\t$z[$i] := StrReplace($z[$i], $pd, _Elements[$pd],, 1)\n\t\t,\tRegExMatch($z[$i], \"\\[(.*)\\]\", _Match)\n\t\t,\t_Match1 := RestoreElements(_Match1, _Elements)\n\t\t,\t$y := Eval(_Match1, _CustomVars, false)\n\t\t,\tObjName := RegExReplace(_Match, \"\\W\", \"_\")\n\t\t,\t_Objects[ObjName] := $y\n\t\t,\t$z[$i] := StrReplace($z[$i], _Match, \"\"\"<~#\" ObjName \"#~>\"\"\")\n\t\t}\n\t\t\n\t\t; Assign Associative Arrays\n\t\tWhile (RegExMatch($z[$i], \"&_Brace\\d+_&\", $pd))\n\t\t{\n\t\t\t$y := {}, o_Elements := {}\n\t\t,\t$o := _Elements[$pd]\n\t\t,\t$o := RestoreElements($o, _Elements)\n\t\t,\t$o := SubStr($o, 2, -1)\n\t\t\tWhile (RegExMatch($o, \"sU)\"\".*\"\"\", _String%A_Index%))\n\t\t\t\to_Elements[\"&_String\" A_Index \"_&\"] := _String%A_Index%\n\t\t\t,\t$o := RegExReplace($o, \"sU)\"\".*\"\"\", \"&_String\" A_Index \"_&\", \"\", 1)\n\t\t\tWhile (RegExMatch($o, \"\\[([^\\[\\]]++|(?R))*\\]\", _Bracket))\n\t\t\t\to_Elements[\"&_Bracket\" A_Index \"_&\"] := _Bracket\n\t\t\t,\t$o := RegExReplace($o, \"\\[([^\\[\\]]++|(?R))*\\]\", \"&_Bracket\" A_Index \"_&\",, 1)\n\t\t\tWhile (RegExMatch($o, \"\\{[^\\{\\}]++\\}\", _Brace))\n\t\t\t\to_Elements[\"&_Brace\" A_Index \"_&\"] := _Brace\n\t\t\t,\t$o := RegExReplace($o, \"\\{[^\\{\\}]++\\}\", \"&_Brace\" A_Index \"_&\",, 1)\n\t\t\tWhile (RegExMatch($o, \"\\(([^()]++|(?R))*\\)\", _Parent))\n\t\t\t\to_Elements[\"&_Parent\" A_Index \"_&\"] := _Parent\n\t\t\t,\t$o := RegExReplace($o, \"\\(([^()]++|(?R))*\\)\", \"&_Parent\" A_Index \"_&\",, 1)\n\t\t\tLoop, Parse, $o, `,, %A_Space%%A_Tab%\n\t\t\t{\n\t\t\t\t$o := StrSplit(A_LoopField, \":\", \" `t\")\n\t\t\t,\t$o.1 := RestoreElements($o.1, o_Elements)\n\t\t\t,\t$o.2 := RestoreElements($o.2, o_Elements)\n\t\t\t,\tEvalResult := Eval($o.2, _CustomVars, false)\n\t\t\t,\t$o.1 := Trim($o.1, \"\"\"\")\n\t\t\t,\t$y[$o.1] := EvalResult[1]\n\t\t\t}\n\t\t\tObjName := RegExReplace(_Match, \"\\W\", \"_\")\n\t\t,\t_Objects[ObjName] := $y\n\t\t,\t$z[$i] := StrReplace($z[$i], $pd, \"\"\"<~#\" ObjName \"#~>\"\"\")\n\t\t}\n\t\t\n\t\t; Restore and evaluate any remaining parenthesis\n\t\tWhile (RegExMatch($z[$i], \"&_Parent\\d+_&\", $pd))\n\t\t{\n\t\t\t_oMatch := StrSplit(_Elements[$pd], \",\", \" `t()\")\n\t\t,\t_Match := RegExReplace(_Elements[$pd], \"\\((.*)\\)\", \"$1\")\n\t\t,\t_Match := RestoreElements(_Match, _Elements)\n\t\t,\tEvalResult := Eval(_Match, _CustomVars, false)\n\t\t,\tRepString := \"(\"\n\t\t\tFor _i, _v in EvalResult\n\t\t\t{\n\t\t\t\tObjName := RegExReplace($pd . _i, \"\\W\", \"_\")\n\t\t\t\tIf (IsObject(_v))\n\t\t\t\t\t_Objects[ObjName] := _v\n\t\t\t\tElse If _v is not Number\n\t\t\t\t{\n\t\t\t\t\tIf (_oMatch[_i] != \"\")\n\t\t\t\t\t{\n\t\t\t\t\t\t_v := \"\"\"\" StrReplace(_v, \"\"\"\", $Quote) \"\"\"\"\n\t\t\t\t\t,\tHidString := \"&_String\" (ObjCount(_Elements) + 1) \"_&\"\n\t\t\t\t\t,\t_Elements[HidString] := _v\n\t\t\t\t\t,\t_v := HidString\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tRepString .= (IsObject(_v) ? \"\"\"<~#\" ObjName \"#~>\"\"\" : _v) \", \"\n\t\t\t}\n\t\t\tRepString := RTrim(RepString, \", \") \")\"\n\t\t,\t$z[$i] := StrReplace($z[$i], $pd, RepString,, 1)\n\t\t}\n\t\t\n\t\t; Check whether the whole string is an object\n\t\t$y := $z[$i]\n\t\tTry\n\t\t{\n\t\t\tIf (_CustomVars.HasKey($y))\n\t\t\t{\n\t\t\t\tIf (IsObject(_CustomVars[$y]))\n\t\t\t\t{\n\t\t\t\t\tObjName := RegExReplace($y, \"\\W\", \"_\")\n\t\t\t\t,\t_Objects[ObjName] := _CustomVars[$y].Clone()\n\t\t\t\t,\t$z[$i] := \"\"\"<~#\" ObjName \"#~>\"\"\"\n\t\t\t\t}\n\t\t\t}\n\t\t\tElse If (IsObject(%$y%))\n\t\t\t{\n\t\t\t\tObjName := RegExReplace($y, \"\\W\", \"_\")\n\t\t\t,\t_Objects[ObjName] := %$y%.Clone()\n\t\t\t,\t$z[$i] := \"\"\"<~#\" ObjName \"#~>\"\"\"\n\t\t\t}\n\t\t}\n\n\t\t; Check for {} object assignment\n\t\tIf (RegExMatch($z[$i], \"\\{\\s*\\}\", _Match))\n\t\t{\n\t\t\t$y := Object()\n\t\t,\tObjName := \"_emptyObj\"\n\t\t,\t_Objects[ObjName] := $y\n\t\t,\t$z[$i] := StrReplace($z[$i], _Match, \"\"\"<~#\" ObjName \"#~>\"\"\")\n\t\t}\n\t\t\n\t\t; Check for Functions\n\t\tWhile (RegExMatch($z[$i], \"s)([\\w%]+)\\((.*?)\\)\", _Match))\n\t\t{\n\t\t\t_Match1 := (RegExMatch(_Match1, \"^%(\\S+)%$\", $pd)) ? %$pd1% : _Match1\n\t\t,\t_Match2 := RestoreElements(_Match2, _Elements)\n\t\t,\t_Params := Eval(_Match2, _CustomVars)\n\t\t,\t$y := %_Match1%(_Params*)\n\t\t,\tObjName := RegExReplace(_Match, \"\\W\", \"_\")\n\t\t\tIf (IsObject($y))\n\t\t\t\t_Objects[ObjName] := $y\n\t\t\tElse If $y is not Number\n\t\t\t{\n\t\t\t\t$y := \"\"\"\" StrReplace($y, \"\"\"\", $Quote) \"\"\"\"\n\t\t\t,\tHidString := \"&_String\" (ObjCount(_Elements) + 1) \"_&\"\n\t\t\t,\t_Elements[HidString] := $y\n\t\t\t,\t$y := HidString\n\t\t\t}\n\t\t\t$z[$i] := StrReplace($z[$i], _Match, IsObject($y) ? \"\"\"<~#\" ObjName \"#~>\"\"\" : $y,, 1)\n\t\t}\n\t\t\n\t\t; Dereference variables in percent signs\n\t\tWhile (RegExMatch($z[$i], \"U)%(\\S+)%\", _Match))\n\t\t\tEvalResult := Eval(_Match1, _CustomVars, false)\n\t\t,\t$z[$i] := StrReplace($z[$i], _Match, EvalResult[1])\n\t\t\n\t\t; ExprEval() cannot parse Unicode strings, so the \"real\" strings are \"hidden\" from ExprCompile() and restored later\n\t\t$z[$i] := RestoreElements($z[$i], _Elements)\n\t,\t__Elements := {}, _Pos := 1\n\t\tWhile (RegExMatch($z[$i], \"sU)\"\"(.*)\"\"\", _String, _Pos))\n\t\t{\n\t\t\tIf (RegExMatch($z[$i], \"sU)^\"\"({.*})\"\"$\", _Brace))\n\t\t\t\t__Elements[\"&_String\" A_Index \"_&\"] := _Brace1\n\t\t\t,\t$z[$i] := RegExReplace($z[$i], \"sU)^\"\"{.*}\"\"$\", \"&_String\" A_Index \"_&\",, 1)\n\t\t\tElse If (RegExMatch($z[$i], \"sU)^\"\"([.*])\"\"$\", _Bracket))\n\t\t\t\t__Elements[\"&_String\" A_Index \"_&\"] := _Bracket1\n\t\t\t,\t$z[$i] := RegExReplace($z[$i], \"sU)^\"\"[.*]\"\"$\", \"&_String\" A_Index \"_&\",, 1)\n\t\t\tElse If (!RegExMatch(_String1, \"^<~#.*#~>$\"))\n\t\t\t\t__Elements[\"&_String\" A_Index \"_&\"] := _String1\n\t\t\t,\t$z[$i] := RegExReplace($z[$i], \"sU)\"\".*\"\"\", \"&_String\" A_Index \"_&\",, 1)\n\t\t\t_Pos++\n\t\t}\n\t\t$z[$i] := RegExReplace($z[$i], \"&_String\\d+_&\", \"\"\"$0\"\"\")\n\t\t\n\t\t; Add concatenate operator after strings where necessary\n\t\tWhile (RegExMatch($z[$i], \"(\"\"&_String\\d+_&\"\"\\s+)([^\\d\\.,\\s:\\+-=*/&|^><\\?])\"))\n\t\t\t$z[$i] := RegExReplace($z[$i], \"(\"\"&_String\\d+_&\"\"\\s+)([^\\d\\.,\\s:\\+-=*/&|^><\\?])\", \"$1. $2\")\n\t\t\n\t\t; Remove remaining parenthesis to allow math operations\n\t\tWhile (RegExMatch($z[$i], \"\\(([^()]++|(?R))*\\)\"))\n\t\t\t$z[$i] := RegExReplace($z[$i], \"\\(([^()]++|(?R))*\\)\", \"$1\")\n\t\t\n\t\t; Evaluate right hand of assignments\n\t\tAssignParse($z[$i], _InVar, _OnOper, _OutValue)\n\t\tIf ((!InStr(_OutValue, \"&_String\")) && (!RegExMatch(_OutValue, \"^\"\"<~#.*#~>\"\"$\")) && (_InVar && _OnOper && _OutValue))\n\t\t\t$z[$i] := _InVar . _OnOper . Eval(_OutValue, _CustomVars, false)[1]\n\n\t\t; Evaluate parsed expression with ExprEval()\n\t\tExprInit()\n\t,\tCompiledExpression := ExprCompile($z[$i])\n\t,\t$Result := ExprEval(CompiledExpression, _CustomVars, _Objects, __Elements)\n\t,\t$Result := StrSplit($Result, Chr(1))\n\t\t\n\t\t; Restore object references\n\t\tFor _i, _v in $Result\n\t\t{\n\t\t\tIf (RegExMatch(_v, \"^<~#(.*)#~>$\", $pd))\n\t\t\t\t$Result[_i] := _Objects[$pd1]\n\t\t}\n\t\t\n\t\t$z[$i] := StrJoin($Result,, false, _Init, _Init)\n\t}\n\t\n\t; If returning to the original call, remove missing expressions from the array\n\tIf (_Init)\n\t{\n\t\t$x := StrSplit($x, \",\", \" `t\")\n\t\tFor _i, _v in $x\n\t\t{\n\t\t\tIf (_v = \"\")\n\t\t\t\t$z.Delete(_i)\n\t\t}\n\t}\n\n\treturn $z\n}\n\nParseObjects(v_String, _CustomVars := \"\", o_Oper := \"\", o_Value := \"\")\n{\n\tStatic _needle := \"([\\w%]+\\.?|\\(([^()]++|(?R))*\\)\\.?|\\[([^\\[\\]]++|(?R))*\\]\\.?)\"\n\t\n\tl_Matches := [], _Pos := 1\n\tWhile (_Pos := RegExMatch(v_String, _needle, l_Found, _Pos))\n\t\tl_Matches.Push(RegExMatch(RTrim(l_Found, \".\"), \"^%(\\S+)%$\", $pd) ? %$pd1% : RTrim(l_Found, \".\"))\n\t,\t_Pos += StrLen(l_Found)\n\tv_Obj := l_Matches[1]\n\tIf (_CustomVars.HasKey(v_Obj))\n\t\t_ArrayObject := _CustomVars[v_Obj]\n\tElse\n\t\tTry _ArrayObject := %v_Obj%\n\tFor $i, $v in l_Matches\n\t{\n\t\tIf (RegExMatch($v, \"^\\((.*)\\)$\"))\n\t\t\tcontinue\n\t\tIf (RegExMatch($v, \"^\\[(.*)\\]$\", l_Found))\n\t\t\t_Key := Eval(l_Found1, _CustomVars, false)\n\t\tElse\n\t\t\t_Key := [$v]\n\t\t$n := l_Matches[$i + 1]\n\t\tIf (RegExMatch($n, \"^\\((.*)\\)$\", l_Found))\n\t\t{\n\t\t\t_Key := _Key[1]\n\t\t,\t_Params := Eval(l_Found1, _CustomVars, false)\n\t\t\t\n\t\t\tTry\n\t\t\t{\n\t\t\t\tIf ($i = 1)\n\t\t\t\t\t_ArrayObject := %_Key%(_Params*)\n\t\t\t\tElse\n\t\t\t\t\t_ArrayObject := _ArrayObject[_Key](_Params*)\n\t\t\t}\n\t\t\tCatch e\n\t\t\t{\n\t\t\t\tIf (InStr(e.Message, \"0x800A03EC\"))\n\t\t\t\t{\n\t\t\t\t\t; Workaround for strange bug in some Excel methods\n\t\t\t\t\tFor _i, _v in _Params\n\t\t\t\t\t\t_Params[_i] := \" \" _v\n\t\t\t\t\n\t\t\t\t\tIf ($i = 1)\n\t\t\t\t\t\t_ArrayObject := %_Key%(_Params*)\n\t\t\t\t\tElse\n\t\t\t\t\t\t_ArrayObject := _ArrayObject[_Key](_Params*)\n\t\t\t\t}\n\t\t\t\tElse\n\t\t\t\t\tThrow e\n\t\t\t}\n\t\t}\n\t\tElse If (($i = l_Matches.Length()) && (o_Value != \"\"))\n\t\t{\n\t\t\tTry\n\t\t\t{\n\t\t\t\tIf (o_Oper = \":=\")\n\t\t\t\t\t_ArrayObject := _ArrayObject[_Key*] := o_Value ? o_Value : false\n\t\t\t\tElse If (o_Oper = \"+=\")\n\t\t\t\t\t_ArrayObject := _ArrayObject[_Key*] += o_Value ? o_Value : false\n\t\t\t\tElse If (o_Oper = \"-=\")\n\t\t\t\t\t_ArrayObject := _ArrayObject[_Key*] -= o_Value ? o_Value : false\n\t\t\t\tElse If (o_Oper = \"*=\")\n\t\t\t\t\t_ArrayObject := _ArrayObject[_Key*] *= o_Value ? o_Value : false\n\t\t\t\tElse If (o_Oper = \"/=\")\n\t\t\t\t\t_ArrayObject := _ArrayObject[_Key*] /= o_Value ? o_Value : false\n\t\t\t\tElse If (o_Oper = \"//=\")\n\t\t\t\t\t_ArrayObject := _ArrayObject[_Key*] //= o_Value ? o_Value : false\n\t\t\t\tElse If (o_Oper = \".=\")\n\t\t\t\t\t_ArrayObject := _ArrayObject[_Key*] .= o_Value ? o_Value : false\n\t\t\t\tElse If (o_Oper = \"|=\")\n\t\t\t\t\t_ArrayObject := _ArrayObject[_Key*] |= o_Value ? o_Value : false\n\t\t\t\tElse If (o_Oper = \"&=\")\n\t\t\t\t\t_ArrayObject := _ArrayObject[_Key*] &= o_Value ? o_Value : false\n\t\t\t\tElse If (o_Oper = \"^=\")\n\t\t\t\t\t_ArrayObject := _ArrayObject[_Key*] ^= o_Value ? o_Value : false\n\t\t\t\tElse If (o_Oper = \">>=\")\n\t\t\t\t\t_ArrayObject := _ArrayObject[_Key*] >>= o_Value ? o_Value : false\n\t\t\t\tElse If (o_Oper = \"<<=\")\n\t\t\t\t\t_ArrayObject := _ArrayObject[_Key*] <<= o_Value ? o_Value : false\n\t\t\t}\n\t\t}\n\t\tElse If ($i > 1)\n\t\t\t_ArrayObject := _ArrayObject[_Key*]\n\t}\n\treturn _ArrayObject\n}\n\nRestoreElements(_String, _Elements)\n{\n\tWhile (RegExMatch(_String, \"&_\\w+_&\", $pd))\n\t\t_String := StrReplace(_String, $pd, _Elements[$pd])\n\treturn _String\n}\n\nAssignParse(String, ByRef VarName, ByRef Oper, ByRef VarValue)\n{\n\tRegExMatch(String, \"(.*?)(:=|\\+=|-=|\\*=|/=|//=|\\.=|\\|=|&=|\\^=|>>=|<<=)(?=([^\"\"]*\"\"[^\"\"]*\"\")*[^\"\"]*$)(.*)\", Out)\n,\tVarName := Trim(Out1), Oper := Out2, VarValue := Trim(Out4)\n}\n\nStrJoin(InputArray, JChr := \"\", Quote := false, Init := true, Unquote := false)\n{\n\tstatic $Quote := Chr(2)\n\tFor i, v in InputArray\n\t{\n\t\tIf (IsObject(v))\n\t\t\treturn v\n\t\tIf v is not Number\n\t\t{\n\t\t\tIf (!Init)\n\t\t\t\tv := RegExReplace(v, \"\"\"{1,2}\", \"\"\"\"\"\")\n\t\t\tIf (Quote)\n\t\t\t\tv := \"\"\"\" v \"\"\"\"\n\t\t\tIf (Unquote)\n\t\t\t\tWhile (RegExMatch(v, \"\"\"{2}\"))\n\t\t\t\t\tv := RegExReplace(v, \"\"\"{2}\", \"\"\"\")\n\t\t\tv := StrReplace(v, $Quote, \"\"\"\")\n\t\t}\n\t\tJoinedStr .= v . JChr\n\t}\n\tIf (JChr != \"\")\n\t\tJoinedStr := SubStr(JoinedStr, 1, -(StrLen(JChr)))\n\treturn JoinedStr\n}\n\nObjCount(Obj)\n{\n\treturn NumGet(&Obj + 4 * A_PtrSize)\n}\n\n;##################################################\n; Author: Uberi\n; Modified by: Pulover\n; http://autohotkey.com/board/topic/64167-expreval-evaluate-expressions/\n;##################################################\nExprInit()\n{\n\tglobal\n\tExprot:=\"`n:= 0 R 2`n+= 0 R 2`n-= 0 R 2`n*= 0 R 2`n/= 0 R 2`n//= 0 R 2`n.= 0 R 2`n|= 0 R 2`n&= 0 R 2`n^= 0 R 2`n>>= 0 R 2`n<<= 0 R 2`n|| 3 L 2`n&& 4 L 2`n\\! 5 R 1`n= 6 L 2`n== 6 L 2`n<> 6 L 2`n!= 6 L 2`n> 7 L 2`n< 7 L 2`n>= 7 L 2`n<= 7 L 2`n\\. 8 L 2`n& 9 L 2`n^ 9 L 2`n| 9 L 2`n<< 10 L 2`n>> 10 L 2`n+ 11 L 2`n- 11 L 2`n* 12 L 2`n/ 12 L 2`n// 12 L 2`n\\- 13 R 1`n! 13 R 1`n~ 13 R 1`n\\& 13 R 1`n\\* 13 R 1`n** 14 R 2`n\\++ 15 R 1`n\\-- 15 R 1`n++ 15 L 1`n-- 15 L 1`n. 16 L 2`n`% 17 R 1`n\",Exprol:=SubStr(RegExReplace(Exprot,\"iS) \\d+ [LR] \\d+\\n\",\"`n\"),2,-1)\n\tSort,Exprol,FExprols\n}\n\nExprCompile(e)\n{\n\te:=Exprt(e)\n\tLoop,Parse,e,% Chr(1)\n\t{\n\t\tlf:=A_LoopField,tt:=SubStr(lf,1,1),to:=SubStr(lf,2)\n\t\tIf tt=f\n\t\tExprp1(s,lf)\n\t\tElse If lf=,\n\t\t{\n\t\t\tWhile,s<>\"\"&&Exprp3(s)<>\"(\"\n\t\t\tExprp1(ou,Exprp2(s))\n\t\t}\n\t\tElse If tt=o\n\t\t{\n\t\t\tWhile,SubStr(so:=Exprp3(s),1,1)=\"o\"\n\t\t\t{\n\t\t\t\tta:=Expras(to),tp:=Exprpr(to),sop:=Exprpr(SubStr(so,2))\n\t\t\t\tIf ((ta=\"L\"&&tp>sop)||(ta=\"R\"&&tp>=sop))\n\t\t\t\tBreak\n\t\t\t\tExprp1(ou,Exprp2(s))\n\t\t\t}\n\t\t\tExprp1(s,lf)\n\t\t}\n\t\tElse If lf=(\n\t\tExprp1(s,\"(\")\n\t\tElse If lf=)\n\t\t{\n\t\t\tWhile,Exprp3(s)<>\"(\"\n\t\t\t{\n\t\t\t\tIf s=\n\t\t\t\tReturn\n\t\t\t\tExprp1(ou,Exprp2(s))\n\t\t\t}\n\t\t\tExprp2(s)\n\t\t\tIf (SubStr(Exprp3(s),1,1)=\"f\")\n\t\t\tExprp1(ou,Exprp2(s))\n\t\t}\n\t\tElse Exprp1(ou,lf)\n\t}\n\tWhile,s<>\"\"\n\t{\n\t\tt1:=Exprp2(s)\n\t\tIf t1 In (,)\n\t\tReturn\n\t\tExprp1(ou,t1)\n\t}\n\tReturn,ou\n}\n\nExprEval(e,lp,eo,el)\n{\n\tc1:=Chr(1)\n\tLoop,Parse,e,%c1%\n\t{\n\t\tlf:=A_LoopField,tt:=SubStr(lf,1,1),t:=SubStr(lf,2)\n\t\tWhile (RegExMatch(lf,\"&_String\\d+_&\",rm))\n\t\tlf:=StrReplace(lf,rm,el[rm])\n\t\tIf tt In l,v\n\t\tlf:=Exprp1(s,lf)\n\t\tElse{\n\t\t\tIf tt=f\n\t\t\tt1:=InStr(t,\" \"),a:=SubStr(t,1,t1-1),t:=SubStr(t,t1+1)\n\t\t\tElse a:=Exprac(t)\n\t\t\tExprp1(s,Exprap(t,s,a,lp,eo))\n\t\t}\n\t}\n\t\n\tLoop,Parse,s,%c1%\n\t{\n\t\tlf:=A_LoopField\n\t\tIf (SubStr(lf,1,1)=\"v\")\n\t\tt1:=SubStr(lf,2),r.=(lp.HasKey(t1) ? lp[t1] : %t1%) . c1\n\t\tElse r.=SubStr(lf,2) . c1\n\t}\n\tReturn,SubStr(r,1,-1)\n}\n\nExprap(o,ByRef s,ac,lp,eo)\n{\n\tlocal i,t1,a1,a2,a3,a4,a5,a6,a1v,a2v,a3v,a4v,a5v,a6v,a7v,a8v,a9v\n\tLoop,%ac%\n\ti:=ac-(A_Index-1),t1:=Exprp2(s),a%i%:=SubStr(t1,2),(SubStr(t1,1,1)=\"v\")?(a%i%v:=1)\n\tLoop, 10\n\t{\n\t\tIf (RegExMatch(a%A_Index%,\"^<~#(.*)#~>$\",rm))\n\t\ta%A_Index%:=eo[rm1],a%A_Index%v:=0\n\t\tElse If (lp.HasKey(a%A_Index%))\n\t\ta%A_Index%:=lp[a%A_Index%],a%A_Index%v:=0\n\t}\n\tIf o=++\n\tReturn,\"l\" . %a1%++\n\tIf o=--\n\tReturn,\"l\" . %a1%--\n\tIf o=\\++\n\tReturn,\"l\" . ++%a1%\n\tIf o=\\--\n\tReturn,\"l\" . --%a1%\n\tIf o=`%\n\tReturn,\"v\" . %a1%\n\tIf o=!\n\tReturn,\"l\" . !(a1v ? %a1%:a1)\n\tIf o=\\!\n\tReturn,\"l\" . (a1v ? %a1%:a1)\n\tIf o=~\n\tReturn,\"l\" . ~(a1v ? %a1%:a1)\n\tIf o=**\n\tReturn,\"l\" . ((a1v ? %a1%:a1)**(a2v ? %a2%:a2))\n\tIf o=*\n\tReturn,\"l\" . ((a1v ? %a1%:a1)*(a2v ? %a2%:a2))\n\tIf o=\\*\n\tReturn,\"l\" . *(a1v ? %a1%:a1)\n\tIf o=/\n\tReturn,\"l\" . ((a1v ? %a1%:a1)/(a2v ? %a2%:a2))\n\tIf o=//\n\tReturn,\"l\" . ((a1v ? %a1%:a1)//(a2v ? %a2%:a2))\n\tIf o=+\n\tReturn,\"l\" . ((a1v ? %a1%:a1)+(a2v ? %a2%:a2))\n\tIf o=-\n\tReturn,\"l\" . ((a1v ? %a1%:a1)-(a2v ? %a2%:a2))\n\tIf o=\\-\n\tReturn,\"l\" . -(a1v ? %a1%:a1)\n\tIf o=<<\n\tReturn,\"l\" . ((a1v ? %a1%:a1)<<(a2v ? %a2%:a2))\n\tIf o=>>\n\tReturn,\"l\" . ((a1v ? %a1%:a1)>>(a2v ? %a2%:a2))\n\tIf o=&\n\tReturn,\"l\" . ((a1v ? %a1%:a1)&(a2v ? %a2%:a2))\n\tIf o=\\&\n\tReturn,\"l\" . &(a1v ? %a1%:a1)\n\tIf o=^\n\tReturn,\"l\" . ((a1v ? %a1%:a1)^(a2v ? %a2%:a2))\n\tIf o=|\n\tReturn,\"l\" . ((a1v ? %a1%:a1)|(a2v ? %a2%:a2))\n\tIf o=\\.\n\tReturn,\"l\" . ((a1v ? %a1%:a1) . (a2v ? %a2%:a2))\n\tIf o=.\n\tReturn,\"v\" . a1\n\tIf o=<\n\tReturn,\"l\" . ((a1v ? %a1%:a1)<(a2v ? %a2%:a2))\n\tIf o=>\n\tReturn,\"l\" . ((a1v ? %a1%:a1)>(a2v ? %a2%:a2))\n\tIf o==\n\tReturn,\"l\" . ((a1v ? %a1%:a1)=(a2v ? %a2%:a2))\n\tIf o===\n\tReturn,\"l\" . ((a1v ? %a1%:a1)==(a2v ? %a2%:a2))\n\tIf o=<>\n\tReturn,\"l\" . ((a1v ? %a1%:a1)<>(a2v ? %a2%:a2))\n\tIf o=!=\n\tReturn,\"l\" . ((a1v ? %a1%:a1)!=(a2v ? %a2%:a2))\n\tIf o=>=\n\tReturn,\"l\" . ((a1v ? %a1%:a1)>=(a2v ? %a2%:a2))\n\tIf o=<=\n\tReturn,\"l\" . ((a1v ? %a1%:a1)<=(a2v ? %a2%:a2))\n\tIf o=&&\n\tReturn,\"l\" . ((a1v ? %a1%:a1)&&(a2v ? %a2%:a2))\n\tIf o=||\n\tReturn,\"l\" . ((a1v ? %a1%:a1)||(a2v ? %a2%:a2))\n\tIf o=:=\n\t{\n\t\t%a1%:=(a2v ? %a2%:a2)\n\t\tReturn,\"v\" . a1\n\t}\n\tIf o=+=\n\t{\n\t\t%a1%+=(a2v ? %a2%:a2)\n\t\tReturn,\"v\" . a1\n\t}\n\tIf o=-=\n\t{\n\t\t%a1%-=(a2v ? %a2%:a2)\n\t\tReturn,\"v\" . a1\n\t}\n\tIf o=*=\n\t{\n\t\t%a1%*=(a2v ? %a2%:a2)\n\t\tReturn,\"v\" . a1\n\t}\n\tIf o=/=\n\t{\n\t\t%a1%/=(a2v ? %a2%:a2)\n\t\tReturn,\"v\" . a1\n\t}\n\tIf o=//=\n\t{\n\t\t%a1%//=(a2v ? %a2%:a2)\n\t\tReturn,\"v\" . a1\n\t}\n\tIf o=.=\n\t{\n\t\t%a1%.=(a2v ? %a2%:a2)\n\t\tReturn,\"v\" . a1\n\t}\n\tIf o=|=\n\t{\n\t\t%a1%|=(a2v ? %a2%:a2)\n\t\tReturn,\"v\" . a1\n\t}\n\tIf o=&=\n\t{\n\t\t%a1%&=(a2v ? %a2%:a2)\n\t\tReturn,\"v\" . a1\n\t}\n\tIf o=^=\n\t{\n\t\t%a1%^=(a2v ? %a2%:a2)\n\t\tReturn,\"v\" . a1\n\t}\n\tIf o=>>=\n\t{\n\t\t%a1%>>=(a2v ? %a2%:a2)\n\t\tReturn,\"v\" . a1\n\t}\n\tIf o=<<=\n\t{\n\t\t%a1%<<=(a2v ? %a2%:a2)\n\t\tReturn,\"v\" . a1\n\t}\n\tIf ac=0\n\tReturn,\"l\" . %o%()\n\tIf ac=1\n\tReturn,\"l\" . %o%(a1v ? %a1%:a1)\n\tIf ac=2\n\tReturn,\"l\" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2))\n\tIf ac=3\n\tReturn,\"l\" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2),(a3v ? %a3%:a3))\n\tIf ac=4\n\tReturn,\"l\" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2),(a3v ? %a3%:a3),(a4v ? %a4%:a4))\n\tIf ac=5\n\tReturn,\"l\" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2),(a3v ? %a3%:a3),(a4v ? %a4%:a4),(a5v ? %a5%:a5))\n\tIf ac=6\n\tReturn,\"l\" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2),(a3v ? %a3%:a3),(a4v ? %a4%:a4),(a5v ? %a5%:a5),(a6v ? %a6%:a6))\n\tIf ac=7\n\tReturn,\"l\" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2),(a3v ? %a3%:a3),(a4v ? %a4%:a4),(a5v ? %a5%:a5),(a6v ? %a6%:a6),(a7v ? %a7%:a7))\n\tIf ac=8\n\tReturn,\"l\" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2),(a3v ? %a3%:a3),(a4v ? %a4%:a4),(a5v ? %a5%:a5),(a6v ? %a6%:a6),(a7v ? %a7%:a7),(a8v ? %a8%:a8))\n\tIf ac=9\n\tReturn,\"l\" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2),(a3v ? %a3%:a3),(a4v ? %a4%:a4),(a5v ? %a5%:a5),(a6v ? %a6%:a6),(a7v ? %a7%:a7),(a8v ? %a8%:a8),(a9v ? %a9%:a9))\n\tIf ac=10\n\tReturn,\"l\" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2),(a3v ? %a3%:a3),(a4v ? %a4%:a4),(a5v ? %a5%:a5),(a6v ? %a6%:a6),(a7v ? %a7%:a7),(a8v ? %a8%:a8),(a9v ? %a9%:a9),(a10v ? %a10%:a10))\n}\n\nExprt(e)\n{\n\tglobal Exprol\n\tc1:=Chr(1),f:=1,f1:=1\n\tWhile,(f:=RegExMatch(e,\"S)\"\"(?:[^\"\"]|\"\"\"\")*\"\"\",m,f))\n\t{\n\t\tt1:=SubStr(m,2,-1)\n\t,\tt1:=StrReplace(t1,\"\"\"\"\"\",\"\"\"\")\n\t,\tt1:=StrReplace(t1,\"'\",\"'27\")\n\t,\tt1:=StrReplace(t1,\"````\",c1)\n\t,\tt1:=StrReplace(t1,\"``n\",\"`n\")\n\t,\tt1:=StrReplace(t1,\"``r\",\"`r\")\n\t,\tt1:=StrReplace(t1,\"``b\",\"`b\")\n\t,\tt1:=StrReplace(t1,\"``t\",\"`t\")\n\t,\tt1:=StrReplace(t1,\"``v\",\"`v\")\n\t,\tt1:=StrReplace(t1,\"``a\",\"`a\")\n\t,\tt1:=StrReplace(t1,\"``f\",\"`f\")\n\t,\tt1:=StrReplace(t1,c1,\"``\")\n\t\tSetFormat,IntegerFast,Hex\n\t\tWhile,RegExMatch(t1,\"iS)[^\\w']\",c)\n\t\tt1:=StrReplace(t1,c,\"'\" . SubStr(\"0\" . SubStr(Asc(c),3),-1))\n\t\tSetFormat,IntegerFast,D\n\t\te1.=SubStr(e,f1,f-f1) . c1 . \"l\" . t1 . c1,f+=StrLen(m),f1:=f\n\t}\n\te1.=SubStr(e,f1),e:=InStr(e1,\"\"\"\")? \"\":e1,e1:=\"\",e:=RegExReplace(e,\"S)/\\*.*?\\*/|[ \\t]`;.*?(?=\\r|\\n|$)\")\n,\te:=StrReplace(e,\"`t\",\" \")\n,\te:=RegExReplace(e,\"S)([\\w#@\\$] +|\\) *)(?=\" . Chr(1) . \"*[\\w#@\\$\\(])\",\"$1 . \")\n,\te:=StrReplace(e,\" . \",\"\\.\")\n,\te:=StrReplace(e,\" \")\n,\tf:=1,f1:=1\n\tWhile,(f:=RegExMatch(e,\"iS)(^|[^\\w#@\\$\\.'])(0x[0-9a-fA-F]+|\\d+(?:\\.\\d+)?|\\.\\d+)(?=[^\\d\\.]|$)\",m,f))\n\t{\n\t\tIf ((m1=\"\\\") && (RegExMatch(m2,\"\\.\\d+\")))\n\t\tm1:=\"\",m2:=SubStr(m2,2)\n\t\tm2+=0\n\t\tm2:=StrReplace(m2,\".\",\"'2E\",,1)\n\t\te1.=SubStr(e,f1,f-f1) . m1 . c1 . \"n\" . m2 . c1,f+=StrLen(m),f1:=f\n\t}\n\te:=e1 . SubStr(e,f1),e1:=\"\" ; ,e:=RegExReplace(e,\"S)(^|\\(|[^\" . c1 . \"-])-\" . c1 . \"n\",\"$1\" . c1 . \"n'2D\")\n,\te:=StrReplace(e,c1 \"n\",c1 \"l\")\n,\te:=RegExReplace(e,\"\\\\\\.(\\d+)\\.(\\d+)\",c1 . \"l$1'2E$2\" . c1)\n,\te:=RegExReplace(RegExReplace(e,\"S)(%[\\w#@\\$]{1,253})%\",\"$1\"),\"S)(?:^|[^\\w#@\\$'\" . c1 . \"])\\K[\\w#@\\$]{1,253}(?=[^\\(\\w#@\\$]|$)\",c1 . \"v$0\" . c1),f:=1,f1:=1\n\tWhile,(f:=RegExMatch(e,\"S)(^|[^\\w#@\\$'])([\\w#@\\$]{1,253})(?=\\()\",m,f))\n\t{\n\t\tt1:=f+StrLen(m)\n\t\tIf (SubStr(e,t1+1,1)=\")\")\n\t\tac=0\n\t\tElse\n\t\t{\n\t\t\tIf !Exprmlb(e,t1,fa)\n\t\t\tReturn\n\t\t\tfa:=StrReplace(fa,\"`,\",\"`,\",c)\n\t\t\tac:=c+1\n\t\t}\n\t\te1.=SubStr(e,f1,f-f1) . m1 . c1 . \"f\" . ac . \"'20\" . m2 . c1,f+=StrLen(m),f1:=f\n\t}\n\te:=e1 . SubStr(e,f1),e1:=\"\"\n,\te:=StrReplace(e,\"\\.\" c1 \"vNot\" c1 \"\\.\",\"!\")\n,\te:=StrReplace(e,\"\\.\" c1 \"vAnd\" c1 \"\\.\",\"&&\")\n,\te:=StrReplace(e,\"\\.\" c1 \"vOr\" c1 \"\\.\",\"||\")\n,\te:=StrReplace(e,c1 \"vNot\" c1 \"\\.\",\"!\")\n,\te:=StrReplace(e,c1 \"vAnd\" c1 \"\\.\",\"&&\")\n,\te:=StrReplace(e,c1 \"vOr\" c1 \"\\.\",\"||\")\n,\te:=StrReplace(e,\"\\.\" c1 \"vNot\" c1 . c1,\"!\")\n,\te:=StrReplace(e,\"\\.\" c1 \"vAnd\" c1 . c1,\"&&\")\n,\te:=StrReplace(e,\"\\.\" c1 \"vOr\" c1 . c1,\"||\")\n,\te:=StrReplace(e,c1 \"vNot\" c1 . c1,\"!\")\n,\te:=StrReplace(e,c1 \"vAnd\" c1 . c1,\"&&\")\n,\te:=StrReplace(e,c1 \"vOr\" c1 . c1,\"||\")\n,\te:=RegExReplace(e,\"S)(^|[^\" . c1 . \"\\)-])-\" . c1 . \"(?=[lvf])\",\"$1\\-\" . c1)\n,\te:=RegExReplace(e,\"S)(^|[^\" . c1 . \"\\)&])&\" . c1 . \"(?=[lvf])\",\"$1\\&\" . c1)\n,\te:=RegExReplace(e,\"S)(^|[^\" . c1 . \"\\)\\*])\\*\" . c1 . \"(?=[lvf])\",\"$1\\*\" . c1)\n,\te:=RegExReplace(e,\"S)(^|[^\" . c1 . \"\\)])(\\+\\+|--)\" . c1 . \"(?=[lvf])\",\"$1\\$2\" . c1)\n,\tt1:=RegExReplace(Exprol,\"S)[\\\\\\.\\*\\?\\+\\[\\{\\|\\(\\)\\^\\$]\",\"\\$0\")\n,\tt1:=StrReplace(t1,\"`n\",\"|\")\n,\te:=RegExReplace(e,\"S)\" . t1,c1 . \"o$0\" . c1)\n,\te:=StrReplace(e,\"`,\",c1 \"`,\" c1)\n,\te:=StrReplace(e,\"(\",c1 \"(\" c1)\n,\te:=StrReplace(e,\")\",c1 \")\" c1)\n,\te:=StrReplace(e,c1 . c1,c1)\n\tIf RegExMatch(e,\"S)\" . c1 . \"[^lvfo\\(\\),\\n]\")\n\tReturn\n\te:=SubStr(e,2,-1),f:=0\n\tWhile,(f:=InStr(e,\"'\",False,f + 1))\n\t{\n\t\tIf ((t1:=SubStr(e,f+1,2))<>27)\n\t\te:=StrReplace(e,\"'\" t1,Chr(\"0x\" . t1))\n\t}\n\te:=StrReplace(e,\"'27\",\"'\")\n\tReturn,e\n}\n\nExprols(o1,o2)\n{\n\tReturn,StrLen(o2)-StrLen(o1)\n}\n\nExprpr(o)\n{\n\tglobal Exprot\n\tt:=InStr(Exprot,\"`n\" . o . \" \")+StrLen(o)+2\n\tReturn,SubStr(Exprot,t,InStr(Exprot,\" \",0,t)-t)\n}\n\nExpras(o)\n{\n\tglobal Exprot\n\tReturn,SubStr(Exprot,InStr(Exprot,\" \",0,InStr(Exprot,\"`n\" . o . \" \")+StrLen(o)+2)+1,1)\n}\n\nExprac(o)\n{\n\tglobal Exprot\n\tReturn,SubStr(Exprot,InStr(Exprot,\"`n\",0,InStr(Exprot,\"`n\" . o . \" \")+1)-1,1)\n}\n\nExprmlb(ByRef s,p,ByRef o=\"\",b=\"(\",e=\")\")\n{\n\tt:=SubStr(s,p),bc:=0,VarSetCapacity(o,StrLen(t))\n\tIf (SubStr(t,1,1)<>b)\n\tReturn,0\n\tLoop,Parse,t\n\t{\n\t\tlf:=A_LoopField\n\t\tIf lf=%b%\n\t\tbc++\n\t\tElse If lf=%e%\n\t\t{\n\t\t\tbc--\n\t\t\tIf bc=0\n\t\t\tReturn,p\n\t\t}\n\t\tElse If bc=1\n\t\to.=lf\n\t\tp++\n\t}\n\tReturn,0\n}\n\nExprp1(ByRef dl,d)\n{\n\tdl.=((dl=\"\")? \"\":Chr(1)) . d\n}\n\nExprp2(ByRef dl)\n{\n\tt:=InStr(dl,Chr(1),0,0),t ?(t1:=SubStr(dl,t+1),dl:=SubStr(dl,1,t-1)):(t1:=dl,dl:=\"\")\n\tReturn,t1\n}\n\nExprp3(ByRef dl)\n{\n\tReturn,SubStr(dl,InStr(dl,Chr(1),0,0)+1)\n}\n"
  },
  {
    "path": "Install.ahk",
    "content": "﻿#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\nFileInstall, __Release\\CH-Install.zip, CH-Install.zip, 1\nFileInstall, Install.png, Install.png, 1\n\nGui, -MinimizeBox\nGui, Font, s20 Bold, Calibri\nGui, Color, White\nGui, Add, Text, Center BackgroundTrans w400, Cash Helper\nGui, Add, Pic, xm yp-10 w64 h64 BackgroundTrans, Install.png\nGui, Font, Norm\nGui, Font, s10 Bold\nGui, Add, Edit, ReadOnly w290 vLoc, %A_ProgramFiles%\\Cash Helper\nIS := InstallState()\nGui, Font, s8\nGui, Add, Button, xp+300 yp w100 vCG, Change\nGui, Font, s10\nGui, Add, Checkbox, xp-300 yp+30 Checked gInstallWay vIAU, Install for all users\nGui, Add, Checkbox, yp+20 vPort, Portable\nGui, Add, Button, w100 vIB gButtonInstall, % IS[1]\nGui, Add, Progress, w400 vPB -Smooth h15 Hidden\nGui, Font, s8\nGui, Add, Text, xp yp+17 wp Center vPercent BackgroundTrans\n\nFileInstall, __Release\\Version.txt, Version.txt, 1\n\nFileRead, Version, Version.txt\nGui, Show,, Install Setup %Version%\nGuiControl, Focus, IB\nReturn\nInstallWay:\n    GuiControlGet, IAU\n    If (IAU) {\n        GuiControl,, Loc, %A_ProgramFiles%\\Cash Helper\n    } Else {\n        GuiControl,, Loc, %A_AppData%\\Cash Helper\n    }\n    IS := InstallState()\nReturn\n\nGuiClose:\nExitApp\n\nButtonInstall:\n    If !FileExist(\"CH-Install.zip\") {\n        MsgBox, 16, Error, Install package not found.\n        Return\n    }\n    GuiControl, Disabled, IB\n    GuiControl, Disabled, IAU\n    GuiControl, Disabled, Port\n    GuiControl, Disabled, Loc\n    GuiControl, Disabled, CG\n    GuiControl,, IB, % IS[2]\n    GuiControlGet, Loc\n    GuiControl, Show, PB\n    GuiControl,, PB, + 20\n    GuiControl,, Percent, 20 `%\n    FileCopyDir, CH-Install.zip, % Loc, 1\n    FileDelete, CH-Install.zip\n    GuiControl,, PB, + 30\n    GuiControl,, Percent, 50 `%\n    FileCopyDir, % Loc \"\\HighChart.zip\", % Loc \"\\\", 1\n    FileDelete, % Loc \"\\HighChart.zip\"\n    GuiControl,, PB, + 40\n    GuiControl,, Percent, 90 `%\n    FileCopy, Version.txt, % Loc, 1\n    FileDelete, Version.txt\n    GuiControl,, PB, + 10\n    GuiControl,, Percent, 100 `%\n    GuiControlGet, Port\n    \n    If (!Port) {\n        RegPath := \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Cash Helper\"\n        RegWrite, REG_SZ, %RegPath%, DisplayName, Cash Helper\n        RegWrite, REG_SZ, %RegPath%, DisplayVersion, %Version%\n        RegWrite, REG_SZ, %RegPath%, DisplayIcon, %Loc%\\StartUp.exe\n        RegWrite, REG_SZ, %RegPath%, InstallLocation, %Loc%\\\n        RegWrite, REG_SZ, %RegPath%, UninstallString, %Loc%\\Uninstall.exe\n        RegWrite, REG_DWORD, %RegPath%, NoModify, 1\n        RegWrite, REG_DWORD, %RegPath%, NoRepair, 1\n        RegWrite, REG_SZ, %RegPath%, Publisher, Chandoul Mohamed\n        GuiControl,, Log, Creating a shortcut...\n        FileCreateShortcut, %Loc%\\StartUp.exe, %A_Desktop%\\Cash Helper.lnk\n    }\n    \n    GuiControl,, IB, COMPLETE!\n    \n    MsgBox, 4, Launch, Run Cash Helper now?\n    IfMsgBox, Yes\n    {\n        Run, % Loc \"\\StartUp.exe\"\n    }\nExitApp\n\nButtonChange:\n    If (Dir := SelectFolderEx(StartingFolder := \"\", Prompt := \"Select Program Location\",, OkBtnLabel := \"OK!\")) {\n        GuiControl,, Loc, % Dir \"\\Cash Helper\"\n        InstallState()\n    }\nReturn\n\nSelectFolderEx(StartingFolder := \"\", Prompt := \"\", OwnerHwnd := 0, OkBtnLabel := \"\") {\n    Static OsVersion := DllCall(\"GetVersion\", \"UChar\")\n    , IID_IShellItem := 0\n    , InitIID := VarSetCapacity(IID_IShellItem, 16, 0)\n    & DllCall(\"Ole32.dll\\IIDFromString\", \"WStr\", \"{43826d1e-e718-42ee-bc55-a1e261c37bfe}\", \"Ptr\", &IID_IShellItem)\n    , Show              := A_PtrSize * 3\n    , SetOptions        := A_PtrSize * 9\n    , SetFolder         := A_PtrSize * 12\n    , SetTitle          := A_PtrSize * 17\n    , SetOkButtonLabel  := A_PtrSize * 18\n    , GetResult         := A_PtrSize * 20\n    SelectedFolder      := \"\"\n    \n    If (OsVersion < 6) {\n        FileSelectFolder, SelectedFolder, *%StartingFolder%, 3, %Prompt%\n        Return SelectedFolder\n    }\n    \n    OwnerHwnd := DllCall(\"IsWindow\", \"Ptr\", OwnerHwnd, \"UInt\") ? OwnerHwnd : 0\n    If !(FileDialog := ComObjCreate(\"{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}\", \"{42f85136-db7e-439c-85f1-e4075d135fc8}\"))\n        Return \"\"\n    VTBL := NumGet(FileDialog + 0, \"UPtr\")\n    DllCall(NumGet(VTBL + SetOptions, \"UPtr\"), \"Ptr\", FileDialog, \"UInt\", 0x00002028, \"UInt\")\n    \n    If (StartingFolder <> \"\")\n        If !DllCall(\"Shell32.dll\\SHCreateItemFromParsingName\", \"WStr\", StartingFolder, \"Ptr\", 0, \"Ptr\", &IID_IShellItem, \"PtrP\", FolderItem)\n            DllCall(NumGet(VTBL + SetFolder, \"UPtr\"), \"Ptr\", FileDialog, \"Ptr\", FolderItem, \"UInt\")\n    \n    If (Prompt <> \"\")\n        DllCall(NumGet(VTBL + SetTitle, \"UPtr\"), \"Ptr\", FileDialog, \"WStr\", Prompt, \"UInt\")\n    \n    If (OkBtnLabel <> \"\")\n        DllCall(NumGet(VTBL + SetOkButtonLabel, \"UPtr\"), \"Ptr\", FileDialog, \"WStr\", OkBtnLabel, \"UInt\")\n    \n    If !DllCall(NumGet(VTBL + Show, \"UPtr\"), \"Ptr\", FileDialog, \"Ptr\", OwnerHwnd, \"UInt\") {\n        If !DllCall(NumGet(VTBL + GetResult, \"UPtr\"), \"Ptr\", FileDialog, \"PtrP\", ShellItem, \"UInt\") {\n            GetDisplayName := NumGet(NumGet(ShellItem + 0, \"UPtr\"), A_PtrSize * 5, \"UPtr\")\n            If !DllCall(GetDisplayName, \"Ptr\", ShellItem, \"UInt\", 0x80028000, \"PtrP\", StrPtr)\n            SelectedFolder := StrGet(StrPtr, \"UTF-16\"), DllCall(\"Ole32.dll\\CoTaskMemFree\", \"Ptr\", StrPtr)\n            ObjRelease(ShellItem)\n        }\n    }\n    \n    If (FolderItem)\n        ObjRelease(FolderItem)\n        \n    ObjRelease(FileDialog)\n    Return SelectedFolder\n}\n\nInstallState() {\n    RegRead, IC, HKLM, SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Cash Helper, InstallLocation\n    GuiControlGet, Loc\n    IS := (IC = Loc \"\\\") ? [\"Update\", \"Updating...\"] : [\"Install\", \"Installing...\"]\n    GuiControl,, IB, % IS[1]\n    Return, IS\n}"
  },
  {
    "path": "Lib/Classes/Class_CtlColors.ahk",
    "content": "﻿; ======================================================================================================================\n; AHK 1.1+\n; ======================================================================================================================\n; Function:          Auxiliary object to color controls on WM_CTLCOLOR... notifications.\n;                    Supported controls are: Checkbox, ComboBox, DropDownList, Edit, ListBox, Radio, Text.\n;                    Checkboxes and Radios accept only background colors due to design.\n; Namespace:         CtlColors\n; Tested with:       1.1.25.02\n; Tested on:         Win 10 (x64)\n; Change log:        1.0.04.00/2017-10-30/just me  -  added transparent background (BkColor = \"Trans\").\n;                    1.0.03.00/2015-07-06/just me  -  fixed Change() to run properly for ComboBoxes.\n;                    1.0.02.00/2014-06-07/just me  -  fixed __New() to run properly with compiled scripts.\n;                    1.0.01.00/2014-02-15/just me  -  changed class initialization.\n;                    1.0.00.00/2014-02-14/just me  -  initial release.\n; ======================================================================================================================\n; This software is provided 'as-is', without any express or implied warranty.\n; In no event will the authors be held liable for any damages arising from the use of this software.\n; ======================================================================================================================\nClass CtlColors {\n   ; ===================================================================================================================\n   ; Class variables\n   ; ===================================================================================================================\n   ; Registered Controls\n   Static Attached := {}\n   ; OnMessage Handlers\n   Static HandledMessages := {Edit: 0, ListBox: 0, Static: 0}\n   ; Message Handler Function\n   Static MessageHandler := \"CtlColors_OnMessage\"\n   ; Windows Messages\n   Static WM_CTLCOLOR := {Edit: 0x0133, ListBox: 0x134, Static: 0x0138}\n   ; HTML Colors (BGR)\n   Static HTML := {AQUA: 0xFFFF00, BLACK: 0x000000, BLUE: 0xFF0000, FUCHSIA: 0xFF00FF, GRAY: 0x808080, GREEN: 0x008000\n                 , LIME: 0x00FF00, MAROON: 0x000080, NAVY: 0x800000, OLIVE: 0x008080, PURPLE: 0x800080, RED: 0x0000FF\n                 , SILVER: 0xC0C0C0, TEAL: 0x808000, WHITE: 0xFFFFFF, YELLOW: 0x00FFFF}\n   ; Transparent Brush\n   Static NullBrush := DllCall(\"GetStockObject\", \"Int\", 5, \"UPtr\")\n   ; System Colors\n   Static SYSCOLORS := {Edit: \"\", ListBox: \"\", Static: \"\"}\n   ; Error message in case of errors\n   Static ErrorMsg := \"\"\n   ; Class initialization\n   Static InitClass := CtlColors.ClassInit()\n   ; ===================================================================================================================\n   ; Constructor / Destructor\n   ; ===================================================================================================================\n   __New() { ; You must not instantiate this class!\n      If (This.InitClass == \"!DONE!\") { ; external call after class initialization\n         This[\"!Access_Denied!\"] := True\n         Return False\n      }\n   }\n   ; ----------------------------------------------------------------------------------------------------------------\n   __Delete() {\n      If This[\"!Access_Denied!\"]\n         Return\n      This.Free() ; free GDI resources\n   }\n   ; ===================================================================================================================\n   ; ClassInit       Internal creation of a new instance to ensure that __Delete() will be called.\n   ; ===================================================================================================================\n   ClassInit() {\n      CtlColors := New CtlColors\n      Return \"!DONE!\"\n   }\n   ; ===================================================================================================================\n   ; CheckBkColor    Internal check for parameter BkColor.\n   ; ===================================================================================================================\n   CheckBkColor(ByRef BkColor, Class) {\n      This.ErrorMsg := \"\"\n      If (BkColor != \"\") && !This.HTML.HasKey(BkColor) && !RegExMatch(BkColor, \"^[[:xdigit:]]{6}$\") {\n         This.ErrorMsg := \"Invalid parameter BkColor: \" . BkColor\n         Return False\n      }\n      BkColor := BkColor = \"\" ? This.SYSCOLORS[Class]\n              :  This.HTML.HasKey(BkColor) ? This.HTML[BkColor]\n              :  \"0x\" . SubStr(BkColor, 5, 2) . SubStr(BkColor, 3, 2) . SubStr(BkColor, 1, 2)\n      Return True\n   }\n   ; ===================================================================================================================\n   ; CheckTxColor    Internal check for parameter TxColor.\n   ; ===================================================================================================================\n   CheckTxColor(ByRef TxColor) {\n      This.ErrorMsg := \"\"\n      If (TxColor != \"\") && !This.HTML.HasKey(TxColor) && !RegExMatch(TxColor, \"i)^[[:xdigit:]]{6}$\") {\n         This.ErrorMsg := \"Invalid parameter TextColor: \" . TxColor\n         Return False\n      }\n      TxColor := TxColor = \"\" ? \"\"\n              :  This.HTML.HasKey(TxColor) ? This.HTML[TxColor]\n              :  \"0x\" . SubStr(TxColor, 5, 2) . SubStr(TxColor, 3, 2) . SubStr(TxColor, 1, 2)\n      Return True\n   }\n   ; ===================================================================================================================\n   ; Attach          Registers a control for coloring.\n   ; Parameters:     HWND        - HWND of the GUI control                                   \n   ;                 BkColor     - HTML color name, 6-digit hexadecimal RGB value, or \"\" for default color\n   ;                 ----------- Optional \n   ;                 TxColor     - HTML color name, 6-digit hexadecimal RGB value, or \"\" for default color\n   ; Return values:  On success  - True\n   ;                 On failure  - False, CtlColors.ErrorMsg contains additional informations\n   ; ===================================================================================================================\n   Attach(HWND, BkColor, TxColor := \"\") {\n      ; Names of supported classes\n      Static ClassNames := {Button: \"\", ComboBox: \"\", Edit: \"\", ListBox: \"\", Static: \"\"}\n      ; Button styles\n      Static BS_CHECKBOX := 0x2, BS_RADIOBUTTON := 0x8\n      ; Editstyles\n      Static ES_READONLY := 0x800\n      ; Default class background colors\n      Static COLOR_3DFACE := 15, COLOR_WINDOW := 5\n      ; Initialize default background colors on first call -------------------------------------------------------------\n      If (This.SYSCOLORS.Edit = \"\") {\n         This.SYSCOLORS.Static := DllCall(\"User32.dll\\GetSysColor\", \"Int\", COLOR_3DFACE, \"UInt\")\n         This.SYSCOLORS.Edit := DllCall(\"User32.dll\\GetSysColor\", \"Int\", COLOR_WINDOW, \"UInt\")\n         This.SYSCOLORS.ListBox := This.SYSCOLORS.Edit\n      }\n      This.ErrorMsg := \"\"\n      ; Check colors ---------------------------------------------------------------------------------------------------\n      If (BkColor = \"\") && (TxColor = \"\") {\n         This.ErrorMsg := \"Both parameters BkColor and TxColor are empty!\"\n         Return False\n      }\n      ; Check HWND -----------------------------------------------------------------------------------------------------\n      If !(CtrlHwnd := HWND + 0) || !DllCall(\"User32.dll\\IsWindow\", \"UPtr\", HWND, \"UInt\") {\n         This.ErrorMsg := \"Invalid parameter HWND: \" . HWND\n         Return False\n      }\n      If This.Attached.HasKey(HWND) {\n         This.ErrorMsg := \"Control \" . HWND . \" is already registered!\"\n         Return False\n      }\n      Hwnds := [CtrlHwnd]\n      ; Check control's class ------------------------------------------------------------------------------------------\n      Classes := \"\"\n      WinGetClass, CtrlClass, ahk_id %CtrlHwnd%\n      This.ErrorMsg := \"Unsupported control class: \" . CtrlClass\n      If !ClassNames.HasKey(CtrlClass)\n         Return False\n      ControlGet, CtrlStyle, Style, , , ahk_id %CtrlHwnd%\n      If (CtrlClass = \"Edit\")\n         Classes := [\"Edit\", \"Static\"]\n      Else If (CtrlClass = \"Button\") {\n         IF (CtrlStyle & BS_RADIOBUTTON) || (CtrlStyle & BS_CHECKBOX)\n            Classes := [\"Static\"]\n         Else\n            Return False\n      }\n      Else If (CtrlClass = \"ComboBox\") {\n         VarSetCapacity(CBBI, 40 + (A_PtrSize * 3), 0)\n         NumPut(40 + (A_PtrSize * 3), CBBI, 0, \"UInt\")\n         DllCall(\"User32.dll\\GetComboBoxInfo\", \"Ptr\", CtrlHwnd, \"Ptr\", &CBBI)\n         Hwnds.Insert(NumGet(CBBI, 40 + (A_PtrSize * 2, \"UPtr\")) + 0)\n         Hwnds.Insert(Numget(CBBI, 40 + A_PtrSize, \"UPtr\") + 0)\n         Classes := [\"Edit\", \"Static\", \"ListBox\"]\n      }\n      If !IsObject(Classes)\n         Classes := [CtrlClass]\n      ; Check background color -----------------------------------------------------------------------------------------\n      If (BkColor <> \"Trans\")\n         If !This.CheckBkColor(BkColor, Classes[1])\n            Return False\n      ; Check text color -----------------------------------------------------------------------------------------------\n      If !This.CheckTxColor(TxColor)\n         Return False\n      ; Activate message handling on the first call for a class --------------------------------------------------------\n      For I, V In Classes {\n         If (This.HandledMessages[V] = 0)\n            OnMessage(This.WM_CTLCOLOR[V], This.MessageHandler)\n         This.HandledMessages[V] += 1\n      }\n      ; Store values for HWND ------------------------------------------------------------------------------------------\n      If (BkColor = \"Trans\")\n         Brush := This.NullBrush\n      Else\n         Brush := DllCall(\"Gdi32.dll\\CreateSolidBrush\", \"UInt\", BkColor, \"UPtr\")\n      For I, V In Hwnds\n         This.Attached[V] := {Brush: Brush, TxColor: TxColor, BkColor: BkColor, Classes: Classes, Hwnds: Hwnds}\n      ; Redraw control -------------------------------------------------------------------------------------------------\n      DllCall(\"User32.dll\\InvalidateRect\", \"Ptr\", HWND, \"Ptr\", 0, \"Int\", 1)\n      This.ErrorMsg := \"\"\n      Return True\n   }\n   ; ===================================================================================================================\n   ; Change          Change control colors.\n   ; Parameters:     HWND        - HWND of the GUI control\n   ;                 BkColor     - HTML color name, 6-digit hexadecimal RGB value, or \"\" for default color\n   ;                 ----------- Optional \n   ;                 TxColor     - HTML color name, 6-digit hexadecimal RGB value, or \"\" for default color\n   ; Return values:  On success  - True\n   ;                 On failure  - False, CtlColors.ErrorMsg contains additional informations\n   ; Remarks:        If the control isn't registered yet, Add() is called instead internally.\n   ; ===================================================================================================================\n   Change(HWND, BkColor, TxColor := \"\") {\n      ; Check HWND -----------------------------------------------------------------------------------------------------\n      This.ErrorMsg := \"\"\n      HWND += 0\n      If !This.Attached.HasKey(HWND)\n         Return This.Attach(HWND, BkColor, TxColor)\n      CTL := This.Attached[HWND]\n      ; Check BkColor --------------------------------------------------------------------------------------------------\n      If (BkColor <> \"Trans\")\n         If !This.CheckBkColor(BkColor, CTL.Classes[1])\n            Return False\n      ; Check TxColor ------------------------------------------------------------------------------------------------\n      If !This.CheckTxColor(TxColor)\n         Return False\n      ; Store Colors ---------------------------------------------------------------------------------------------------\n      If (BkColor <> CTL.BkColor) {\n         If (CTL.Brush) {\n            If (Ctl.Brush <> This.NullBrush)\n               DllCall(\"Gdi32.dll\\DeleteObject\", \"Prt\", CTL.Brush)\n            This.Attached[HWND].Brush := 0\n         }\n         If (BkColor = \"Trans\")\n            Brush := This.NullBrush\n         Else\n            Brush := DllCall(\"Gdi32.dll\\CreateSolidBrush\", \"UInt\", BkColor, \"UPtr\")\n         For I, V In CTL.Hwnds {\n            This.Attached[V].Brush := Brush\n            This.Attached[V].BkColor := BkColor\n         }\n      }\n      For I, V In Ctl.Hwnds\n         This.Attached[V].TxColor := TxColor\n      This.ErrorMsg := \"\"\n      DllCall(\"User32.dll\\InvalidateRect\", \"Ptr\", HWND, \"Ptr\", 0, \"Int\", 1)\n      Return True\n   }\n   ; ===================================================================================================================\n   ; Detach          Stop control coloring.\n   ; Parameters:     HWND        - HWND of the GUI control\n   ; Return values:  On success  - True\n   ;                 On failure  - False, CtlColors.ErrorMsg contains additional informations\n   ; ===================================================================================================================\n   Detach(HWND) {\n      This.ErrorMsg := \"\"\n      HWND += 0\n      If This.Attached.HasKey(HWND) {\n         CTL := This.Attached[HWND].Clone()\n         If (CTL.Brush) && (CTL.Brush <> This.NullBrush)\n            DllCall(\"Gdi32.dll\\DeleteObject\", \"Prt\", CTL.Brush)\n         For I, V In CTL.Classes {\n            If This.HandledMessages[V] > 0 {\n               This.HandledMessages[V] -= 1\n               If This.HandledMessages[V] = 0\n                  OnMessage(This.WM_CTLCOLOR[V], \"\")\n         }  }\n         For I, V In CTL.Hwnds\n            This.Attached.Remove(V, \"\")\n         DllCall(\"User32.dll\\InvalidateRect\", \"Ptr\", HWND, \"Ptr\", 0, \"Int\", 1)\n         CTL := \"\"\n         Return True\n      }\n      This.ErrorMsg := \"Control \" . HWND . \" is not registered!\"\n      Return False\n   }\n   ; ===================================================================================================================\n   ; Free            Stop coloring for all controls and free resources.\n   ; Return values:  Always True.\n   ; ===================================================================================================================\n   Free() {\n      For K, V In This.Attached\n         If (V.Brush) && (V.Brush <> This.NullBrush)\n            DllCall(\"Gdi32.dll\\DeleteObject\", \"Ptr\", V.Brush)\n      For K, V In This.HandledMessages\n         If (V > 0) {\n            OnMessage(This.WM_CTLCOLOR[K], \"\")\n            This.HandledMessages[K] := 0\n         }\n      This.Attached := {}\n      Return True\n   }\n   ; ===================================================================================================================\n   ; IsAttached      Check if the control is registered for coloring.\n   ; Parameters:     HWND        - HWND of the GUI control\n   ; Return values:  On success  - True\n   ;                 On failure  - False\n   ; ===================================================================================================================\n   IsAttached(HWND) {\n      Return This.Attached.HasKey(HWND)\n   }\n}\n\n; ======================================================================================================================\n; CtlColors_OnMessage\n; This function handles CTLCOLOR messages. There's no reason to call it manually!\n; ======================================================================================================================\nCtlColors_OnMessage(HDC, HWND) {\n   Critical\n   If CtlColors.IsAttached(HWND) {\n      CTL := CtlColors.Attached[HWND]\n      If (CTL.TxColor != \"\")\n         DllCall(\"Gdi32.dll\\SetTextColor\", \"Ptr\", HDC, \"UInt\", CTL.TxColor)\n      If (CTL.BkColor = \"Trans\")\n         DllCall(\"Gdi32.dll\\SetBkMode\", \"Ptr\", HDC, \"UInt\", 1) ; TRANSPARENT = 1\n      Else\n         DllCall(\"Gdi32.dll\\SetBkColor\", \"Ptr\", HDC, \"UInt\", CTL.BkColor)\n      Return CTL.Brush\n   }\n}\n"
  },
  {
    "path": "Lib/Classes/Class_GDIplus.ahk",
    "content": "﻿class GDIplus {\n    __New() {\n        if !DllCall(\"GetModuleHandle\", \"Str\", \"gdiplus\", \"Ptr\")\n            DllCall(\"LoadLibrary\", \"Str\", \"gdiplus\")\n        VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)\n        DllCall(\"gdiplus\\GdiplusStartup\", \"UPtrP\", pToken, \"Ptr\", &si, \"Ptr\", 0)\n        this.token := pToken\n    }\n    __Delete() {\n        DllCall(\"gdiplus\\GdiplusShutdown\", \"Ptr\", this.token)\n        if hModule := DllCall(\"GetModuleHandle\", \"Str\", \"gdiplus\", \"Ptr\")\n            DllCall(\"FreeLibrary\", \"Ptr\", hModule)\n    }\n    CreateBitmapFromStream(pStream) {\n        DllCall(\"gdiplus\\GdipCreateBitmapFromStream\", \"Ptr\", pStream, \"PtrP\", pBitmap)\n        Return pBitmap\n    }\n    CreateHBITMAPFromBitmap(pBitmap, background := 0xffffffff) {\n        DllCall(\"gdiplus\\GdipCreateHBITMAPFromBitmap\", \"Ptr\", pBitmap, \"PtrP\", hbm, \"UInt\", background)\n        return hbm\n    }\n    DisposeImage(pBitmap) {\n        return DllCall(\"gdiplus\\GdipDisposeImage\", \"Ptr\", pBitmap)\n    }\n}"
  },
  {
    "path": "Lib/Classes/Class_ImageButton.ahk",
    "content": "﻿; ======================================================================================================================\n; Namespace:         ImageButton\n; Function:          Create images and assign them to pushbuttons.\n; Tested with:       AHK 1.1.33.02 (A32/U32/U64)\n; Tested on:         Win 10 (x64)\n; Change history:    1.5.00.00/2020-12-16/just me - increased script performance, added support for icons (HICON)\n;                    1.4.00.00/2014-06-07/just me - fixed bug for button caption = \"0\", \"000\", etc.\n;                    1.3.00.00/2014-02-28/just me - added support for ARGB colors\n;                    1.2.00.00/2014-02-23/just me - added borders\n;                    1.1.00.00/2013-12-26/just me - added rounded and bicolored buttons       \n;                    1.0.00.00/2013-12-21/just me - initial release\n; How to use:\n;     1. Create a push button (e.g. \"Gui, Add, Button, vMyButton hwndHwndButton, Caption\") using the 'Hwnd' option\n;        to get its HWND.\n;     2. Call ImageButton.Create() passing two parameters:\n;        HWND        -  Button's HWND.\n;        Options*    -  variadic array containing up to 6 option arrays (see below).\n;        ---------------------------------------------------------------------------------------------------------------\n;        The index of each option object determines the corresponding button state on which the bitmap will be shown.\n;        MSDN defines 6 states (http://msdn.microsoft.com/en-us/windows/bb775975):\n;           PBS_NORMAL    = 1\n;\t         PBS_HOT       = 2\n;\t         PBS_PRESSED   = 3\n;\t         PBS_DISABLED  = 4\n;\t         PBS_DEFAULTED = 5\n;\t         PBS_STYLUSHOT = 6 <- used only on tablet computers (that's false for Windows Vista and 7, see below)\n;        If you don't want the button to be 'animated' on themed GUIs, just pass one option object with index 1.\n;        On Windows Vista and 7 themed bottons are 'animated' using the images of states 5 and 6 after clicked.\n;        ---------------------------------------------------------------------------------------------------------------\n;        Each option array may contain the following values:\n;           Index Value\n;           1     Mode        mandatory:\n;                             0  -  unicolored or bitmap\n;                             1  -  vertical bicolored\n;                             2  -  horizontal bicolored\n;                             3  -  vertical gradient\n;                             4  -  horizontal gradient\n;                             5  -  vertical gradient using StartColor at both borders and TargetColor at the center\n;                             6  -  horizontal gradient using StartColor at both borders and TargetColor at the center\n;                             7  -  'raised' style\n;           2     StartColor  mandatory for Option[1], higher indices will inherit the value of Option[1], if omitted:\n;                             -  ARGB integer value (0xAARRGGBB) or HTML color name (\"Red\").\n;                             -  Path of an image file or HBITMAP handle for mode 0.\n;           3     TargetColor mandatory for Option[1] if Mode > 0. Higher indcices will inherit the color of Option[1],\n;                             if omitted:\n;                             -  ARGB integer value (0xAARRGGBB) or HTML color name (\"Red\").\n;                             -  String \"HICON\" if StartColor contains a HICON handle.\n;           4     TextColor   optional, if omitted, the default text color will be used for Option[1], higher indices \n;                             will inherit the color of Option[1]:\n;                             -  ARGB integer value (0xAARRGGBB) or HTML color name (\"Red\").\n;                                Default: 0xFF000000 (black)\n;           5     Rounded     optional:\n;                             -  Radius of the rounded corners in pixel; the letters 'H' and 'W' may be specified\n;                                also to use the half of the button's height or width respectively.\n;                                Default: 0 - not rounded\n;           6     GuiColor    optional, needed for rounded buttons if you've changed the GUI background color:\n;                             -  RGB integer value (0xRRGGBB) or HTML color name (\"Red\").\n;                                Default: AHK default GUI background color\n;           7     BorderColor optional, ignored for modes 0 (bitmap) and 7, color of the border:\n;                             -  RGB integer value (0xRRGGBB) or HTML color name (\"Red\").\n;           8     BorderWidth optional, ignored for modes 0 (bitmap) and 7, width of the border in pixels:\n;                             -  Default: 1\n;        ---------------------------------------------------------------------------------------------------------------\n;        If the the button has a caption it will be drawn above the bitmap.\n; Credits:           THX tic     for GDIP.AHK     : http://www.autohotkey.com/forum/post-198949.html\n;                    THX tkoi    for ILBUTTON.AHK : http://www.autohotkey.com/forum/topic40468.html\n; ======================================================================================================================\n; This software is provided 'as-is', without any express or implied warranty.\n; In no event will the authors be held liable for any damages arising from the use of this software.\n; ======================================================================================================================\n; ======================================================================================================================\n; CLASS ImageButton()\n; ======================================================================================================================\nClass ImageButton {\n   ; ===================================================================================================================\n   ; PUBLIC PROPERTIES =================================================================================================\n   ; ===================================================================================================================\n   Static DefGuiColor  := \"\"        ; default GUI color                             (read/write)\n   Static DefTxtColor := \"Black\"    ; default caption color                         (read/write)\n   Static LastError := \"\"           ; will contain the last error message, if any   (readonly)\n   ; ===================================================================================================================\n   ; PRIVATE PROPERTIES ================================================================================================\n   ; ===================================================================================================================\n   Static BitMaps := []\n   Static GDIPDll := 0\n   Static GDIPToken := 0\n   Static MaxOptions := 8\n   ; HTML colors\n   Static HTML := {BLACK: 0x000000, GRAY: 0x808080, SILVER: 0xC0C0C0, WHITE: 0xFFFFFF, MAROON: 0x800000\n                 , PURPLE: 0x800080, FUCHSIA: 0xFF00FF, RED: 0xFF0000, GREEN: 0x008000, OLIVE: 0x808000\n                 , YELLOW: 0xFFFF00, LIME: 0x00FF00, NAVY: 0x000080, TEAL: 0x008080, AQUA: 0x00FFFF, BLUE: 0x0000FF}\n   ; Initialize\n   Static ClassInit := ImageButton.InitClass()\n   ; ===================================================================================================================\n   ; PRIVATE METHODS ===================================================================================================\n   ; ===================================================================================================================\n   __New(P*) {\n      Return False\n   }\n   ; ===================================================================================================================\n   InitClass() {\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Get AHK's default GUI background color\n      GuiColor := DllCall(\"User32.dll\\GetSysColor\", \"Int\", 15, \"UInt\") ; COLOR_3DFACE is used by AHK as default\n      This.DefGuiColor := ((GuiColor >> 16) & 0xFF) | (GuiColor & 0x00FF00) | ((GuiColor & 0xFF) << 16)\n      Return True\n   }\n   ; ===================================================================================================================\n   BitmapOrIcon(O2, O3) {\n      ; OBJ_BITMAP = 7\n      Return (This.IsInt(O2) && (O3 = \"HICON\")) || (DllCall(\"GetObjectType\", \"Ptr\", O2, \"UInt\") = 7) || FileExist(O2)\n   }\n   ; ===================================================================================================================\n   FreeBitmaps() {\n      For I, HBITMAP In This.BitMaps\n         DllCall(\"Gdi32.dll\\DeleteObject\", \"Ptr\", HBITMAP)\n      This.BitMaps := []\n   }\n   ; ===================================================================================================================\n   GetARGB(RGB) {\n      ARGB := This.HTML.HasKey(RGB) ? This.HTML[RGB] : RGB\n      Return (ARGB & 0xFF000000) = 0 ? 0xFF000000 | ARGB : ARGB\n   }\n   ; ===================================================================================================================\n   IsInt(Val) {\n      If Val Is Integer\n         Return True\n      Return False\n   }\n   ; ===================================================================================================================\n   PathAddRectangle(Path, X, Y, W, H) {\n      Return DllCall(\"Gdiplus.dll\\GdipAddPathRectangle\", \"Ptr\", Path, \"Float\", X, \"Float\", Y, \"Float\", W, \"Float\", H)\n   }\n   ; ===================================================================================================================\n   PathAddRoundedRect(Path, X1, Y1, X2, Y2, R) {\n      D := (R * 2), X2 -= D, Y2 -= D\n      DllCall(\"Gdiplus.dll\\GdipAddPathArc\"\n            , \"Ptr\", Path, \"Float\", X1, \"Float\", Y1, \"Float\", D, \"Float\", D, \"Float\", 180, \"Float\", 90)\n      DllCall(\"Gdiplus.dll\\GdipAddPathArc\"\n            , \"Ptr\", Path, \"Float\", X2, \"Float\", Y1, \"Float\", D, \"Float\", D, \"Float\", 270, \"Float\", 90)\n      DllCall(\"Gdiplus.dll\\GdipAddPathArc\"\n            , \"Ptr\", Path, \"Float\", X2, \"Float\", Y2, \"Float\", D, \"Float\", D, \"Float\", 0, \"Float\", 90)\n      DllCall(\"Gdiplus.dll\\GdipAddPathArc\"\n            , \"Ptr\", Path, \"Float\", X1, \"Float\", Y2, \"Float\", D, \"Float\", D, \"Float\", 90, \"Float\", 90)\n      Return DllCall(\"Gdiplus.dll\\GdipClosePathFigure\", \"Ptr\", Path)\n   }\n   ; ===================================================================================================================\n   SetRect(ByRef Rect, X1, Y1, X2, Y2) {\n      VarSetCapacity(Rect, 16, 0)\n      NumPut(X1, Rect, 0, \"Int\"), NumPut(Y1, Rect, 4, \"Int\")\n      NumPut(X2, Rect, 8, \"Int\"), NumPut(Y2, Rect, 12, \"Int\")\n      Return True\n   }\n   ; ===================================================================================================================\n   SetRectF(ByRef Rect, X, Y, W, H) {\n      VarSetCapacity(Rect, 16, 0)\n      NumPut(X, Rect, 0, \"Float\"), NumPut(Y, Rect, 4, \"Float\")\n      NumPut(W, Rect, 8, \"Float\"), NumPut(H, Rect, 12, \"Float\")\n      Return True\n   }\n   ; ===================================================================================================================\n   SetError(Msg) {\n      If (This.Bitmap)\n         DllCall(\"Gdiplus.dll\\GdipDisposeImage\", \"Ptr\", This.Bitmap)\n      If (This.Graphics)\n         DllCall(\"Gdiplus.dll\\GdipDeleteGraphics\", \"Ptr\", This.Graphics)\n      If (This.Font)\n         DllCall(\"Gdiplus.dll\\GdipDeleteFont\", \"Ptr\", This.Font)\n      This.Delete(\"Bitmap\")\n      This.Delete(\"Graphics\")\n      This.Delete(\"Font\")\n      This.FreeBitmaps()\n      ; This.GdiplusShutdown()\n      This.LastError := Msg\n      Return False\n   }\n   ; ===================================================================================================================\n   ; PUBLIC METHODS ====================================================================================================\n   ; ===================================================================================================================\n   Create(HWND, Options*) {\n      ; Windows constants\n      Static BCM_GETIMAGELIST := 0x1603, BCM_SETIMAGELIST := 0x1602\n           , BS_CHECKBOX := 0x02, BS_RADIOBUTTON := 0x04, BS_GROUPBOX := 0x07, BS_AUTORADIOBUTTON := 0x09\n           , BS_LEFT := 0x0100, BS_RIGHT := 0x0200, BS_CENTER := 0x0300, BS_TOP := 0x0400, BS_BOTTOM := 0x0800\n           , BS_VCENTER := 0x0C00, BS_BITMAP := 0x0080\n           , BUTTON_IMAGELIST_ALIGN_LEFT := 0, BUTTON_IMAGELIST_ALIGN_RIGHT := 1, BUTTON_IMAGELIST_ALIGN_CENTER := 4\n           , ILC_COLOR32 := 0x20\n           , OBJ_BITMAP := 7\n           , RCBUTTONS := BS_CHECKBOX | BS_RADIOBUTTON | BS_AUTORADIOBUTTON\n           , SA_LEFT := 0x00, SA_CENTER := 0x01, SA_RIGHT := 0x02\n           , WM_GETFONT := 0x31\n      ; ----------------------------------------------------------------------------------------------------------------\n      This.LastError := \"\"\n      HBITMAP := HFORMAT := PBITMAP := PBRUSH := PFONT := PPATH := 0\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Check HWND\n      If !DllCall(\"User32.dll\\IsWindow\", \"Ptr\", HWND)\n         Return This.SetError(\"Invalid parameter HWND!\")\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Check Options\n      If !(IsObject(Options)) || (Options.MinIndex() <> 1) || (Options.MaxIndex() > This.MaxOptions)\n         Return This.SetError(\"Invalid parameter Options!\")\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Get and check control's class and styles\n      WinGetClass, BtnClass, ahk_id %HWND%\n      ControlGet, BtnStyle, Style, , , ahk_id %HWND%\n      If (BtnClass != \"Button\") || ((BtnStyle & 0xF ^ BS_GROUPBOX) = 0) || ((BtnStyle & RCBUTTONS) > 1)\n         Return This.SetError(\"The control must be a pushbutton!\")\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Get the button's font\n      HFONT := DllCall(\"User32.dll\\SendMessage\", \"Ptr\", HWND, \"UInt\", WM_GETFONT, \"Ptr\", 0, \"Ptr\", 0, \"Ptr\")\n      DC := DllCall(\"User32.dll\\GetDC\", \"Ptr\", HWND, \"Ptr\")\n      DllCall(\"Gdi32.dll\\SelectObject\", \"Ptr\", DC, \"Ptr\", HFONT)\n      DllCall(\"Gdiplus.dll\\GdipCreateFontFromDC\", \"Ptr\", DC, \"PtrP\", PFONT)\n      DllCall(\"User32.dll\\ReleaseDC\", \"Ptr\", HWND, \"Ptr\", DC)\n      If !(This.Font := PFONT)\n         Return This.SetError(\"Couldn't get button's font!\")\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Get the button's rectangle\n      VarSetCapacity(RECT, 16, 0)\n      If !DllCall(\"User32.dll\\GetWindowRect\", \"Ptr\", HWND, \"Ptr\", &RECT)\n         Return This.SetError(\"Couldn't get button's rectangle!\")\n      BtnW := NumGet(RECT,  8, \"Int\") - NumGet(RECT, 0, \"Int\")\n      BtnH := NumGet(RECT, 12, \"Int\") - NumGet(RECT, 4, \"Int\")\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Get the button's caption\n      ControlGetText, BtnCaption, , ahk_id %HWND%\n      If (ErrorLevel)\n         Return This.SetError(\"Couldn't get button's caption!\")\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Create a GDI+ bitmap\n      DllCall(\"Gdiplus.dll\\GdipCreateBitmapFromScan0\", \"Int\", BtnW, \"Int\", BtnH, \"Int\", 0\n            , \"UInt\", 0x26200A, \"Ptr\", 0, \"PtrP\", PBITMAP)\n      If !(This.Bitmap := PBITMAP)\n         Return This.SetError(\"Couldn't create the GDI+ bitmap!\")\n      ; Get the pointer to its graphics\n      PGRAPHICS := 0\n      DllCall(\"Gdiplus.dll\\GdipGetImageGraphicsContext\", \"Ptr\", PBITMAP, \"PtrP\", PGRAPHICS)\n      If !(This.Graphics := PGRAPHICS)\n         Return This.SetError(\"Couldn't get the the GDI+ bitmap's graphics!\")\n      ; Quality settings\n      DllCall(\"Gdiplus.dll\\GdipSetSmoothingMode\", \"Ptr\", PGRAPHICS, \"UInt\", 4)\n      DllCall(\"Gdiplus.dll\\GdipSetInterpolationMode\", \"Ptr\", PGRAPHICS, \"Int\", 7)\n      DllCall(\"Gdiplus.dll\\GdipSetCompositingQuality\", \"Ptr\", PGRAPHICS, \"UInt\", 4)\n      DllCall(\"Gdiplus.dll\\GdipSetRenderingOrigin\", \"Ptr\", PGRAPHICS, \"Int\", 0, \"Int\", 0)\n      DllCall(\"Gdiplus.dll\\GdipSetPixelOffsetMode\", \"Ptr\", PGRAPHICS, \"UInt\", 4)\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Create the bitmap(s)\n      This.BitMaps := []\n      For Idx, Opt In Options {\n         If !IsObject(Opt)\n            Continue\n         BkgColor1 := BkgColor2 := TxtColor := Mode := Rounded := GuiColor := Image := \"\"\n         ; Replace omitted options with the values of Options.1\n         Loop, % This.MaxOptions {\n            If (Opt[A_Index] = \"\")\n               Opt[A_Index] := Options[1, A_Index]\n         }\n         ; -------------------------------------------------------------------------------------------------------------\n         ; Check option values\n         ; Mode\n         Mode := SubStr(Opt[1], 1 ,1)\n         If !InStr(\"0123456789\", Mode)\n            Return This.SetError(\"Invalid value for Mode in Options[\" . Idx . \"]!\")\n         ; StartColor & TargetColor\n         If (Mode = 0) && This.BitmapOrIcon(Opt[2], Opt[3])\n            Image := Opt[2]\n         Else {\n            If !This.IsInt(Opt[2]) && !This.HTML.HasKey(Opt[2])\n               Return This.SetError(\"Invalid value for StartColor in Options[\" . Idx . \"]!\")\n            BkgColor1 := This.GetARGB(Opt[2])\n            If (Opt[3] = \"\")\n               Opt[3] := Opt[2]\n            If !This.IsInt(Opt[3]) && !This.HTML.HasKey(Opt[3])\n               Return This.SetError(\"Invalid value for TargetColor in Options[\" . Idx . \"]!\")\n            BkgColor2 := This.GetARGB(Opt[3])\n         }\n         ; TextColor\n         If (Opt[4] = \"\")\n            Opt[4] := This.DefTxtColor\n         If !This.IsInt(Opt[4]) && !This.HTML.HasKey(Opt[4])\n            Return This.SetError(\"Invalid value for TxtColor in Options[\" . Idx . \"]!\")\n         TxtColor := This.GetARGB(Opt[4])\n         ; Rounded\n         Rounded := Opt[5]\n         If (Rounded = \"H\")\n            Rounded := BtnH * 0.5\n         If (Rounded = \"W\")\n            Rounded := BtnW * 0.5\n         If ((Rounded + 0) = \"\")\n            Rounded := 0\n         ; GuiColor\n         If (Opt[6] = \"\")\n            Opt[6] := This.DefGuiColor\n         If !This.IsInt(Opt[6]) && !This.HTML.HasKey(Opt[6])\n            Return This.SetError(\"Invalid value for GuiColor in Options[\" . Idx . \"]!\")\n         GuiColor := This.GetARGB(Opt[6])\n         ; BorderColor\n         BorderColor := \"\"\n         If (Opt[7] <> \"\") {\n            If !This.IsInt(Opt[7]) && !This.HTML.HasKey(Opt[7])\n               Return This.SetError(\"Invalid value for BorderColor in Options[\" . Idx . \"]!\")\n            BorderColor := 0xFF000000 | This.GetARGB(Opt[7]) ; BorderColor must be always opaque\n         }\n         ; BorderWidth\n         BorderWidth := Opt[8] ? Opt[8] : 1\n         ; -------------------------------------------------------------------------------------------------------------\n         ; Clear the background\n         DllCall(\"Gdiplus.dll\\GdipGraphicsClear\", \"Ptr\", PGRAPHICS, \"UInt\", GuiColor)\n         ; Create the image\n         If (Image = \"\") { ; Create a BitMap based on the specified colors\n            PathX := PathY := 0, PathW := BtnW, PathH := BtnH\n            ; Create a GraphicsPath\n            DllCall(\"Gdiplus.dll\\GdipCreatePath\", \"UInt\", 0, \"PtrP\", PPATH)\n            If (Rounded < 1) ; the path is a rectangular rectangle\n               This.PathAddRectangle(PPATH, PathX, PathY, PathW, PathH)\n            Else ; the path is a rounded rectangle\n               This.PathAddRoundedRect(PPATH, PathX, PathY, PathW, PathH, Rounded)\n            ; If BorderColor and BorderWidth are specified, 'draw' the border (not for Mode 7)\n            If (BorderColor <> \"\") && (BorderWidth > 0) && (Mode <> 7) {\n               ; Create a SolidBrush\n               DllCall(\"Gdiplus.dll\\GdipCreateSolidFill\", \"UInt\", BorderColor, \"PtrP\", PBRUSH)\n               ; Fill the path\n               DllCall(\"Gdiplus.dll\\GdipFillPath\", \"Ptr\", PGRAPHICS, \"Ptr\", PBRUSH, \"Ptr\", PPATH)\n               ; Free the brush\n               DllCall(\"Gdiplus.dll\\GdipDeleteBrush\", \"Ptr\", PBRUSH)\n               ; Reset the path\n               DllCall(\"Gdiplus.dll\\GdipResetPath\", \"Ptr\", PPATH)\n               ; Add a new 'inner' path\n               PathX := PathY := BorderWidth, PathW -= BorderWidth, PathH -= BorderWidth, Rounded -= BorderWidth\n               If (Rounded < 1) ; the path is a rectangular rectangle\n                  This.PathAddRectangle(PPATH, PathX, PathY, PathW - PathX, PathH - PathY)\n               Else ; the path is a rounded rectangle\n                  This.PathAddRoundedRect(PPATH, PathX, PathY, PathW, PathH, Rounded)\n               ; If a BorderColor has been drawn, BkgColors must be opaque\n               BkgColor1 := 0xFF000000 | BkgColor1\n               BkgColor2 := 0xFF000000 | BkgColor2               \n            }\n            PathW -= PathX\n            PathH -= PathY\n            PBRUSH := 0\n            If (Mode = 0) { ; the background is unicolored\n               ; Create a SolidBrush\n               DllCall(\"Gdiplus.dll\\GdipCreateSolidFill\", \"UInt\", BkgColor1, \"PtrP\", PBRUSH)\n               ; Fill the path\n               DllCall(\"Gdiplus.dll\\GdipFillPath\", \"Ptr\", PGRAPHICS, \"Ptr\", PBRUSH, \"Ptr\", PPATH)\n            }\n            Else If (Mode = 1) || (Mode = 2) { ; the background is bicolored\n               ; Create a LineGradientBrush\n               This.SetRectF(RECTF, PathX, PathY, PathW, PathH)\n               DllCall(\"Gdiplus.dll\\GdipCreateLineBrushFromRect\", \"Ptr\", &RECTF\n                     , \"UInt\", BkgColor1, \"UInt\", BkgColor2, \"Int\", Mode & 1, \"Int\", 3, \"PtrP\", PBRUSH)\n               DllCall(\"Gdiplus.dll\\GdipSetLineGammaCorrection\", \"Ptr\", PBRUSH, \"Int\", 1)\n               ; Set up colors and positions\n               This.SetRect(COLORS, BkgColor1, BkgColor1, BkgColor2, BkgColor2) ; sorry for function misuse\n               This.SetRectF(POSITIONS, 0, 0.5, 0.5, 1) ; sorry for function misuse\n               DllCall(\"Gdiplus.dll\\GdipSetLinePresetBlend\", \"Ptr\", PBRUSH\n                     , \"Ptr\", &COLORS, \"Ptr\", &POSITIONS, \"Int\", 4)\n               ; Fill the path\n               DllCall(\"Gdiplus.dll\\GdipFillPath\", \"Ptr\", PGRAPHICS, \"Ptr\", PBRUSH, \"Ptr\", PPATH)\n            }\n            Else If (Mode >= 3) && (Mode <= 6) { ; the background is a gradient\n               ; Determine the brush's width/height\n               W := Mode = 6 ? PathW / 2 : PathW  ; horizontal\n               H := Mode = 5 ? PathH / 2 : PathH  ; vertical\n               ; Create a LineGradientBrush\n               This.SetRectF(RECTF, PathX, PathY, W, H)\n               DllCall(\"Gdiplus.dll\\GdipCreateLineBrushFromRect\", \"Ptr\", &RECTF\n                     , \"UInt\", BkgColor1, \"UInt\", BkgColor2, \"Int\", Mode & 1, \"Int\", 3, \"PtrP\", PBRUSH)\n               DllCall(\"Gdiplus.dll\\GdipSetLineGammaCorrection\", \"Ptr\", PBRUSH, \"Int\", 1)\n               ; Fill the path\n               DllCall(\"Gdiplus.dll\\GdipFillPath\", \"Ptr\", PGRAPHICS, \"Ptr\", PBRUSH, \"Ptr\", PPATH)\n            }\n            Else { ; raised mode\n               DllCall(\"Gdiplus.dll\\GdipCreatePathGradientFromPath\", \"Ptr\", PPATH, \"PtrP\", PBRUSH)\n               ; Set Gamma Correction\n               DllCall(\"Gdiplus.dll\\GdipSetPathGradientGammaCorrection\", \"Ptr\", PBRUSH, \"UInt\", 1)\n               ; Set surround and center colors\n               VarSetCapacity(ColorArray, 4, 0)\n               NumPut(BkgColor1, ColorArray, 0, \"UInt\")\n               DllCall(\"Gdiplus.dll\\GdipSetPathGradientSurroundColorsWithCount\", \"Ptr\", PBRUSH, \"Ptr\", &ColorArray\n                   , \"IntP\", 1)\n               DllCall(\"Gdiplus.dll\\GdipSetPathGradientCenterColor\", \"Ptr\", PBRUSH, \"UInt\", BkgColor2)\n               ; Set the FocusScales\n               FS := (BtnH < BtnW ? BtnH : BtnW) / 3\n               XScale := (BtnW - FS) / BtnW\n               YScale := (BtnH - FS) / BtnH\n               DllCall(\"Gdiplus.dll\\GdipSetPathGradientFocusScales\", \"Ptr\", PBRUSH, \"Float\", XScale, \"Float\", YScale)\n               ; Fill the path\n               DllCall(\"Gdiplus.dll\\GdipFillPath\", \"Ptr\", PGRAPHICS, \"Ptr\", PBRUSH, \"Ptr\", PPATH)\n            }\n            ; Free resources\n            DllCall(\"Gdiplus.dll\\GdipDeleteBrush\", \"Ptr\", PBRUSH)\n            DllCall(\"Gdiplus.dll\\GdipDeletePath\", \"Ptr\", PPATH)\n         } Else { ; Create a bitmap from HBITMAP or file\n            If This.IsInt(Image)\n               If (Opt[3] = \"HICON\")\n                  DllCall(\"Gdiplus.dll\\GdipCreateBitmapFromHICON\", \"Ptr\", Image, \"PtrP\", PBM)\n               Else\n                  DllCall(\"Gdiplus.dll\\GdipCreateBitmapFromHBITMAP\", \"Ptr\", Image, \"Ptr\", 0, \"PtrP\", PBM)\n            Else\n               DllCall(\"Gdiplus.dll\\GdipCreateBitmapFromFile\", \"WStr\", Image, \"PtrP\", PBM)\n            ; Draw the bitmap\n            DllCall(\"Gdiplus.dll\\GdipDrawImageRectI\", \"Ptr\", PGRAPHICS, \"Ptr\", PBM, \"Int\", 0, \"Int\", 0\n                  , \"Int\", BtnW, \"Int\", BtnH)\n            ; Free the bitmap\n            DllCall(\"Gdiplus.dll\\GdipDisposeImage\", \"Ptr\", PBM)\n         }\n         ; -------------------------------------------------------------------------------------------------------------\n         ; Draw the caption\n         If (BtnCaption <> \"\") {\n            ; Create a StringFormat object\n            DllCall(\"Gdiplus.dll\\GdipStringFormatGetGenericTypographic\", \"PtrP\", HFORMAT)\n            ; Text color\n            DllCall(\"Gdiplus.dll\\GdipCreateSolidFill\", \"UInt\", TxtColor, \"PtrP\", PBRUSH)\n            ; Horizontal alignment\n            HALIGN := (BtnStyle & BS_CENTER) = BS_CENTER ? SA_CENTER\n                    : (BtnStyle & BS_CENTER) = BS_RIGHT  ? SA_RIGHT\n                    : (BtnStyle & BS_CENTER) = BS_Left   ? SA_LEFT\n                    : SA_CENTER\n            DllCall(\"Gdiplus.dll\\GdipSetStringFormatAlign\", \"Ptr\", HFORMAT, \"Int\", HALIGN)\n            ; Vertical alignment\n            VALIGN := (BtnStyle & BS_VCENTER) = BS_TOP ? 0\n                    : (BtnStyle & BS_VCENTER) = BS_BOTTOM ? 2\n                    : 1\n            DllCall(\"Gdiplus.dll\\GdipSetStringFormatLineAlign\", \"Ptr\", HFORMAT, \"Int\", VALIGN)\n            ; Set render quality to system default\n            DllCall(\"Gdiplus.dll\\GdipSetTextRenderingHint\", \"Ptr\", PGRAPHICS, \"Int\", 0)\n            ; Set the text's rectangle\n            VarSetCapacity(RECT, 16, 0)\n            NumPut(BtnW, RECT,  8, \"Float\")\n            NumPut(BtnH, RECT, 12, \"Float\")\n            ; Draw the text\n            DllCall(\"Gdiplus.dll\\GdipDrawString\", \"Ptr\", PGRAPHICS, \"WStr\", BtnCaption, \"Int\", -1\n                  , \"Ptr\", PFONT, \"Ptr\", &RECT, \"Ptr\", HFORMAT, \"Ptr\", PBRUSH)\n         }\n         ; -------------------------------------------------------------------------------------------------------------\n         ; Create a HBITMAP handle from the bitmap and add it to the array\n         DllCall(\"Gdiplus.dll\\GdipCreateHBITMAPFromBitmap\", \"Ptr\", PBITMAP, \"PtrP\", HBITMAP, \"UInt\", 0X00FFFFFF)\n         This.BitMaps[Idx] := HBITMAP\n         ; Free resources\n         DllCall(\"Gdiplus.dll\\GdipDeleteBrush\", \"Ptr\", PBRUSH)\n         DllCall(\"Gdiplus.dll\\GdipDeleteStringFormat\", \"Ptr\", HFORMAT)\n      }\n      ; Now free remaining the GDI+ objects\n      DllCall(\"Gdiplus.dll\\GdipDisposeImage\", \"Ptr\", PBITMAP)\n      DllCall(\"Gdiplus.dll\\GdipDeleteGraphics\", \"Ptr\", PGRAPHICS)\n      DllCall(\"Gdiplus.dll\\GdipDeleteFont\", \"Ptr\", PFONT)\n      This.Delete(\"Bitmap\")\n      This.Delete(\"Graphics\")\n      This.Delete(\"Font\")\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Create the ImageList\n      HIL := DllCall(\"Comctl32.dll\\ImageList_Create\"\n                   , \"UInt\", BtnW, \"UInt\", BtnH, \"UInt\", ILC_COLOR32, \"Int\", 6, \"Int\", 0, \"Ptr\")\n      Loop, % (This.BitMaps.MaxIndex() > 1 ? 6 : 1) {\n         HBITMAP := This.BitMaps.HasKey(A_Index) ? This.BitMaps[A_Index] : This.BitMaps.1\n         DllCall(\"Comctl32.dll\\ImageList_Add\", \"Ptr\", HIL, \"Ptr\", HBITMAP, \"Ptr\", 0)\n      }\n      ; Create a BUTTON_IMAGELIST structure\n      VarSetCapacity(BIL, 20 + A_PtrSize, 0)\n      ; Get the currently assigned image list\n      DllCall(\"User32.dll\\SendMessage\", \"Ptr\", HWND, \"UInt\", BCM_GETIMAGELIST, \"Ptr\", 0, \"Ptr\", &BIL)\n      IL := NumGet(BIL, \"UPtr\")\n      ; Create a new BUTTON_IMAGELIST structure\n      VarSetCapacity(BIL, 20 + A_PtrSize, 0)\n      NumPut(HIL, BIL, 0, \"Ptr\")\n      Numput(BUTTON_IMAGELIST_ALIGN_CENTER, BIL, A_PtrSize + 16, \"UInt\")\n      ; Hide buttons's caption\n      ControlSetText, , , ahk_id %HWND%\n      Control, Style, +%BS_BITMAP%, , ahk_id %HWND%\n      ; Remove the currently assigned image list, if any\n      If(IL)\n         IL_Destroy(IL)\n      ; Assign the ImageList to the button\n      DllCall(\"User32.dll\\SendMessage\", \"Ptr\", HWND, \"UInt\", BCM_SETIMAGELIST, \"Ptr\", 0, \"Ptr\", 0)\n      DllCall(\"User32.dll\\SendMessage\", \"Ptr\", HWND, \"UInt\", BCM_SETIMAGELIST, \"Ptr\", 0, \"Ptr\", &BIL)\n      ; Free the bitmaps\n      This.FreeBitmaps()\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; All done successfully\n      Return True\n   }\n   ; ===================================================================================================================\n   ; Set the default GUI color\n   SetGuiColor(GuiColor) {\n      ; GuiColor     -  RGB integer value (0xRRGGBB) or HTML color name (\"Red\").\n      If !(GuiColor + 0) && !This.HTML.HasKey(GuiColor)\n         Return False\n      This.DefGuiColor := (This.HTML.HasKey(GuiColor) ? This.HTML[GuiColor] : GuiColor) & 0xFFFFFF\n      Return True\n   }\n   ; ===================================================================================================================\n   ; Set the default text color\n   SetTxtColor(TxtColor) {\n      ; TxtColor     -  RGB integer value (0xRRGGBB) or HTML color name (\"Red\").\n      If !(TxtColor + 0) && !This.HTML.HasKey(TxtColor)\n         Return False\n      This.DefTxtColor := (This.HTML.HasKey(TxtColor) ? This.HTML[TxtColor] : TxtColor) & 0xFFFFFF\n      Return True\n   }\n}\n\nUseGDIP(Params*) { ; Loads and initializes the Gdiplus.dll at load-time\n   ; GET_MODULE_HANDLE_EX_FLAG_PIN = 0x00000001\n   Static GdipObject := \"\"\n        , GdipModule := \"\"\n        , GdipToken  := \"\"\n   Static OnLoad := UseGDIP()\n   If (GdipModule = \"\") {\n      If !DllCall(\"LoadLibrary\", \"Str\", \"Gdiplus.dll\", \"UPtr\")\n         UseGDIP_Error(\"The Gdiplus.dll could not be loaded!`n`nThe program will exit!\")\n      If !DllCall(\"GetModuleHandleEx\", \"UInt\", 0x00000001, \"Str\", \"Gdiplus.dll\", \"PtrP\", GdipModule, \"UInt\")\n         UseGDIP_Error(\"The Gdiplus.dll could not be loaded!`n`nThe program will exit!\")\n      VarSetCapacity(SI, 24, 0), NumPut(1, SI, 0, \"UInt\") ; size of 64-bit structure\n      If DllCall(\"Gdiplus.dll\\GdiplusStartup\", \"PtrP\", GdipToken, \"Ptr\", &SI, \"Ptr\", 0)\n         UseGDIP_Error(\"GDI+ could not be startet!`n`nThe program will exit!\")\n      GdipObject := {Base: {__Delete: Func(\"UseGDIP\").Bind(GdipModule, GdipToken)}}\n   }\n   Else If (Params[1] = GdipModule) && (Params[2] = GdipToken)\n      DllCall(\"Gdiplus.dll\\GdiplusShutdown\", \"Ptr\", GdipToken)\n}\nUseGDIP_Error(ErrorMsg) {\n   MsgBox, 262160, UseGDIP, %ErrorMsg%\n   ExitApp\n}"
  },
  {
    "path": "Lib/Classes/Class_RichEdit.ahk",
    "content": "﻿; ======================================================================================================================\n; Scriptname:     Class_RichEdit.ahk\n; Namespace:      RichEdit\n; Author:         just me\n; AHK Version:    1.1.21.03 (Unicode)\n; OS Version:     Win 8.1 (x64)\n; Function:       The class provides some wrapper functions for rich edit controls (v4.1 Unicode).\n; Change History:\n;    0.1.05.00    2015-04-14/just me - fixed LoadRTF() not closing the file after reading\n;    0.1.04.00    2014-08-27/just me - fixed SetParaIndent() and changed indentation sample\n;    0.1.03.00    2014-03-03/just me - added GetTextRange()\n;    0.1.02.00    2013-12-01/just me - changed SetText() to handle RTF formatted text properly\n;    0.1.01.00    2013-11-29/just me - bug fix -> GetSelText()\n;    0.1.00.00    2013-11-17/just me - initial beta release\n; Credits:\n;    corrupt for cRichEdit:\n;       http://www.autohotkey.com/board/topic/17869-crichedit-standard-richedit-control-for-autohotkey-scripts/\n;    jballi for HE_Print:\n;       http://www.autohotkey.com/board/topic/45513-function-he-print-wysiwyg-print-for-the-hiedit-control/\n;    majkinetor for Dlg:\n;       http://www.autohotkey.com/board/topic/15836-module-dlg-501/\n; ======================================================================================================================\nClass RichEdit {\n   ; ===================================================================================================================\n   ; Class variables - do not change !!!\n   ; ===================================================================================================================\n   ; RichEdit v4.1 (Unicode)\n   Static Class := \"RICHEDIT50W\"\n   ; RichEdit v4.1 (Unicode)\n   Static DLL := \"Msftedit.dll\"\n   ; DLL handle\n   Static Instance := DllCall(\"Kernel32.dll\\LoadLibrary\", \"Str\", RichEdit.DLL, \"UPtr\")\n   ; Callback function handling RichEdit messages\n   Static SubclassCB := 0\n   ; Number of controls/instances\n   Static Controls := 0\n   ; ===================================================================================================================\n   ; Instance variables - do not change !!!\n   ; ===================================================================================================================\n   GuiName := \"\"\n   GuiHwnd := \"\"\n   HWND := \"\"\n   DefFont := \"\"\n   ; ===================================================================================================================\n   ; CONSTRUCTOR\n   ; ===================================================================================================================\n   __New(GuiName, Options, MultiLine := True) {\n      Static WS_TABSTOP := 0x10000, WS_HSCROLL := 0x100000, WS_VSCROLL := 0x200000, WS_VISIBLE := 0x10000000\n           , WS_CHILD := 0x40000000\n           , WS_EX_CLIENTEDGE := 0x200, WS_EX_STATICEDGE := 0x20000\n           , ES_MULTILINE := 0x0004, ES_AUTOVSCROLL := 0x40, ES_AUTOHSCROLL := 0x80, ES_NOHIDESEL := 0x0100\n           , ES_WANTRETURN := 0x1000, ES_DISABLENOSCROLL := 0x2000, ES_SUNKEN := 0x4000, ES_SAVESEL := 0x8000\n           , ES_SELECTIONBAR := 0x1000000\n      ; Check for Unicode\n      If !(SubStr(A_AhkVersion, 1, 1) > 1) && !(A_IsUnicode) {\n         MsgBox, 16, % A_ThisFunc, % This.__Class . \" requires a unicode version of AHK!\"\n         Return False\n      }\n      ; Do not instantiate instances of RichEdit\n      If (This.Base.HWND)\n         Return False\n      ; Determine the HWND of the GUI\n      Gui, %GuiName%:+LastFoundExist\n      GuiHwnd := WinExist()\n      If !(GuiHwnd) {\n         ErrorLevel := \"ERROR: Gui \" . GuiName . \" does not exist!\"\n         Return False\n      }\n      ; Load library if necessary\n      If (This.Base.Instance = 0) {\n         This.Base.Instance := DllCall(\"Kernel32.dll\\LoadLibrary\", \"Str\", This.Base.DLL, \"UPtr\")\n         If (ErrorLevel) {\n            ErrorLevel := \"ERROR: Error loading \" . This.Base.DLL . \" - \" . ErrorLevel\n            Return False\n         }\n      }\n      ; Specify default styles & exstyles\n      Styles := WS_TABSTOP | WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL\n      If (MultiLine)\n         Styles |= WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_NOHIDESEL | ES_WANTRETURN\n                 | ES_DISABLENOSCROLL | ES_SAVESEL ; | ES_SELECTIONBAR does not work properly\n      ExStyles := WS_EX_STATICEDGE\n      ; Create the control\n      CtrlClass := This.Class\n      Gui, %GuiName%:Add, Custom, Class%CtrlClass% %Options% hwndHWND +%Styles% +E%ExStyles%\n      If (MultiLine) {\n         ; Adjust the formatting rectangle for multiline controls to simulate a selection bar\n         ; EM_GETRECT = 0xB2, EM_SETRECT = 0xB3\n         VarSetCapacity(RECT, 16, 0)\n         SendMessage, 0xB2, 0, &RECT, , ahk_id %HWND%\n         NumPut(NumGet(RECT, 0, \"Int\") + 10, RECT, 0, \"Int\")\n         NumPut(NumGet(RECT, 4, \"Int\") + 2,  RECT, 4, \"Int\")\n         SendMessage, 0xB3, 0, &RECT, , ahk_id %HWND%\n         ; Set advanced typographic options\n         ; EM_SETTYPOGRAPHYOPTIONS = 0x04CA (WM_USER + 202)\n         ; TO_ADVANCEDTYPOGRAPHY\t= 1, TO_ADVANCEDLAYOUT = 8 ? not documented\n         SendMessage, 0x04CA, 0x01, 0x01, , ahk_id %HWND%\n      }\n      ; Initialize control\n      ; EM_SETLANGOPTIONS = 0x0478 (WM_USER + 120)\n      ; IMF_AUTOKEYBOARD = 0x01, IMF_AUTOFONT = 0x02\n      SendMessage, 0x0478, 0, 0x03, , ahk_id %HWND%\n      ; Subclass the control to get Tab key and prevent Esc from sending a WM_CLOSE message to the parent window.\n      ; One of majkinetor's splendid discoveries!\n      ; Initialize SubclassCB\n      If (This.Base.SubclassCB = 0)\n         This.Base.SubclassCB := RegisterCallback(\"RichEdit.SubclassProc\")\n      DllCall(\"Comctl32.dll\\SetWindowSubclass\", \"Ptr\", HWND, \"Ptr\", This.Base.SubclassCB, \"Ptr\", HWND, \"Ptr\", 0)\n      This.GuiName := GuiName\n      This.GuiHwnd := GuiHwnd\n      This.HWND := HWND\n      This.DefFont := This.GetFont(1)\n      This.DefFont.Default := 1\n      ; Correct AHK font size setting, if necessary\n      If (Round(This.DefFont.Size) <> This.DefFont.Size) {\n         This.DefFont.Size := Round(This.DefFont.Size)\n         This.SetDefaultFont()\n      }\n      This.Base.Controls += 1\n      ; Initialize the print margins\n      This.GetMargins()\n      ; Initialize the text limit\n      This.LimitText(2147483647)\n   }\n   ; ===================================================================================================================\n   ; DESTRUCTOR\n   ; ===================================================================================================================\n   __Delete() {\n      If (This.HWND) {\n         DllCall(\"Comctl32.dll\\RemoveWindowSubclass\", \"Ptr\", This.HWND, \"Ptr\", This.Base.SubclassCB, \"Ptr\", 0)\n         DllCall(\"User32.dll\\DestroyWindow\", \"Ptr\", This.HWND)\n         This.HWND := 0\n         This.Base.Controls -= 1\n         If (This.Base.Controls = 0) {\n            DllCall(\"Kernel32.dll\\FreeLibrary\", \"Ptr\", This.Base.Instance)\n            This.Base.Instance := 0\n         }\n      }\n   }\n   ; ===================================================================================================================\n   ; ===================================================================================================================\n   ; INTERNAL CLASSES ==================================================================================================\n   ; ===================================================================================================================\n   ; ===================================================================================================================\n   Class CF2 { ; CHARFORMAT2 structure -> http://msdn.microsoft.com/en-us/library/bb787883(v=vs.85).aspx\n      __New() {\n         Static CF2_Size := 116\n         This.Insert(\":\", {Mask: {O: 4, T: \"UInt\"}, Effects: {O: 8, T: \"UInt\"}\n                         , Height: {O: 12, T: \"Int\"}, Offset: {O: 16, T: \"Int\"}\n                         , TextColor: {O: 20, T: \"Int\"}, CharSet: {O: 24, T: \"UChar\"}\n                         , PitchAndFamily: {O: 25, T: \"UChar\"}, FaceName: {O: 26, T: \"Str32\"}\n                         , Weight: {O: 90, T: \"UShort\"}, Spacing: {O: 92, T: \"Short\"}\n                         , BackColor: {O: 96, T: \"UInt\"}, LCID: {O: 100, T: \"UInt\"}\n                         , Cookie: {O: 104, T: \"UInt\"}, Style: {O: 108, T: \"Short\"}\n                         , Kerning: {O: 110, T: \"UShort\"}, UnderlineType: {O: 112, T: \"UChar\"}\n                         , Animation: {O: 113, T: \"UChar\"}, RevAuthor: {O: 114, T: \"UChar\"}\n                         , UnderlineColor: {O: 115, T: \"UChar\"}})\n         This.Insert(\".\")\n         This.SetCapacity(\".\", CF2_Size)\n         Addr :=  This.GetAddress(\".\")\n         DllCall(\"Kernel32.dll\\RtlZeroMemory\", \"Ptr\", Addr, \"Ptr\", CF2_Size)\n         NumPut(CF2_Size, Addr + 0, 0, \"UInt\")\n      }\n      __Get(Name) {\n         Addr := This.GetAddress(\".\")\n         If (Name = \"CF2\")\n            Return Addr\n         If !This[\":\"].HasKey(Name)\n            Return \"\"\n         Attr := This[\":\"][Name]\n         If (Name <> \"FaceName\")\n            Return NumGet(Addr + 0, Attr.O, Attr.T)\n         Return StrGet(Addr + Attr.O, 32)\n      }\n      __Set(Name, Value) {\n         Addr := This.GetAddress(\".\")\n         If !This[\":\"].HasKey(Name)\n            Return \"\"\n         Attr := This[\":\"][Name]\n         If (Name <> \"FaceName\")\n            NumPut(Value, Addr + 0, Attr.O, Attr.T)\n         Else\n            StrPut(Value, Addr + Attr.O, 32)\n         Return Value\n      }\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   Class PF2 { ; PARAFORMAT2 structure -> http://msdn.microsoft.com/en-us/library/bb787942(v=vs.85).aspx\n      __New() {\n         Static PF2_Size := 188\n         This.Insert(\":\", {Mask: {O: 4, T: \"UInt\"}, Numbering: {O: 8, T: \"UShort\"}\n                         , StartIndent: {O: 12, T: \"Int\"}, RightIndent: {O: 16, T: \"Int\"}\n                         , Offset: {O: 20, T: \"Int\"}, Alignment: {O: 24, T: \"UShort\"}\n                         , TabCount: {O: 26, T: \"UShort\"}, Tabs: {O: 28, T: \"UInt\"}\n                         , SpaceBefore: {O: 156, T: \"Int\"}, SpaceAfter: {O: 160, T: \"Int\"}\n                         , LineSpacing: {O: 164, T: \"Int\"}, Style: {O: 168, T: \"Short\"}\n                         , LineSpacingRule: {O: 170, T: \"UChar\"}, OutlineLevel: {O: 171, T: \"UChar\"}\n                         , ShadingWeight: {O: 172, T: \"UShort\"}, ShadingStyle: {O: 174, T: \"UShort\"}\n                         , NumberingStart: {O: 176, T: \"UShort\"}, NumberingStyle: {O: 178, T: \"UShort\"}\n                         , NumberingTab: {O: 180, T: \"UShort\"}, BorderSpace: {O: 182, T: \"UShort\"}\n                         , BorderWidth: {O: 184, T: \"UShort\"}, Borders: {O: 186, T: \"UShort\"}})\n         This.Insert(\".\")\n         This.SetCapacity(\".\", PF2_Size)\n         Addr :=  This.GetAddress(\".\")\n         DllCall(\"Kernel32.dll\\RtlZeroMemory\", \"Ptr\", Addr, \"Ptr\", PF2_Size)\n         NumPut(PF2_Size, Addr + 0, 0, \"UInt\")\n      }\n      __Get(Name) {\n         Addr := This.GetAddress(\".\")\n         If (Name = \"PF2\")\n            Return Addr\n         If !This[\":\"].HasKey(Name)\n            Return \"\"\n         Attr := This[\":\"][Name]\n         If (Name <> \"Tabs\")\n            Return NumGet(Addr + 0, Attr.O, Attr.T)\n         Tabs := []\n         Offset := Attr.O - 4\n         Loop, 32\n            Tabs[A_Index] := NumGet(Addr + 0, Offset += 4, \"UInt\")\n         Return Tabs\n      }\n      __Set(Name, Value) {\n         Addr := This.GetAddress(\".\")\n         If !This[\":\"].HasKey(Name)\n            Return \"\"\n         Attr := This[\":\"][Name]\n         If (Name <> \"Tabs\") {\n            NumPut(Value, Addr + 0, Attr.O, Attr.T)\n            Return Value\n         }\n         If !IsObject(Value)\n            Return \"\"\n         Offset := Attr.O - 4\n         For Each, Tab In Value\n            NumPut(Tab, Addr + 0, Offset += 4, \"UInt\")\n         Return Tabs\n      }\n   }\n   ; ===================================================================================================================\n   ; ===================================================================================================================\n   ; PRIVATE METHODS ===================================================================================================\n   ; ===================================================================================================================\n   ; ===================================================================================================================\n   GetBGR(RGB) { ; Get numeric BGR value from numeric RGB value or HTML color name\n      Static HTML := {BLACK:  0x000000, SILVER: 0xC0C0C0, GRAY:   0x808080, WHITE:   0xFFFFFF\n                    , MAROON: 0x000080, RED:    0x0000FF, PURPLE: 0x800080, FUCHSIA: 0xFF00FF\n                    , GREEN:  0x008000, LIME:   0x00FF00, OLIVE:  0x008080, YELLOW:  0x00FFFF\n                    , NAVY:   0x800000, BLUE:   0xFF0000, TEAL:   0x808000, AQUA:    0xFFFF00}\n      If HTML.HasKey(RGB)\n         Return HTML[RGB]\n      Return ((RGB & 0xFF0000) >> 16) + (RGB & 0x00FF00) + ((RGB & 0x0000FF) << 16)\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetRGB(BGR) {  ; Get numeric RGB value from numeric BGR-Value\n      Return ((BGR & 0xFF0000) >> 16) + (BGR & 0x00FF00) + ((BGR & 0x0000FF) << 16)\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetMeasurement() { ; Get locale measurement (metric / inch)\n      ; LOCALE_USER_DEFAULT = 0x0400, LOCALE_IMEASURE = 0x0D, LOCALE_RETURN_NUMBER = 0x20000000\n      Static Metric := 2.54  ; centimeters\n           , Inches := 1.00  ; inches\n           , Measurement := \"\"\n           , Len := A_IsUnicode ? 2 : 4\n      If (Measurement = \"\") {\n         VarSetCapacity(LCD, 4, 0)\n         DllCall(\"Kernel32.dll\\GetLocaleInfo\", \"UInt\", 0x400, \"UInt\", 0x2000000D, \"Ptr\", &LCD, \"Int\", Len)\n         Measurement := NumGet(LCD, 0, \"UInt\") ? Inches : Metric\n      }\n      Return Measurement\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SubclassProc(M, W, L, I, R) { ; RichEdit subclassproc\n      ; Left out first parameter HWND, will be found in \"This\" when called by system\n      ; See -> http://msdn.microsoft.com/en-us/library/bb776774%28VS.85%29.aspx\n      If (M = 0x87) ; WM_GETDLGCODE\n         Return 4   ; DLGC_WANTALLKEYS\n      Return DllCall(\"Comctl32.dll\\DefSubclassProc\", \"Ptr\", This, \"UInt\", M, \"Ptr\", W, \"Ptr\", L)\n   }\n   ; ===================================================================================================================\n   ; ===================================================================================================================\n   ; PUBLIC METHODS ====================================================================================================\n   ; ===================================================================================================================\n   ; ===================================================================================================================\n   ; -------------------------------------------------------------------------------------------------------------------\n   ; Methods to be used by advanced users only\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetCharFormat() { ; Retrieves the character formatting of the current selection.\n      ; For details see http://msdn.microsoft.com/en-us/library/bb787883(v=vs.85).aspx.\n      ; Returns a 'CF2' object containing the formatting settings.\n      ; EM_GETCHARFORMAT = 0x043A\n      CF2 := New This.CF2\n      SendMessage, 0x043A, 1, % CF2.CF2, , % \"ahk_id \" . This.HWND\n      Return (CF2.Mask ? CF2 : False)\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetCharFormat(CF2) { ; Sets character formatting of the current selection.\n      ; For details see http://msdn.microsoft.com/en-us/library/bb787883(v=vs.85).aspx.\n      ; CF2 : CF2 object like returned by GetCharFormat().\n      ; EM_SETCHARFORMAT = 0x0444\n      SendMessage, 0x0444, 1, % CF2.CF2, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetParaFormat() { ; Retrieves the paragraph formatting of the current selection.\n      ; For details see http://msdn.microsoft.com/en-us/library/bb787942(v=vs.85).aspx.\n      ; Returns a 'PF2' object containing the formatting settings.\n      ; EM_GETPARAFORMAT = 0x043D\n      PF2 := New This.PF2\n      SendMessage, 0x043D, 0, % PF2.PF2, , % \"ahk_id \" . This.HWND\n      Return (PF2.Mask ? PF2 : False)\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetParaFormat(PF2) { ; Sets the  paragraph formatting for the current selection.\n      ; For details see http://msdn.microsoft.com/en-us/library/bb787942(v=vs.85).aspx.\n      ; PF2 : PF2 object like returned by GetParaFormat().\n      ; EM_SETPARAFORMAT = 0x0447\n      SendMessage, 0x0447, 0, % PF2.PF2, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ; Control specific\n   ; -------------------------------------------------------------------------------------------------------------------\n   IsModified() { ; Has the control been  modified?\n      ; EM_GETMODIFY = 0xB8\n      SendMessage, 0xB8, 0, 0, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetModified(Modified := False) { ; Sets or clears the modification flag for an edit control.\n      ; EM_SETMODIFY = 0xB9\n      SendMessage, 0xB9, % !!Modified, 0, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetEventMask(Events := \"\") { ; Set the events which shall send notification codes control's owner\n      ; Events : Array containing one or more of the keys defined in 'ENM'.\n      ; For details see http://msdn.microsoft.com/en-us/library/bb774238(v=vs.85).aspx\n      ; EM_SETEVENTMASK\t= \t0x0445\n      Static ENM := {NONE: 0x00, CHANGE: 0x01, UPDATE: 0x02, SCROLL: 0x04, SCROLLEVENTS: 0x08, DRAGDROPDONE: 0x10\n                   , PARAGRAPHEXPANDED: 0x20, PAGECHANGE: 0x40, KEYEVENTS: 0x010000, MOUSEEVENTS: 0x020000\n                   , REQUESTRESIZE: 0x040000, SELCHANGE: 0x080000, DROPFILES: 0x100000, PROTECTED: 0x200000\n                   , LINK: 0x04000000}\n      If !IsObject(Events)\n         Events := [\"NONE\"]\n      Mask := 0\n      For Each, Event In Events {\n         If ENM.HasKey(Event)\n            Mask |= ENM[Event]\n         Else\n            Return False\n      }\n      SendMessage, 0x0445, 0, %Mask%, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ; Loading and storing RTF format\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetRTF(Selection := False) { ; Gets the whole content of the control as rich text.\n      ; Selection = False : whole contents (default)\n      ; Selection = True  : current selection\n      ; EM_STREAMOUT = 0x044A\n      ; SF_TEXT = 0x1, SF_RTF = 0x2, SF_RTFNOOBJS = 0x3, SF_UNICODE = 0x10, SF_USECODEPAGE =\t0x0020\n      ; SFF_PLAINRTF = 0x4000, SFF_SELECTION = 0x8000\n      ; UTF-8 = 65001, UTF-16 = 1200\n      Static GetRTFCB := 0\n      Flags := 0x4022 | (1200 << 16) | (Selection ? 0x8000 : 0)\n      GetRTFCB := RegisterCallback(\"RichEdit.GetRTFProc\")\n      VarSetCapacity(ES, (A_PtrSize * 2) + 4, 0) ; EDITSTREAM structure\n      NumPut(This.HWND, ES, 0, \"Ptr\")            ; dwCookie\n      NumPut(GetRTFCB, ES, A_PtrSize + 4, \"Ptr\") ; pfnCallback\n      SendMessage, 0x044A, %Flags%, &ES, , % \"ahk_id \" . This.HWND\n      DllCall(\"Kernel32.dll\\GlobalFree\", \"Ptr\", GetRTFCB)\n      Return This.GetRTFProc(\"Get\", 0, 0)\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetRTFProc(pbBuff, cb, pcb) { ; Callback procedure for GetRTF\n      ; left out first parameter dwCookie, will be passed in \"This\" when called by system\n      Static RTF := \"\"\n      If (cb > 0) {\n         RTF .= StrGet(pbBuff, cb, \"CP0\")\n         Return 0\n      }\n      If (pbBuff = \"Get\") {\n         Out := RTF\n         VarSetCapacity(RTF, 0)\n         Return Out\n      }\n      Return 1\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   LoadRTF(FilePath, Selection := False) { ; Loads RTF file into the control.\n      ; FilePath = file path\n      ; Selection = False : whole contents (default)\n      ; Selection = True  : current selection\n      ; EM_STREAMIN = 0x0449\n      ; SF_TEXT = 0x1, SF_RTF = 0x2, SF_RTFNOOBJS = 0x3, SF_UNICODE = 0x10, SF_USECODEPAGE =\t0x0020\n      ; SFF_PLAINRTF = 0x4000, SFF_SELECTION = 0x8000\n      ; UTF-16 = 1200\n      Static LoadRTFCB := RegisterCallback(\"RichEdit.LoadRTFProc\")\n      Flags := 0x4002 | (Selection ? 0x8000 : 0) ; | (1200 << 16)\n      If !(File := FileOpen(FilePath, \"r\"))\n         Return False\n      VarSetCapacity(ES, (A_PtrSize * 2) + 4, 0)  ; EDITSTREAM structure\n      NumPut(File.__Handle, ES, 0, \"Ptr\")         ; dwCookie\n      NumPut(LoadRTFCB, ES, A_PtrSize + 4, \"Ptr\") ; pfnCallback\n      SendMessage, 0x0449, %Flags%, &ES, , % \"ahk_id \" . This.HWND\n      Result := ErrorLevel\n      File.Close()\n      Return Result\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   LoadRTFProc(pbBuff, cb, pcb) { ; Callback procedure for LoadRTF\n      ; Left out first parameter dwCookie, will be passed in \"This\" when called by system\n      Return !DllCall(\"ReadFile\", \"Ptr\", This, \"Ptr\", pbBuff, \"UInt\", cb, \"Ptr\", pcb, \"Ptr\", 0)\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ; Scrolling\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetScrollPos() { ; Obtains the current scroll position.\n      ; Returns on object with keys 'X' and 'Y' containing the scroll position.\n      ; EM_GETSCROLLPOS = 0x04DD\n      VarSetCapacity(PT, 8, 0)\n      SendMessage, 0x04DD, 0, &PT, , % \"ahk_id \" . This.HWND\n      Return {X: NumGet(PT, 0, \"Int\"), Y: NumGet(PT, 4, \"Int\")}\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetScrollPos(X, Y) { ; Scrolls the contents of a rich edit control to the specified point.\n      ; X : x-position to scroll to.\n      ; Y : y-position to scroll to.\n      ; EM_SETSCROLLPOS = 0x04DE\n      VarSetCapacity(PT, 8, 0)\n      NumPut(X, PT, 0, \"Int\")\n      NumPut(Y, PT, 4, \"Int\")\n      SendMessage, 0x04DE, 0, &PT, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ScrollCaret() { ; Scrolls the caret into view.\n      ; EM_SCROLLCARET = 0x00B7\n      SendMessage, 0x00B7, 0, 0, , % \"ahk_id \" . This.HWND\n      Return True\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ShowScrollBar(SB, Mode := True) { ; Shows or hides one of the scroll bars of a rich edit control.\n      ; SB   : Identifies which scroll bar to display: horizontal or vertical.\n      ;        This parameter must be 1 (SB_VERT) or 0 (SB_HORZ).\n      ; Mode : Specify TRUE to show the scroll bar and FALSE to hide it.\n      ; EM_SHOWSCROLLBAR = 0x0460 (WM_USER + 96)\n      SendMessage, 0x0460, %SB%, %Mode%, , % \"ahk_id \" . This.HWND\n      Return True\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ; Text and selection\n   ; -------------------------------------------------------------------------------------------------------------------\n   FindText(Find, Mode := \"\") { ; Finds Unicode text within a rich edit control.\n      ; Find : Text to search for.\n      ; Mode : Optional array containing one or more of the keys specified in 'FR'.\n      ;        For details see http://msdn.microsoft.com/en-us/library/bb788013(v=vs.85).aspx.\n      ; Returns True if the text was found; otherwise false.\n      ; EM_FINDTEXTEXW = 0x047C, EM_SCROLLCARET = 0x00B7\n      Static FR:= {DOWN: 1, WHOLEWORD: 2, MATCHCASE: 4}\n      Flags := 0\n      For Each, Value In Mode\n         If FR.HasKey(Value)\n            Flags |= FR[Value]\n      Sel := This.GetSel()\n      Min := (Flags & FR.DOWN) ? Sel.E : Sel.S\n      Max := (Flags & FR.DOWN) ? -1 : 0\n      VarSetCapacity(FTX, 16 + A_PtrSize, 0)\n      NumPut(Min, FTX, 0, \"Int\")\n      NumPut(Max, FTX, 4, \"Int\")\n      NumPut(&Find, FTX, 8, \"Ptr\")\n      SendMessage, 0x047C, %Flags%, &FTX, , % \"ahk_id \" . This.HWND\n      S := NumGet(FTX, 8 + A_PtrSize, \"Int\"), E := NumGet(FTX, 12 + A_PtrSize, \"Int\")\n      If (S = -1) && (E = -1)\n         Return False\n      This.SetSel(S, E)\n      This.ScrollCaret()\n      Return\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   FindWordBreak(CharPos, Mode := \"Left\") { ; Finds the next word break before or after the specified character position\n                                            ; or retrieves information about the character at that position.\n      ; CharPos : Character position.\n      ; Mode    : Can be one of the keys specified in 'WB'.\n      ; Returns the character index of the word break or other values depending on 'Mode'.\n      ; For details see http://msdn.microsoft.com/en-us/library/bb788018(v=vs.85).aspx.\n      ; EM_FINDWORDBREAK = 0x044C (WM_USER + 76)\n      Static WB := {LEFT: 0, RIGHT: 1, ISDELIMITER: 2, CLASSIFY: 3, MOVEWORDLEFT: 4, MOVEWORDRIGHT: 5, LEFTBREAK: 6\n                  , RIGHTBREAK: 7}\n      Option := WB.HasKey(Mode) ? WB[Mode] : 0\n      SendMessage, 0x044C, %Option%, %CharPos%, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetSelText() { ; Retrieves the currently selected text as plain text.\n      ; Returns selected text.\n      ; EM_GETSELTEXT = 0x043E, EM_EXGETSEL = 0x0434\n      VarSetCapacity(CR, 8, 0)\n      SendMessage, 0x0434, 0, &CR, , % \"ahk_id \" . This.HWND\n      L := NumGet(CR, 4, \"Int\") - NumGet(CR, 0, \"Int\") + 1\n      If (L > 1) {\n         VarSetCapacity(Text, L * 2, 0)\n         SendMessage, 0x043E, 0, &Text, , % \"ahk_id \" . This.HWND\n         VarSetCapacity(Text, -1)\n      }\n      Return Text\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetSel() { ; Retrieves the starting and ending character positions of the selection in a rich edit control.\n      ; Returns an object containing the keys S (start of selection) and E (end of selection)).\n      ; EM_EXGETSEL = 0x0434\n      VarSetCapacity(CR, 8, 0)\n      SendMessage, 0x0434, 0, &CR, , % \"ahk_id \" . This.HWND\n      Return {S: NumGet(CR, 0, \"Int\"), E: NumGet(CR, 4, \"Int\")}\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetText() { ; Gets the whole content of the control as plain text.\n      ; EM_GETTEXTEX = 0x045E\n      Text := \"\"\n      If (Length := This.GetTextLen() * 2) {\n         VarSetCapacity(GTX, (4 * 4) + (A_PtrSize * 2), 0) ; GETTEXTEX structure\n         NumPut(Length + 2, GTX, 0, \"UInt\") ; cb\n         NumPut(1200, GTX, 8, \"UInt\")       ; codepage = Unicode\n         VarSetCapacity(Text, Length + 2, 0)\n         SendMessage, 0x045E, &GTX, &Text, , % \"ahk_id \" . This.HWND\n         VarSetCapacity(Text, -1)\n      }\n      Return Text\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetTextLen() { ; Calculates text length in various ways.\n      ; EM_GETTEXTLENGTHEX = 0x045F\n      VarSetCapacity(GTL, 8, 0)     ; GETTEXTLENGTHEX structure\n      NumPut(1200, GTL, 4, \"UInt\")  ; codepage = Unicode\n      SendMessage, 0x045F, &GTL, 0, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetTextRange(Min, Max) { ; Retrieves a specified range of characters from a rich edit control.\n      ; Min : Character position index immediately preceding the first character in the range.\n      ;       Integer value to store as cpMin in the CHARRANGE structure.\n      ; Max : Character position immediately following the last character in the range.\n      ;       Integer value to store as cpMax in the CHARRANGE structure.\n      ; CHARRANGE -> http://msdn.microsoft.com/en-us/library/bb787885(v=vs.85).aspx\n      ; EM_GETTEXTRANGE = 0x044B\n      If (Max <= Min)\n         Return \"\"\n      VarSetCapacity(Text, (Max - Min) << !!A_IsUnicode, 0)\n      VarSetCapacity(TEXTRANGE, 16, 0) ; TEXTRANGE Struktur\n      NumPut(Min, TEXTRANGE, 0, \"UInt\")\n      NumPut(Max, TEXTRANGE, 4, \"UInt\")\n      NumPut(&Text, TEXTRANGE, 8, \"UPtr\")\n      SendMessage, 0x044B, 0, % &TEXTRANGE, , % \"ahk_id \" . This.HWND\n      VarSetCapacity(Text, -1) ; Länge des Zeichenspeichers korrigieren \n      Return Text\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   HideSelection(Mode) { ; Hides or shows the selection.\n      ; Mode : True to hide or False to show the selection.\n      ; EM_HIDESELECTION = 0x043F (WM_USER + 63)\n      SendMessage, 0x043F, %Mode%, 0, , % \"ahk_id \" . This.HWND\n      Return True\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   LimitText(Limit)  { ; Sets an upper limit to the amount of text the user can type or paste into a rich edit control.\n      ; Limit : Specifies the maximum amount of text that can be entered.\n      ;         If this parameter is zero, the default maximum is used, which is 64K characters.\n      ; EM_EXLIMITTEXT =  0x435 (WM_USER + 53)\n      SendMessage, 0x0435, 0, %Limit%, , % \"ahk_id \" . This.HWND\n      Return True\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ReplaceSel(Text := \"\") { ; Replaces the selected text with the specified text.\n      ; EM_REPLACESEL = 0xC2\n      SendMessage, 0xC2, 1, &Text, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetText(ByRef Text := \"\", Mode := \"\") { ; Replaces the selection or the whole content of the control.\n      ; Mode : Option flags. It can be any reasonable combination of the keys defined in 'ST'.\n      ; For details see http://msdn.microsoft.com/en-us/library/bb774284(v=vs.85).aspx.\n      ; EM_SETTEXTEX = 0x0461, CP_UNICODE = 1200\n      ; ST_DEFAULT = 0, ST_KEEPUNDO = 1, ST_SELECTION = 2, ST_NEWCHARS = 4 ???\n      Static ST := {DEFAULT: 0, KEEPUNDO: 1, SELECTION: 2}\n      Flags := 0\n      For Each, Value In Mode\n         If ST.HasKey(Value)\n            Flags |= ST[Value]\n      CP := 1200\n      BufAddr := &Text\n      ; RTF formatted text has to be passed as ANSI!!!\n      If (SubStr(Text, 1, 5) = \"{\\rtf\") || (SubStr(Text, 1, 5) = \"{urtf\") {\n         Len := StrPut(Text, \"CP0\")\n         VarSetCapacity(Buf, Len, 0)\n         StrPut(Text, &Buf, \"CP0\")\n         BufAddr := &Buf\n         CP := 0\n      }\n      VarSetCapacity(STX, 8, 0)     ; SETTEXTEX structure\n      NumPut(Flags, STX, 0, \"UInt\") ; flags\n      NumPut(CP  ,  STX, 4, \"UInt\") ; codepage\n      SendMessage, 0x0461, &STX, BufAddr, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetSel(Start, End) { ; Selects a range of characters.\n      ; Start : zero-based start index\n      ; End   : zero-beased end index (-1 = end of text))\n      ; EM_EXSETSEL = 0x0437\n      VarSetCapacity(CR, 8, 0)\n      NumPut(Start, CR, 0, \"Int\")\n      NumPut(End,   CR, 4, \"Int\")\n      SendMessage, 0x0437, 0, &CR, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ; Appearance, styles, and options\n   ; -------------------------------------------------------------------------------------------------------------------\n   AutoURL(On) { ; Turn AutoURLDetection on/off\n      ; EM_AUTOURLDETECT = 0x45B\n      SendMessage, 0x45B, % !!On, 0, , % \"ahk_id \" . This.HWND\n      WinSet, Redraw, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetOptions() { ; Retrieves rich edit control options.\n      ; Returns an array of currently the set options as the keys defined in 'ECO'.\n      ; For details see http://msdn.microsoft.com/en-us/library/bb774178(v=vs.85).aspx.\n      ; EM_GETOPTIONS = 0x044E\n      Static ECO := {AUTOWORDSELECTION: 0x01, AUTOVSCROLL: 0x40, AUTOHSCROLL: 0x80, NOHIDESEL: 0x100\n                   , READONLY: 0x800, WANTRETURN: 0x1000, SAVESEL: 0x8000, SELECTIONBAR: 0x01000000\n                   , VERTICAL: 0x400000}\n      SendMessage, 0x044E, 0, 0, , % \"ahk_id \" . This.HWND\n      O := ErrorLevel\n      Options := []\n      For Key, Value In ECO\n         If (O & Value)\n            Options.Insert(Key)\n      Return Options\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetStyles() { ; Retrieves the current edit style flags.\n      ; Returns an object containing keys as defined in 'SES'.\n      ; For details see http://msdn.microsoft.com/en-us/library/bb788031(v=vs.85).aspx.\n      ; EM_GETEDITSTYLE\t= 0x04CD (WM_USER + 205)\n      Static SES := {1: \"EMULATESYSEDIT\", 1: \"BEEPONMAXTEXT\", 4: \"EXTENDBACKCOLOR\", 32: \"NOXLTSYMBOLRANGE\", 64: \"USEAIMM\"\n                   , 128: \"NOIME\", 256: \"ALLOWBEEPS\", 512: \"UPPERCASE\", 1024: \"LOWERCASE\", 2048: \"NOINPUTSEQUENCECHK\"\n                   , 4096: \"BIDI\", 8192: \"SCROLLONKILLFOCUS\", 16384: \"XLTCRCRLFTOCR\", 32768: \"DRAFTMODE\"\n                   , 0x0010000: \"USECTF\", 0x0020000: \"HIDEGRIDLINES\", 0x0040000: \"USEATFONT\", 0x0080000: \"CUSTOMLOOK\"\n                   , 0x0100000: \"LBSCROLLNOTIFY\", 0x0200000: \"CTFALLOWEMBED\", 0x0400000: \"CTFALLOWSMARTTAG\"\n                   , 0x0800000: \"CTFALLOWPROOFING\"}\n      SendMessage, 0x04CD, 0, 0, , % \"ahk_id \" . This.HWND\n      Result := ErrorLevel\n      Styles := []\n      For Key, Value In SES\n         If (Result & Key)\n            Styles.Insert(Value)\n      Return Styles\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetZoom() { ; Gets the current zoom ratio.\n      ; Returns the zoom ratio in percent.\n      ; EM_GETZOOM = 0x04E0\n      VarSetCapacity(N, 4, 0), VarSetCapacity(D, 4, 0)\n      SendMessage, 0x04E0, &N, &D, , % \"ahk_id \" . This.HWND\n      N := NumGet(N, 0, \"Int\"), D := NumGet(D, 0, \"Int\")\n      Return (N = 0) && (D = 0) ? 100 : Round(N / D * 100)\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetBkgndColor(Color) { ; Sets the background color.\n      ; Color : RGB integer value or HTML color name or\n      ;         \"Auto\" to reset to system default color.\n      ; Returns the prior background color.\n      ; EM_SETBKGNDCOLOR = 0x0443\n      If (Color = \"Auto\")\n         System := True, Color := 0\n      Else\n         System := False, Color := This.GetBGR(Color)\n      SendMessage, 0x0443, %System%, %Color%, , % \"ahk_id \" . This.HWND\n      Return This.GetRGB(ErrorLevel)\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetOptions(Options, Mode := \"SET\") { ; Sets the options for a rich edit control.\n      ; Options : Array of options as the keys defined in 'ECO'.\n      ; Mode    : Settings mode: SET, OR, AND, XOR\n      ; For details see http://msdn.microsoft.com/en-us/library/bb774254(v=vs.85).aspx.\n      ; EM_SETOPTIONS = 0x044D\n      Static ECO := {AUTOWORDSELECTION: 0x01, AUTOVSCROLL: 0x40, AUTOHSCROLL: 0x80, NOHIDESEL: 0x100, READONLY: 0x800\n                   , WANTRETURN: 0x1000, SAVESEL: 0x8000, SELECTIONBAR: 0x01000000, VERTICAL: 0x400000}\n           , ECOOP := {SET: 0x01, OR: 0x02, AND: 0x03, XOR: 0x04}\n      If !ECOOP.HasKey(Mode)\n         Return False\n      O := 0\n      For Each, Option In Options {\n         If ECO.HasKey(Option)\n            O |= ECO[Option]\n         Else\n            Return False\n      }\n      SendMessage, 0x044D, % ECOOP[Mode], %O%, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetStyles(Styles) { ; Sets the current edit style flags for a rich edit control.\n      ; Styles : Object containing on or more of the keys defined in 'SES'.\n      ;          If the value is 0 the style will be removed, otherwise it will be added.\n      ; For details see http://msdn.microsoft.com/en-us/library/bb774236(v=vs.85).aspx.\n      ; EM_SETEDITSTYLE\t= 0x04CC (WM_USER + 204)\n      Static SES = {EMULATESYSEDIT: 1, BEEPONMAXTEXT: 2, EXTENDBACKCOLOR: 4, NOXLTSYMBOLRANGE: 32, USEAIMM: 64\n                  , NOIME: 128, ALLOWBEEPS: 256, UPPERCASE: 512, LOWERCASE: 1024, NOINPUTSEQUENCECHK: 2048\n                  , BIDI: 4096, SCROLLONKILLFOCUS: 8192, XLTCRCRLFTOCR: 16384, DRAFTMODE: 32768\n                  , USECTF: 0x0010000, HIDEGRIDLINES: 0x0020000, USEATFONT: 0x0040000, CUSTOMLOOK: 0x0080000\n                  , LBSCROLLNOTIFY: 0x0100000, CTFALLOWEMBED: 0x0200000, CTFALLOWSMARTTAG: 0x0400000\n                  , CTFALLOWPROOFING: 0x0800000}\n      Flags := Mask := 0\n      For Style, Value In Styles {\n         If SES.HasKey(Style) {\n            Mask |= SES[Style]\n            If (Value <> 0)\n               Flags |= SES[Style]\n         }\n      }\n      If (Mask) {\n         SendMessage, 0x04CC, %Flags%, %Mask%, ,, % \"ahk_id \" . This.HWND\n         Return ErrorLevel\n      }\n      Return False\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetZoom(Ratio := \"\") { ; Sets the zoom ratio of a rich edit control.\n      ; Ratio : Float value between 100/64 and 6400; a ratio of 0 turns zooming off.\n      ; EM_SETZOOM = 0x4E1\n      SendMessage, 0x4E1, % (Ratio > 0 ? Ratio : 100), 100, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ; Copy, paste, etc.\n   ; -------------------------------------------------------------------------------------------------------------------\n   CanRedo() { ; Determines whether there are any actions in the control redo queue.\n      ; EM_CANREDO = 0x0455 (WM_USER + 85)\n      SendMessage, 0x0455, 0, 0, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   CanUndo() { ; Determines whether there are any actions in an edit control's undo queue.\n      ; EM_CANUNDO = 0x00C6\n      SendMessage, 0x00C6, 0, 0, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   Clear() {\n      ; WM_CLEAR = 0x303\n      SendMessage, 0x303, 0, 0, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   Copy() {\n      ; WM_COPY = 0x301\n      SendMessage, 0x301, 0, 0, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   Cut() {\n      ; WM_CUT = 0x300\n      SendMessage, 0x300, 0, 0, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   Paste() {\n      ; WM_PASTE = 0x302\n      SendMessage, 0x302, 0, 0, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   Redo() {\n      ; EM_REDO := 0x454\n      SendMessage, 0x454, 0, 0, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   Undo() {\n      ; EM_UNDO = 0xC7\n      SendMessage, 0xC7, 0, 0, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SelAll() {\n      ; Select all\n      Return This.SetSel(0, -1)\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   Deselect() {\n      ; Deselect all\n      Sel := This.GetSel()\n      Return This.SetSel(Sel.S, Sel.S)\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ; Font & colors\n   ; -------------------------------------------------------------------------------------------------------------------\n   ChangeFontSize(Diff) { ; Change font size\n      ; Diff : any positive or negative integer, positive values are treated as +1, negative as -1.\n      ; Returns new size.\n      ; EM_SETFONTSIZE = 0x04DF\n      ; Font size changes by 1 in the range 4 - 11 pt, by 2 for 12 - 28 pt, afterward to 36 pt, 48 pt, 72 pt, 80 pt,\n      ; and by 10 for > 80 pt. The maximum value is 160 pt, the minimum is 4 pt\n      Font := This.GetFont()\n      If (Diff > 0 && Font.Size < 160) || (Diff < 0 && Font.Size > 4)\n         SendMessage, 0x04DF, % (Diff > 0 ? 1 : -1), 0, , % \"ahk_id \" . This.HWND\n      Else\n         Return False\n      Font := This.GetFont()\n      Return Font.Size\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetFont(Default := False) { ; Get current font\n      ; Set Default to True to get the default font.\n      ; Returns an object containing current options (see SetFont())\n      ; EM_GETCHARFORMAT = 0x043A\n      ; BOLD_FONTTYPE = 0x0100, ITALIC_FONTTYPE = 0x0200\n      ; CFM_BOLD = 1, CFM_ITALIC = 2, CFM_UNDERLINE = 4, CFM_STRIKEOUT = 8, CFM_PROTECTED = 16, CFM_SUBSCRIPT = 0x30000\n      ; CFM_BACKCOLOR = 0x04000000, CFM_CHARSET := 0x08000000, CFM_FACE = 0x20000000, CFM_COLOR = 0x40000000\n      ; CFM_SIZE = 0x80000000\n      ; CFE_SUBSCRIPT = 0x10000, CFE_SUPERSCRIPT = 0x20000, CFE_AUTOBACKCOLOR = 0x04000000, CFE_AUTOCOLOR = 0x40000000\n      ; SCF_SELECTION = 1\n      Static Mask := 0xEC03001F\n      Static Effects := 0xEC000000\n      CF2 := New This.CF2\n      CF2.Mask := Mask\n      CF2.Effects := Effects\n      SendMessage, 0x043A, % (Default ? 0 : 1), % CF2.CF2, , % \"ahk_id \" . This.HWND\n      Font := {}\n      Font.Name := CF2.FaceName\n      Font.Size := CF2.Height / 20\n      CFS := CF2.Effects\n      Style := (CFS & 1 ? \"B\" : \"\") . (CFS & 2 ? \"I\" : \"\") . (CFS & 4 ? \"U\" : \"\") . (CFS & 8 ? \"S\" : \"\")\n             . (CFS & 0x10000 ? \"L\" : \"\") . (CFS & 0x20000 ? \"H\" : \"\") . (CFS & 16 ? \"P\" : \"\")\n      Font.Style := Style = \"\" ? \"N\" : Style\n      Font.Color := This.GetRGB(CF2.TextColor)\n      If (CF2.Effects & 0x04000000)\n         Font.BkColor := \"Auto\"\n      Else\n         Font.BkColor := This.GetRGB(CF2.BackColor)\n      Font.CharSet := CF2.CharSet\n      Return Font\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetDefaultFont(Font := \"\") { ; Set default font\n      ; Font : Optional object - see SetFont().\n      If IsObject(Font) {\n         For Key, Value In Font\n            If This.DefFont.HasKey(Key)\n               This.DefFont[Key] := Value\n      }\n      Return This.SetFont(This.DefFont)\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetFont(Font) { ; Set current/default font\n      ; Font : Object containing the following keys\n      ;        Name    : optional font name\n      ;        Size    : optional font size in points\n      ;        Style   : optional string of one or more of the following styles\n      ;                  B = bold, I = italic, U = underline, S = strikeout, L = subscript\n      ;                  H = superschript, P = protected, N = normal\n      ;        Color   : optional text color as RGB integer value or HTML color name\n      ;                  \"Auto\" for \"automatic\" (system's default) color\n      ;        BkColor : optional text background color (see Color)\n      ;                  \"Auto\" for \"automatic\" (system's default) background color\n      ;        CharSet : optional font character set\n      ;                  1 = DEFAULT_CHARSET, 2 = SYMBOL_CHARSET\n      ;        Empty parameters preserve the corresponding properties\n      ; EM_SETCHARFORMAT = 0x0444\n      ; SCF_DEFAULT = 0, SCF_SELECTION = 1\n      CF2 := New This.CF2\n      Mask := Effects := 0\n      If (Font.Name != \"\") {\n         Mask |= 0x20000000, Effects |= 0x20000000 ; CFM_FACE, CFE_FACE\n         CF2.FaceName := Font.Name\n      }\n      Size := Font.Size\n      If (Size != \"\") {\n         If (Size < 161)\n            Size *= 20\n         Mask |= 0x80000000, Effects |= 0x80000000 ; CFM_SIZE, CFE_SIZE\n         CF2.Height := Size\n      }\n      If (Font.Style != \"\") {\n         Mask |= 0x3001F           ; all font styles\n         If InStr(Font.Style, \"B\")\n            Effects |= 1           ; CFE_BOLD\n         If InStr(Font.Style, \"I\")\n            Effects |= 2           ; CFE_ITALIC\n         If InStr(Font.Style, \"U\")\n            Effects |= 4           ; CFE_UNDERLINE\n         If InStr(Font.Style, \"S\")\n            Effects |= 8           ; CFE_STRIKEOUT\n         If InStr(Font.Style, \"P\")\n            Effects |= 16          ; CFE_PROTECTED\n         If InStr(Font.Style, \"L\")\n            Effects |= 0x10000     ; CFE_SUBSCRIPT\n         If InStr(Font.Style, \"H\")\n            Effects |= 0x20000     ; CFE_SUPERSCRIPT\n      }\n      If (Font.Color != \"\") {\n         Mask |= 0x40000000        ; CFM_COLOR\n         If (Font.Color = \"Auto\")\n            Effects |= 0x40000000  ; CFE_AUTOCOLOR\n         Else\n            CF2.TextColor := This.GetBGR(Font.Color)\n      }\n      If (Font.BkColor != \"\") {\n         Mask |= 0x04000000        ; CFM_BACKCOLOR\n         If (Font.BkColor = \"Auto\")\n            Effects |= 0x04000000  ; CFE_AUTOBACKCOLOR\n         Else\n            CF2.BackColor := This.GetBGR(Font.BkColor)\n      }\n      If (Font.CharSet != \"\") {\n         Mask |= 0x08000000, Effects |= 0x08000000 ; CFM_CHARSET, CFE_CHARSET\n         CF2.CharSet := Font.CharSet = 2 ? 2 : 1 ; SYMBOL|DEFAULT\n      }\n      If (Mask != 0) {\n         Mode := Font.Default ? 0 : 1\n         CF2.Mask := Mask\n         CF2.Effects := Effects\n         SendMessage, 0x0444, %Mode%, % CF2.CF2, , % \"ahk_id \" . This.HWND\n         Return ErrorLevel\n      }\n      Return False\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ToggleFontStyle(Style) { ; Toggle single font style\n      ; Style : one of the following styles\n      ;         B = bold, I = italic, U = underline, S = strikeout, L = subscript, H = superschript, P = protected,\n      ;         N = normal (reset all other styles)\n      ; EM_GETCHARFORMAT = 0x043A, EM_SETCHARFORMAT = 0x0444\n      ; CFM_BOLD = 1, CFM_ITALIC = 2, CFM_UNDERLINE = 4, CFM_STRIKEOUT = 8, CFM_PROTECTED = 16, CFM_SUBSCRIPT = 0x30000\n      ; CFE_SUBSCRIPT = 0x10000, CFE_SUPERSCRIPT = 0x20000, SCF_SELECTION = 1\n      CF2 :=This.GetCharFormat()\n      CF2.Mask := 0x3001F ; FontStyles\n      If (Style = \"N\")\n         CF2.Effects := 0\n      Else\n         CF2.Effects ^= Style = \"B\" ? 1 : Style = \"I\" ? 2 : Style = \"U\" ? 4 : Style = \"S\" ? 8\n                      : Style = \"H\" ? 0x20000 : Style = \"L\" ? 0x10000 : 0\n      SendMessage, 0x0444, 1, % CF2.CF2, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ; Paragraph formatting\n   ; -------------------------------------------------------------------------------------------------------------------\n   AlignText(Align := 1) { ; Set paragraph's alignment\n      ; Note: Values greater 3 doesn't seem to work though they should as documented\n      ; Align: may contain one of the following numbers:\n      ;        PFA_LEFT             1\n      ;        PFA_RIGHT            2\n      ;        PFA_CENTER           3\n      ;        PFA_JUSTIFY          4 // New paragraph-alignment option 2.0 (*)\n      ;        PFA_FULL_INTERWORD   4 // These are supported in 3.0 with advanced\n      ;        PFA_FULL_INTERLETTER 5 // typography enabled\n      ;        PFA_FULL_SCALED      6\n      ;        PFA_FULL_GLYPHS      7\n      ;        PFA_SNAP_GRID        8\n      ; EM_SETPARAFORMAT = 0x0447, PFM_ALIGNMENT = 0x08\n      If (Align >= 1) && (ALign <= 8) {\n         PF2 := New This.PF2    ; PARAFORMAT2 struct\n         PF2.Mask := 0x08       ; dwMask\n         PF2.Alignment := Align ; wAlignment\n         SendMessage, 0x0447, 0, % PF2.PF2, , % \"ahk_id \" . This.HWND\n         Return True\n      }\n      Return False\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetBorder(Widths, Styles) { ; Set paragraph's borders\n      ; Borders are not displayed in RichEdit, so the call of this function has no visible result.\n      ; Even WordPad distributed with Win7 does not show them, but e.g. Word 2007 does.\n      ; Widths : Array of the 4 border widths in the range of 1 - 15 in order left, top, right, bottom; zero = no border\n      ; Styles : Array of the 4 border styles in the range of 0 - 7 in order left, top, right, bottom (see remarks)\n      ; Note:\n      ; The description on MSDN at http://msdn.microsoft.com/en-us/library/bb787942(v=vs.85).aspx is wrong!\n      ; To set borders you have to put the border width into the related nibble (4 Bits) of wBorderWidth\n      ; (in order: left (0 - 3), top (4 - 7), right (8 - 11), and bottom (12 - 15). The values are interpreted as\n      ; half points (i.e. 10 twips). Border styles are set in the related nibbles of wBorders.\n      ; Valid styles seem to be:\n      ;     0 : \\brdrdash (dashes)\n      ;     1 : \\brdrdashsm (small dashes)\n      ;     2 : \\brdrdb (double line)\n      ;     3 : \\brdrdot (dotted line)\n      ;     4 : \\brdrhair (single/hair line)\n      ;     5 : \\brdrs ? looks like 3\n      ;     6 : \\brdrth ? looks like 3\n      ;     7 : \\brdrtriple (triple line)\n      ; EM_SETPARAFORMAT = 0x0447, PFM_BORDER = 0x800\n      If !IsObject(Widths)\n         Return False\n      W := S := 0\n      For I, V In Widths {\n         If (V)\n            W |= V << ((A_Index - 1) * 4)\n         If Styles[I]\n            S |= Styles[I] << ((A_Index - 1) * 4)\n      }\n      PF2 := New This.PF2\n      PF2.Mask := 0x800\n      PF2.BorderWidth := W\n      PF2.Borders := S\n      SendMessage, 0x0447, 0, % PF2.PF2, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetLineSpacing(Lines) { ; Sets paragraph's line spacing.\n      ; Lines : number of lines as integer or float.\n      ; SpacingRule = 5:\n      ; The value of dyLineSpacing / 20 is the spacing, in lines, from one line to the next. Thus, setting\n      ; dyLineSpacing to 20 produces single-spaced text, 40 is double spaced, 60 is triple spaced, and so on.\n      ; EM_SETPARAFORMAT = 0x0447, PFM_LINESPACING = 0x100\n      PF2 := New This.PF2\n      PF2.Mask := 0x100\n      PF2.LineSpacing := Abs(Lines) * 20\n      PF2.LineSpacingRule := 5\n      SendMessage, 0x0447, 0, % PF2.PF2, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetParaIndent(Indent := \"Reset\") { ; Sets space left/right of the paragraph.\n      ; Indent : Object containing up to three keys:\n      ;          - Start  : Optional - Absolute indentation of the paragraph's first line.\n      ;          - Right  : Optional - Indentation of the right side of the paragraph, relative to the right margin.\n      ;          - Offset : Optional - Indentation of the second and subsequent lines, relative to the indentation\n      ;                                of the first line.\n      ;          Values are interpreted as centimeters/inches depending on the user's locale measurement settings.\n      ;          Call without passing a parameter to reset indentation.\n      ; EM_SETPARAFORMAT = 0x0447\n      ; PFM_STARTINDENT  = 0x0001\n      ; PFM_RIGHTINDENT  = 0x0002\n      ; PFM_OFFSET       = 0x0004\n      Static PFM := {STARTINDENT: 0x01, RIGHTINDENT: 0x02, OFFSET: 0x04}\n      Measurement := This.GetMeasurement()\n      PF2 := New This.PF2\n      If (Indent = \"Reset\")\n         PF2.Mask := 0x07 ; reset indentation\n      Else If !IsObject(Indent)\n         Return False\n      Else {\n         PF2.Mask := 0\n         If (Indent.HasKey(\"Start\")) {\n            PF2.Mask |= PFM.STARTINDENT\n            PF2.StartIndent := Round((Indent.Start / Measurement) * 1440)\n         }\n         If (Indent.HasKey(\"Offset\")) {\n            PF2.Mask |= PFM.OFFSET\n            PF2.Offset := Round((Indent.Offset / Measurement) * 1440)\n         }\n         If (Indent.HasKey(\"Right\")) {\n            PF2.Mask |= PFM.RIGHTINDENT\n            PF2.RightIndent := Round((Indent.Right / Measurement) * 1440)\n         }\n      }\n      If (PF2.Mask) {\n         SendMessage, 0x0447, 0, % PF2.PF2, , % \"ahk_id \" . This.HWND\n         Return ErrorLevel\n      }\n      Return False\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetParaNumbering(Numbering := \"Reset\") {\n      ; Numbering : Object containing up to four keys:\n      ;             - Type  : Options used for bulleted or numbered paragraphs.\n      ;             - Style : Optional - Numbering style used with numbered paragraphs.\n      ;             - Tab   : Optional - Minimum space between a paragraph number and the paragraph text.\n      ;             - Start : Optional - Sequence number used for numbered paragraphs (e.g. 3 for C or III)\n      ;             Tab is interpreted as centimeters/inches depending on the user's locale measurement settings.\n      ;             Call without passing a parameter to reset numbering.\n      ; EM_SETPARAFORMAT = 0x0447\n      ; PARAFORMAT numbering options\n      ; PFN_BULLET   1 ; tomListBullet\n      ; PFN_ARABIC   2 ; tomListNumberAsArabic:   0, 1, 2,\t...\n      ; PFN_LCLETTER 3 ; tomListNumberAsLCLetter: a, b, c,\t...\n      ; PFN_UCLETTER 4 ; tomListNumberAsUCLetter: A, B, C,\t...\n      ; PFN_LCROMAN  5 ; tomListNumberAsLCRoman:  i, ii, iii,\t...\n      ; PFN_UCROMAN  6 ; tomListNumberAsUCRoman:  I, II, III,\t...\n      ; PARAFORMAT2 wNumberingStyle options\n      ; PFNS_PAREN     0x0000 ; default, e.g.,                 1)\n      ; PFNS_PARENS    0x0100 ; tomListParentheses/256, e.g., (1)\n      ; PFNS_PERIOD    0x0200 ; tomListPeriod/256, e.g.,       1.\n      ; PFNS_PLAIN     0x0300 ; tomListPlain/256, e.g.,        1\n      ; PFNS_NONUMBER  0x0400 ; used for continuation w/o number\n      ; PFNS_NEWNUMBER 0x8000 ; start new number with wNumberingStart\n      ; PFM_NUMBERING      0x0020\n      ; PFM_NUMBERINGSTYLE 0x2000\n      ; PFM_NUMBERINGTAB   0x4000\n      ; PFM_NUMBERINGSTART 0x8000\n      Static PFM := {Type: 0x0020, Style: 0x2000, Tab: 0x4000, Start: 0x8000}\n      Static PFN := {Bullet: 1, Arabic: 2, LCLetter: 3, UCLetter: 4, LCRoman: 5, UCRoman: 6}\n      Static PFNS := {Paren: 0x0000, Parens: 0x0100, Period: 0x0200, Plain: 0x0300, None: 0x0400, New: 0x8000}\n      PF2 := New This.PF2\n      If (Numbering = \"Reset\")\n         PF2.Mask := 0xE020\n      Else If !IsObject(Numbering)\n         Return False\n      Else {\n         If (Numbering.HasKey(\"Type\")) {\n            PF2.Mask |= PFM.Type\n            PF2.Numbering := PFN[Numbering.Type]\n         }\n         If (Numbering.HasKey(\"Style\")) {\n            PF2.Mask |= PFM.Style\n            PF2.NumberingStyle := PFNS[Numbering.Style]\n         }\n         If (Numbering.HasKey(\"Tab\")) {\n            PF2.Mask |= PFM.Tab\n            PF2.NumberingTab := Round((Numbering.Tab / This.GetMeasurement()) * 1440)\n         }\n         If (Numbering.HasKey(\"Start\")) {\n            PF2.Mask |= PFM.Start\n            PF2.NumberingStart := Numbering.Start\n         }\n      }\n      If (PF2.Mask) {\n         SendMessage, 0x0447, 0, % PF2.PF2, , % \"ahk_id \" . This.HWND\n         Return ErrorLevel\n      }\n      Return False\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetParaSpacing(Spacing := \"Reset\") { ; Set space before / after the paragraph\n      ; Spacing : Object containing one or two keys:\n      ;           - Before : additional space before the paragraph in points\n      ;           - After  : additional space after the paragraph in points\n      ;           Call without passing a parameter to reset spacing to zero.\n      ; EM_SETPARAFORMAT = 0x0447\n      ; PFM_SPACEBEFORE  = 0x0040\n      ; PFM_SPACEAFTER   = 0x0080\n      Static PFM := {Before: 0x40, After: 0x80}\n      PF2 := New This.PF2\n      If (Spacing = \"Reset\")\n         PF2.Mask := 0xC0 ; reset spacing\n      Else If !IsObject(Spacing)\n         Return False\n      Else {\n         If (Spacing.Before >= 0) {\n            PF2.Mask |= PFM.Before\n            PF2.SpaceBefore := Round(Spacing.Before * 20)\n         }\n         If (Spacing.After >= 0) {\n            PF2.Mask |= PFM.After\n            PF2.SpaceAfter := Round(Spacing.After * 20)\n         }\n      }\n      If (PF2.Mask) {\n         SendMessage, 0x0447, 0, % PF2.PF2, , % \"ahk_id \" . This.HWND\n         Return ErrorLevel\n      }\n      Return False\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetDefaultTabs(Distance) { ; Set default tabstops\n      ; Distance will be interpreted as inches or centimeters depending on the current user's locale.\n      ; EM_SETTABSTOPS = 0xCB\n      Static DUI := 64      ; dialog units per inch\n           , MinTab := 0.20 ; minimal tab distance\n           , MaxTab := 3.00 ; maximal tab distance\n      IM := This.GetMeasurement()\n      StringReplace, Distance, Distance, `,, .\n      Distance := Round(Distance / IM, 2)\n      If (Distance < MinTab)\n         Distance := MinTab\n      If (Distance > MaxTab)\n         Distance := MaxTab\n      VarSetCapacity(TabStops, 4, 0)\n      NumPut(Round(DUI * Distance), TabStops, \"Int\")\n      SendMessage, 0xCB, 1, &TabStops, , % \"ahk_id \" . This.HWND\n      Result := ErrorLevel\n      DllCall(\"User32.dll\\UpdateWindow\", \"Ptr\", This.HWND)\n      Return Result\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SetTabStops(TabStops := \"Reset\") { ; Set paragraph's tabstobs\n      ; TabStops is an object containing the integer position as hundredth of inches/centimeters as keys\n      ; and the alignment (\"L\", \"C\", \"R\", or \"D\") as values.\n      ; The position will be interpreted as hundredth of inches or centimeters depending on the current user's locale.\n      ; Call without passing a  parameter to reset to default tabs.\n      ; EM_SETPARAFORMAT = 0x0447, PFM_TABSTOPS = 0x10\n      Static MinT := 30                ; minimal tabstop in hundredth of inches\n      Static MaxT := 830               ; maximal tabstop in hundredth of inches\n      Static Align := {L: 0x00000000   ; left aligned (default)\n                     , C: 0x01000000   ; centered\n                     , R: 0x02000000   ; right aligned\n                     , D: 0x03000000}  ; decimal tabstop\n      Static MAX_TAB_STOPS := 32\n      IC := This.GetMeasurement()\n      PF2 := New This.PF2\n      PF2.Mask := 0x10\n      If (TabStops = \"Reset\") {\n         SendMessage, 0x0447, 0, % PF2.PF2, , % \"ahk_id \" . This.HWND\n         Return !!(ErrorLevel)\n      }\n      If !IsObject(TabStops)\n         Return False\n      TabCount := 0\n      Tabs  := []\n      For Position, Alignment In TabStops {\n         Position /= IC\n         If (Position < MinT) Or (Position > MaxT)\n         Or !Align.HasKey(Alignment) Or (A_Index > MAX_TAB_STOPS)\n            Return False\n         Tabs[A_Index] := (Align[Alignment] | Round((Position / 100) * 1440))\n         TabCount := A_Index\n      }\n      If (TabCount) {\n         PF2.TabCount := TabCount\n         PF2.Tabs := Tabs\n         SendMessage, 0x0447, 0, % PF2.PF2, , % \"ahk_id \" . This.HWND\n         Return ErrorLevel\n      }\n      Return False\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ; Line handling\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetLineCount() { ; Get the total number of lines\n\n      ; EM_GETLINECOUNT = 0xBA\n      SendMessage, 0xBA, 0, 0, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetCaretLine() { ; Get the line containing the caret\n      ; EM_LINEINDEX = 0xBB, EM_EXLINEFROMCHAR = 0x0436\n      SendMessage, 0xBB, -1, 0, , % \"ahk_id \" . This.HWND\n      SendMessage, 0x0436, 0, %ErrorLevel%, , % \"ahk_id \" . This.HWND\n      Return ErrorLevel + 1\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ; Statistics\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetStatistics() { ; Get some statistic values\n      ; Get the line containing the caret, it's position in this line, the total amount of lines, the absulute caret\n      ; position and the total amount of characters.\n      ; EM_GETSEL = 0xB0, EM_LINEFROMCHAR = 0xC9, EM_LINEINDEX = 0xBB, EM_GETLINECOUNT = 0xBA\n      Stats := {}\n      VarSetCapacity(GTL, 8, 0)  ; GETTEXTLENGTHEX structure\n      SB := 0\n      SendMessage, 0xB0, &SB, 0, , % \"ahk_id \" . This.HWND\n      SB := NumGet(SB, 0, \"UInt\") + 1\n      SendMessage, 0xBB, -1, 0, , % \"ahk_id \" . This.HWND\n      Stats.LinePos := SB - ErrorLevel\n      SendMessage, 0xC9, -1, 0, , % \"ahk_id \" . This.HWND\n      Stats.Line := ErrorLevel + 1\n      SendMessage, 0xBA, 0, 0, , % \"ahk_id \" . This.HWND\n      Stats.LineCount := ErrorLevel\n      Stats.CharCount := This.GetTextLen()\n      Return Stats\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ; Layout\n   ; -------------------------------------------------------------------------------------------------------------------\n   WordWrap(On) { ; Turn wordwrapping on/off\n      ; EM_SCROLLCARET = 0xB7, EM_SETTARGETDEVICE = 0x0448\n      Sel := This.GetSel()\n      SendMessage, 0x0448, 0, % (On ? 0 : -1), , % \"ahk_id \" . This.HWND\n      This.SetSel(Sel.S, Sel.E)\n      SendMessage, 0xB7, 0, 0,  % \"ahk_id \" . This.HWND\n      Return On\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   WYSIWYG(On) { ; Show control as printed (WYSIWYG)\n      ; Text measuring is based on the default printer's capacities, thus changing the printer may produce different\n      ; results. See remarks/comments in Print() also.\n      ; EM_SCROLLCARET = 0xB7, EM_SETTARGETDEVICE = 0x0448\n      ; PD_RETURNDC = 0x0100, PD_RETURNDEFAULT = 0x0400\n      Static PDC := 0\n      Static PD_Size := (A_PtrSize = 4 ? 66 : 120)\n      Static OffFlags := A_PtrSize * 5\n      Sel := This.GetSel()\n      If !(On) {\n         DllCall(\"User32.dll\\LockWindowUpdate\", \"Ptr\", This.HWND)\n         DllCall(\"Gdi32.dll\\DeleteDC\", \"Ptr\", PDC)\n         SendMessage, 0x0448, 0, -1, , % \"ahk_id \" . This.HWND\n         This.SetSel(Sel.S, Sel.E)\n         SendMessage, 0xB7, 0, 0,  % \"ahk_id \" . This.HWND\n         DllCall(\"User32.dll\\LockWindowUpdate\", \"Ptr\", 0)\n         Return ErrorLevel\n      }\n      Numput(VarSetCapacity(PD, PD_Size, 0), PD)\n      NumPut(0x0100 | 0x0400, PD, A_PtrSize * 5, \"UInt\") ; PD_RETURNDC | PD_RETURNDEFAULT\n      If !DllCall(\"Comdlg32.dll\\PrintDlg\", \"Ptr\", &PD, \"Int\")\n         Return\n      DllCall(\"Kernel32.dll\\GlobalFree\", \"Ptr\", NumGet(PD, A_PtrSize * 2, \"UPtr\"))\n      DllCall(\"Kernel32.dll\\GlobalFree\", \"Ptr\", NumGet(PD, A_PtrSize * 3, \"UPtr\"))\n      PDC := NumGet(PD, A_PtrSize * 4, \"UPtr\")\n      DllCall(\"User32.dll\\LockWindowUpdate\", \"Ptr\", This.HWND)\n      Caps := This.GetPrinterCaps(PDC)\n      ; Set up page size and margins in pixel\n      UML := This.Margins.LT                   ; user margin left\n      UMR := This.Margins.RT                   ; user margin right\n      PML := Caps.POFX                         ; physical margin left\n      PMR := Caps.PHYW - Caps.HRES - Caps.POFX ; physical margin right\n      LPW := Caps.HRES                         ; logical page width\n      ; Adjust margins\n      UML := UML > PML ? (UML - PML) : 0\n      UMR := UMR > PMR ? (UMR - PMR) : 0\n      LineLen := LPW - UML - UMR\n      SendMessage, 0x0448, %PDC%, %LineLen%, , % \"ahk_id \" . This.HWND\n      This.SetSel(Sel.S, Sel.E)\n      SendMessage, 0xB7, 0, 0,  % \"ahk_id \" . This.HWND\n      DllCall(\"User32.dll\\LockWindowUpdate\", \"Ptr\", 0)\n      Return ErrorLevel\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ; File handling\n   ; -------------------------------------------------------------------------------------------------------------------\n   LoadFile(File, Mode = \"Open\") { ; Load file\n      ; File : file name\n      ; Mode : Open / Add / Insert\n      ;        Open   : Replace control's content\n      ;        Append : Append to conrol's content\n      ;        Insert : Insert at / replace current selection\n      If !FileExist(File)\n         Return False\n      SplitPath, File, , , Ext\n      If (Ext = \"rtf\") {\n         If (Mode = \"Open\") {\n            Selection := False\n         } Else If (Mode = \"Insert\") {\n            Selection := True\n         } Else If (Mode = \"Append\") {\n            This.SetSel(-1, -2)\n            Selection := True\n         }\n         This.LoadRTF(File, Selection)\n      } Else {\n         FileRead, Text, %File%\n         If (Mode = \"Open\") {\n            This.SetText(Text)\n         } Else If (Mode = \"Insert\") {\n            This.ReplaceSel(Text)\n         } Else If (Mode = \"Append\") {\n            This.SetSel(-1, -2)\n            This.ReplaceSel(Text)\n         }\n      }\n      Return True\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   SaveFile(File) { ; Save file\n      ; File : file name\n      ; Returns True on success, otherwise False.\n      GuiName := This.GuiName\n      Gui, %GuiName%:+OwnDialogs\n      SplitPath, File, , , Ext\n      Text := Ext = \"rtf\" ? This.GetRTF() : This.GetText()\n      If IsObject(FileObj := FileOpen(File, \"w\")) {\n         FileObj.Write(Text)\n         FileObj.Close()\n         Return True\n      }\n      Return False\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   ; Printing\n   ; THX jballi ->  http://www.autohotkey.com/board/topic/45513-function-he-print-wysiwyg-print-for-the-hiedit-control/\n   ; -------------------------------------------------------------------------------------------------------------------\n   Print() {\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Static variables\n      Static PD_ALLPAGES := 0x00, PD_SELECTION := 0x01, PD_PAGENUMS := 0x02, PD_NOSELECTION := 0x04\n           , PD_RETURNDC := 0x0100, PD_USEDEVMODECOPIES := 0x040000, PD_HIDEPRINTTOFILE := 0x100000\n           , PD_NONETWORKBUTTON := 0x200000, PD_NOCURRENTPAGE := 0x800000\n           , MM_TEXT := 0x1\n           , EM_FORMATRANGE := 0x0439, EM_SETTARGETDEVICE := 0x0448\n           , DocName := \"AHKRichEdit\"\n           , PD_Size := (A_PtrSize = 8 ? (13 * A_PtrSize) + 16 : 66)\n      ErrorMsg := \"\"\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Prepare to call PrintDlg\n      ; Define/Populate the PRINTDLG structure\n      VarSetCapacity(PD, PD_Size, 0)\n      Numput(PD_Size, PD, 0, \"UInt\")  ; lStructSize\n      Numput(This.GuiHwnd, PD, A_PtrSize, \"UPtr\") ; hwndOwner\n      ; Collect Start/End select positions\n      Sel := This.GetSel()\n      ; Determine/Set Flags\n      Flags := PD_ALLPAGES | PD_RETURNDC | PD_USEDEVMODECOPIES | PD_HIDEPRINTTOFILE | PD_NONETWORKBUTTON\n             | PD_NOCURRENTPAGE\n      If (Sel.S = Sel.E)\n         Flags |= PD_NOSELECTION\n      Else\n         Flags |= PD_SELECTION\n      Offset := A_PtrSize * 5\n      NumPut(Flags, PD, Offset, \"UInt\")       ; Flags\n      ; Page and copies\n      NumPut( 1, PD, Offset += 4, \"UShort\")   ; nFromPage\n      NumPut( 1, PD, Offset += 2, \"UShort\")   ; nToPage\n      NumPut( 1, PD, Offset += 2, \"UShort\")   ; nMinPage\n      NumPut(-1, PD, Offset += 2, \"UShort\")   ; nMaxPage\n      NumPut( 1, PD, Offset += 2, \"UShort\")   ; nCopies\n      ; Note: Use -1 to specify the maximum page number (65535).\n      ; Programming note: The values that are loaded to these fields are critical. The Print dialog will not\n      ; display (returns an error) if unexpected values are loaded to one or more of these fields.\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Print dialog box\n      ; Open the Print dialog.  Bounce If the user cancels.\n      If !DllCall(\"Comdlg32.dll\\PrintDlg\", \"Ptr\", &PD, \"UInt\") {\n         ErrorLevel := \"Function: \" . A_ThisFunc . \" - DLLCall of 'PrintDlg' failed.\"\n         Return False\n      }\n      ; Get the printer device context.  Bounce If not defined.\n      If !(PDC := NumGet(PD, A_PtrSize * 4, \"UPtr\")) { ; hDC\n         ErrorLevel := \"Function: \" . A_ThisFunc . \" - Couldn't get a printer's device context.\"\n         Return False\n      }\n      ; Free global structures created by PrintDlg\n      DllCall(\"Kernel32.dll\\GlobalFree\", \"Ptr\", NumGet(PD, A_PtrSize * 2, \"UPtr\"))\n      DllCall(\"Kernel32.dll\\GlobalFree\", \"Ptr\", NumGet(PD, A_PtrSize * 3, \"UPtr\"))\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Prepare to print\n      ; Collect Flags\n      Offset := A_PtrSize * 5\n      Flags := NumGet(PD, OffSet, \"UInt\")           ; Flags\n      ; Determine From/To Page\n      If (Flags & PD_PAGENUMS) {\n         PageF := NumGet(PD, Offset += 4, \"UShort\") ; nFromPage (first page)\n         PageL := NumGet(PD, Offset += 2, \"UShort\") ; nToPage (last page)\n      } Else {\n         PageF := 1\n         PageL := 65535\n      }\n      ; Collect printer capacities\n      Caps := This.GetPrinterCaps(PDC)\n      ; Set up page size and margins in Twips (1/20 point or 1/1440 of an inch)\n      UML := This.Margins.LT                   ; user margin left\n      UMT := This.Margins.TT                   ; user margin top\n      UMR := This.Margins.RT                   ; user margin right\n      UMB := This.Margins.BT                   ; user margin bottom\n      PML := Caps.POFX                         ; physical margin left\n      PMT := Caps.POFY                         ; physical margin top\n      PMR := Caps.PHYW - Caps.HRES - Caps.POFX ; physical margin right\n      PMB := Caps.PHYH - Caps.VRES - Caps.POFY ; physical margin bottom\n      LPW := Caps.HRES                         ; logical page width\n      LPH := Caps.VRES                         ; logical page height\n      ; Adjust margins\n      UML := UML > PML ? (UML - PML) : 0\n      UMT := UMT > PMT ? (UMT - PMT) : 0\n      UMR := UMR > PMR ? (UMR - PMR) : 0\n      UMB := UMB > PMB ? (UMB - PMB) : 0\n      ; Define/Populate the FORMATRANGE structure\n      VarSetCapacity(FR, (A_PtrSize * 2) + (4 * 10), 0)\n      NumPut(PDC, FR, 0, \"UPtr\")         ; hdc\n      NumPut(PDC, FR, A_PtrSize, \"UPtr\") ; hdcTarget\n      ; Define FORMATRANGE.rc\n      ; rc is the area to render to (rcPage - margins), measured in twips (1/20 point or 1/1440 of an inch).\n      ; If the user-defined margins are smaller than the printer's margins (the unprintable areas at the edges of each\n      ; page), the user margins are set to the printer's margins. In addition, the user-defined margins must be adjusted\n      ; to account for the printer's margins.\n      ; For example: If the user requests a 3/4 inch (19.05 mm) left margin but the printer's left margin is 1/4 inch\n      ; (6.35 mm), rc.Left is set to 720 twips (1/2 inch or 12.7 mm).\n      Offset := A_PtrSize * 2\n      NumPut(UML, FR, Offset += 0, \"Int\")       ; rc.Left\n      NumPut(UMT, FR, Offset += 4, \"Int\")       ; rc.Top\n      NumPut(LPW - UMR, FR, Offset += 4, \"Int\") ; rc.Right\n      NumPut(LPH - UMB, FR, Offset += 4, \"Int\") ; rc.Bottom\n      ; Define FORMATRANGE.rcPage\n      ; rcPage is the entire area of a page on the rendering device, measured in twips (1/20 point or 1/1440 of an inch)\n      ; Note: rc defines the maximum printable area which does not include the printer's margins (the unprintable areas\n      ; at the edges of the page). The unprintable areas are represented by PHYSICALOFFSETX and PHYSICALOFFSETY.\n      NumPut(0, FR, Offset += 4, \"Int\")         ; rcPage.Left\n      NumPut(0, FR, Offset += 4, \"Int\")         ; rcPage.Top\n      NumPut(LPW, FR, Offset += 4, \"Int\")       ; rcPage.Right\n      NumPut(LPH, FR, Offset += 4, \"Int\")       ; rcPage.Bottom\n      ; Determine print range.\n      ; If \"Selection\" option is chosen, use selected text, otherwise use the entire document.\n      If (Flags & PD_SELECTION) {\n         PrintS := Sel.S\n         PrintE := Sel.E\n      } Else {\n         PrintS := 0\n         PrintE := -1            ; (-1 = Select All)\n      }\n      Numput(PrintS, FR, Offset += 4, \"Int\")    ; cr.cpMin\n      NumPut(PrintE, FR, Offset += 4, \"Int\")    ; cr.cpMax\n      ; Define/Populate the DOCINFO structure\n      VarSetCapacity(DI, A_PtrSize * 5, 0)\n      NumPut(A_PtrSize * 5, DI, 0, \"UInt\")\n      NumPut(&DocName, DI, A_PtrSize, \"UPtr\")     ; lpszDocName\n      NumPut(0       , DI, A_PtrSize * 2, \"UPtr\") ; lpszOutput\n      ; Programming note: All other DOCINFO fields intentionally left as null.\n      ; Determine MaxPrintIndex\n      If (Flags & PD_SELECTION) {\n          PrintM := Sel.E\n      } Else {\n          PrintM := This.GetTextLen()\n      }\n      ; Be sure that the printer device context is in text mode\n      DllCall(\"Gdi32.dll\\SetMapMode\", \"Ptr\", PDC, \"Int\", MM_TEXT)\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; Print it!\n      ; Start a print job.  Bounce If there is a problem.\n      PrintJob := DllCall(\"Gdi32.dll\\StartDoc\", \"Ptr\", PDC, \"Ptr\", &DI, \"Int\")\n      If (PrintJob <= 0) {\n         ErrorLevel := \"Function: \" . A_ThisFunc . \" - DLLCall of 'StartDoc' failed.\"\n         Return False\n      }\n      ; Print page loop\n      PageC  := 0 ; current page\n      PrintC := 0 ; current print index\n      While (PrintC < PrintM) {\n         PageC++\n         ; Are we done yet?\n         If (PageC > PageL)\n            Break\n         If (PageC >= PageF) && (PageC <= PageL) {\n            ; StartPage function.  Break If there is a problem.\n            If (DllCall(\"Gdi32.dll\\StartPage\", \"Ptr\", PDC, \"Int\") <= 0) {\n               ErrorMsg := \"Function: \" . A_ThisFunc . \" - DLLCall of 'StartPage' failed.\"\n               Break\n            }\n         }\n         ; Format or measure page\n         If (PageC >= PageF) && (PageC <= PageL)\n            Render := True\n         Else\n            Render := False\n         SendMessage, %EM_FORMATRANGE%, %Render%, &FR, , % \"ahk_id \" . This.HWND\n         PrintC := ErrorLevel\n         If (PageC >= PageF) && (PageC <= PageL) {\n            ; EndPage function. Break If there is a problem.\n            If (DllCall(\"Gdi32.dll\\EndPage\", \"Ptr\", PDC, \"Int\") <= 0) {\n               ErrorMsg := \"Function: \" . A_ThisFunc . \" - DLLCall of 'EndPage' failed.\"\n               Break\n            }\n         }\n         ; Update FR for the next page\n         Offset := (A_PtrSize * 2) + (4 * 8)\n         Numput(PrintC, FR, Offset += 0, \"Int\") ; cr.cpMin\n         NumPut(PrintE, FR, Offset += 4, \"Int\") ; cr.cpMax\n      }\n      ; ----------------------------------------------------------------------------------------------------------------\n      ; End the print job\n      DllCall(\"Gdi32.dll\\EndDoc\", \"Ptr\", PDC)\n      ; Delete the printer device context\n      DllCall(\"Gdi32.dll\\DeleteDC\", \"Ptr\", PDC)\n      ; Reset control (free cached information)\n      SendMessage %EM_FORMATRANGE%, 0, 0, , % \"ahk_id \" . This.HWND\n      ; Return to sender\n      If (ErrorMsg) {\n         ErrorLevel := ErrorMsg\n         Return False\n      }\n      Return True\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetMargins() { ; Get the default print margins\n      Static PSD_RETURNDEFAULT := 0x00000400, PSD_INTHOUSANDTHSOFINCHES := 0x00000004\n           , I := 1000 ; thousandth of inches\n           , M := 2540 ; hundredth of millimeters\n           , PSD_Size := (4 * 10) + (A_PtrSize * 11)\n           , PD_Size := (A_PtrSize = 8 ? (13 * A_PtrSize) + 16 : 66)\n           , OffFlags := 4 * A_PtrSize\n           , OffMargins := OffFlags + (4 * 7)\n      If !This.HasKey(\"Margins\") {\n         VarSetCapacity(PSD, PSD_Size, 0) ; PAGESETUPDLG structure\n         NumPut(PSD_Size, PSD, 0, \"UInt\")\n         NumPut(PSD_RETURNDEFAULT, PSD, OffFlags, \"UInt\")\n         If !DllCall(\"Comdlg32.dll\\PageSetupDlg\", \"Ptr\", &PSD, \"UInt\")\n            Return false\n         DllCall(\"Kernel32.dll\\GobalFree\", UInt, NumGet(PSD, 2 * A_PtrSize, \"UPtr\"))\n         DllCall(\"Kernel32.dll\\GobalFree\", UInt, NumGet(PSD, 3 * A_PtrSize, \"UPtr\"))\n         Flags := NumGet(PSD, OffFlags, \"UInt\")\n         Metrics := (Flags & PSD_INTHOUSANDTHSOFINCHES) ? I : M\n         Offset := OffMargins\n         This.Margins := {}\n         This.Margins.L := NumGet(PSD, Offset += 0, \"Int\")           ; Left\n         This.Margins.T := NumGet(PSD, Offset += 4, \"Int\")           ; Top\n         This.Margins.R := NumGet(PSD, Offset += 4, \"Int\")           ; Right\n         This.Margins.B := NumGet(PSD, Offset += 4, \"Int\")           ; Bottom\n         This.Margins.LT := Round((This.Margins.L / Metrics) * 1440) ; Left in twips\n         This.Margins.TT := Round((This.Margins.T / Metrics) * 1440) ; Top in twips\n         This.Margins.RT := Round((This.Margins.R / Metrics) * 1440) ; Right in twips\n         This.Margins.BT := Round((This.Margins.B / Metrics) * 1440) ; Bottom in twips\n      }\n      Return True\n   }\n   ; -------------------------------------------------------------------------------------------------------------------\n   GetPrinterCaps(DC) { ; Get printer's capacities\n      Static HORZRES         := 0x08, VERTRES         := 0x0A\n           , LOGPIXELSX      := 0x58, LOGPIXELSY      := 0x5A\n           , PHYSICALWIDTH   := 0x6E, PHYSICALHEIGHT  := 0x6F\n           , PHYSICALOFFSETX := 0x70, PHYSICALOFFSETY := 0x71\n           , Caps := {}\n      ; Number of pixels per logical inch along the page width and height\n      LPXX := DllCall(\"Gdi32.dll\\GetDeviceCaps\", \"Ptr\", DC, \"Int\", LOGPIXELSX, \"Int\")\n      LPXY := DllCall(\"Gdi32.dll\\GetDeviceCaps\", \"Ptr\", DC, \"Int\", LOGPIXELSY, \"Int\")\n      ; The width and height of the physical page, in twips.\n      Caps.PHYW := Round((DllCall(\"Gdi32.dll\\GetDeviceCaps\", \"Ptr\", DC, \"Int\", PHYSICALWIDTH, \"Int\") / LPXX) * 1440)\n      Caps.PHYH := Round((DllCall(\"Gdi32.dll\\GetDeviceCaps\", \"Ptr\", DC, \"Int\", PHYSICALHEIGHT, \"Int\") / LPXY) * 1440)\n      ; The distance from the left/right edge (PHYSICALOFFSETX) and the top/bottom edge (PHYSICALOFFSETY) of the\n      ; physical page to the edge of the printable area, in twips.\n      Caps.POFX := Round((DllCall(\"Gdi32.dll\\GetDeviceCaps\", \"Ptr\", DC, \"Int\", PHYSICALOFFSETX, \"Int\") / LPXX) * 1440)\n      Caps.POFY := Round((DllCall(\"Gdi32.dll\\GetDeviceCaps\", \"Ptr\", DC, \"Int\", PHYSICALOFFSETY, \"Int\") / LPXY) * 1440)\n      ; Width and height of the printable area of the page, in twips.\n      Caps.HRES := Round((DllCall(\"Gdi32.dll\\GetDeviceCaps\", \"Ptr\", DC, \"Int\", HORZRES, \"Int\") / LPXX) * 1440)\n      Caps.VRES := Round((DllCall(\"Gdi32.dll\\GetDeviceCaps\", \"Ptr\", DC, \"Int\", VERTRES, \"Int\") / LPXY) * 1440)\n      Return Caps\n   }\n}\n"
  },
  {
    "path": "Lib/Language.ahk",
    "content": "﻿;////////////////////////////////////////////////////////////////////////////////////////////////////\n/*\n    GUI Interface Keys-Words {English}\n*/\n;////////////////////////////////////////////////////////////////////////////////////////////////////\n_1      :=      \"CASH MANAGER\"\n_2      :=      \"CONTINUE\"\n_3      :=      \"QUIT\"\n_4      :=      \"CASH REGISTER\"\n_5      :=      \"DEFINE\"\n_6      :=      \"STOCKPILE\"\n_7      :=      \"PROFITS\"\n_8      :=      \"ENSURE DOT\"\n_9      :=      \"SUBMIT\"\n_10     :=      \"CAN'T DOWNLOAD THE UPDATE PACKAGE!\"\n_11     :=      \"CAN'T EXTRACT FILES INSIDE THE UPDATE PACKAGE!\"\n_12     :=      \"CAN'T UPDATE THE PROGRAM FILES!\"\n_13     :=      \"ERROR\"\n_14     :=      \"COMMANDLINE CALL\"\n_16     :=      \"UPDATE\"\n_17     :=      \"A NEW UPDATE IS AVAILABLE NOW!\"\n_18     :=      \"DOWNLOAD AND INSTALL NOW?\"\n_19     :=      \"SELL OPERATION WAS DONE AT\"\n_20     :=      \"NEW VERSION\"\n_21     :=      \"DO YOU WISH TO DOWNLOAD THE NEW VERSION\"\n_22     :=      \"STARTING...\"\n_23     :=      \"CHECKING FOR UPDATES...\"\n_24     :=      \"WAIT FOR THE USER DESCISION...\"\n_25     :=      \"WORKING ON IT..\"\n_26     :=      \"DOWNLOADING...\"\n_27     :=      \"BARCODE\"\n_28     :=      \"MANAGEMENT\"\n_29     :=      \"KRIDI\"\n_30     :=      \"SET THIS DEFINITION\"\n_31     :=      \"CHECK FOR UPDATES AT APP STARTING\"\n_32     :=      \"REMEMBER MY INPUTS\"\n_33     :=      \"1`N2`N3`N4`N5\"\n_34     :=      \"SAVE IT AS KRIDI\"\n_35     :=      \"LOGIN\"\n_36     :=      \"OK\"\n_37     :=      \"ITEMS\"\n_38     :=      \"NAME\"\n_39     :=      \"SELL PRICE\"\n_40     :=      \"BUY PRICE\"\n_41     :=      \"PROFIT MADE\"\n_42     :=      \"OVERALL PROFIT\"\n_43     :=      \"FIX THE TOOLTIP GUI\"\n_44     :=      \"CHECK FOR UPDATES\"\n_45     :=      \"NO NEW UPDATES!\"\n_46     :=      \"NOW DOWNLOADING...\"\n_47     :=      \"DOWNLOAD PROGRESS\"\n_48     :=      \"COULD NOT CREATE THE JSON CONFIGURATION KEY!\"\n_49     :=      \"COULD NOT GET CURRENT AVAILABLE VERSION FROM THE DATABASE!\"\n_50     :=      \"VERSION IS AVAILABLE!\"\n_51     :=      \"DO YOU WISH TO DOWNLOAD THE NEW VERSION\"\n_52     :=      \"COULD NOT CREATE THE DOWNLOAD LINK!\"\n_53     :=      \"COULD NOT GET THE UPDATE PACKAGE LOCATION!\"\n_54     :=      \"COMPLETE\"\n_55     :=      \"UPDATE TOOL IS NOT FOUND!\"\n_56     :=      \"DEFINE BARCODE\"\n_57     :=      \"DEFINE NAME\"\n_58     :=      \"DEFINE BUY PRICE\"\n_59     :=      \"DEFINE SELL PRICE\"\n_60     :=      \"DEFINE QUANTITY\"\n_61     :=      \"STOCK CHANGE\"\n_62     :=      \"SAVE CHANGES\"\n_63     :=      \"BARCODE\"\n_64     :=      \"SUM CALCULATION\"\n_65     :=      \"SELECTION OF ALL PRODUCTS IN THE SAME STOCK\"\n_66     :=      \"SUM FLOW\"\n_67     :=      \"ERROR\"\n_68     :=      \"QUANTITY\"\n_69     :=      \"PRICE\"\n_70     :=      \"FILE NAME\"\n_71     :=      \"USERNAME AND TIME\"\n_72     :=      \"DATE\"\n_73     :=      \"RELOG\"\n_74     :=      \"ALL\"\n_75     :=      \"ENTER THE REGISTERED USERNAME AND THE PASSWORD TO CONTINUE\"\n_76     :=      \"A USERNAME IS REQUIRED TO CONTINUE!\"\n_77     :=      \"A PASSWORD IS REQUIRED TO CONTINUE!\"\n_78     :=      \"THE USERNAME OR THE PASSWORD IS/ARE WRONG\"\n_79     :=      \"SOLD PRODUCTS\"\n_80     :=      \"FINDS\"\n_81     :=      \"MORE DETAILS ABOUT THE SELL\"\n_82     :=      \"SEARCH RESULTS\"\n_83     :=      \"STATISTIC INFO\"\n_84     :=      \"SELLS\"\n_85     :=      \"CALCULATE ALL\"\n_86     :=      \"SORTED BY THE SOLD QUANTITY\"\n_87     :=      \"USERNAME\"\n_88     :=      \"PASSWORD\"\n_89     :=      \"ADD USER\"\n_90     :=      \"EDIT USER\"\n_91     :=      \"REMOVE USER\"\n_92     :=      \"*NEW USERNAME\"\n_93     :=      \"*NEW PASSWORD\"\n_94     :=      \"SUBMITTED\"\n_95     :=      \"NOT YET SUBMITTED\"\n_96     :=      \"SELLS WAS FOUND\"\n_97     :=      \"SELL WAS FOUND\"\n_98     :=      \"TRANSACTION SUCESSFUL!\"\n_99     :=      \"AT\"\n_100    :=      \"WAITING FOR\"\n_101    :=      \"SUBMISSION\"\n_102    :=      \"ADMIN PASSWORD\"\n_103    :=      \"PLEASE RE-ENTER YOUR PASSWORD TO CONFIRM THIS OPERATION\"\n_104    :=      \"ENABLE DEBUG MODE FOR TESTING\"\n_105    :=      \"SEND FEEDBACK\"\n_106    :=      \"UPDATE CHECK\"\n_107    :=      \"BY NAME SEARCH\"\n_108    :=      \"START UP\"\n_109    :=      \"LOG IN\"\n_110    :=      \"CREATE A USERNAME\"\n_111    :=      \"CREATE A PASSWORD\"\n_112    :=      \"UN-VALID\"\n_113    :=      \"PLEASE MAKE SURE THE INPUT DOESN'T CONTAIN THE FOLLOWING CHARACTERS `;/\"\n_114    :=      \"PLEASE RE-CHECK YOUR LOGGING INFO, SOMETHING SEEMS WRONG!\"\n_115    :=      \"SELL\"\n_116    :=      \"ENSURE\"\n_117    :=      \"DEFINE\"\n_118    :=      \"STOCK\"\n_119    :=      \"REVIEW\"\n_120    :=      \"MANAGE\"\n_121    :=      \"KRIDI\"\n_122    :=      \"TOTAL PRICE\"\n_123    :=      \"DISCOUNT\"\n_124    :=      \"CLIENT NAME\"\n_125    :=      \"NOTES\"\n_126    :=      \"DETAILS\"\n_127    :=      \"ADD MORE INFO\"\n_128    :=      \"PROFIT\"\n_129    :=      \"PROFIT\"\n_130    :=      \"DELETE\"\n_131    :=      \"EDIT\"\n_132    :=      \"APPLY\"\n_133    :=      \"SOLD WITH\"\n_134    :=      \"BOUGHT WITH\"\n_135    :=      \"THE MADE PROFIT\"\n_136    :=      \"SELECT A PICTURE\"\n_137    :=      \"ADD A PICTURE\"\n_138    :=      \"COST PRICE\"\n_139    :=      \"SEARCH BY BARCODE OR NAME\"\n_140    :=      \"ADD\"\n_141    :=      \"TOTAL\"\n_142    :=      \"RESET ALL\"\n_143    :=      \"RESET SELECTED\"\n_144    :=      \"SURE?\"\n_145    :=      \"YOU ARE ABOUT TO RESET ALL THE STOCK! CONTINUE?\"\n_146    :=      \"DONE!\"\n_147    :=      \"THE STOCK SHOULD BE RESETTED BY NOW!\"\n_148    :=      \"THE FOLLOWING STOCK IS ABOUT TO BE RESETTED! CONTINUE?\"\n_149    :=      \"THE FOLLOWING STOCK SHOULD BE RESETTED BY NOW!\"\n_150    :=      \"NEW USER\"\n_151    :=      \"THE ADMIN LOGGING INPUTS ARE WRONG!\"\n_152    :=      \"THIS USER ALREADY EXIST! IT SHOULD BE SELECTED IN THE LIST SHOWING THE USERS LIST.\"\n_156    :=      \"USERS\"\n_157    :=      \"OVER ALL SELL PRICE\"\n_158    :=      \"OVER ALL COST PRICE\"\n_159    :=      \"OVER ALL COST PROFIT\"\n_160    :=      \"UNVALID SELL DATA!\"\n_161    :=      \"SEARCH BY NAME\"\n_162    :=      \"HOTKEYS\"\n_163    :=      \"PROGRESS\"\n_164    :=      \"THIS PAYEMENT\"\n_165    :=      \"FAILED TO DOWNLOAD FROM GITHUB!\"\n_166    :=      \"INVALID INPUT DATA!\"\n_167    :=      \"ADD CART\"\n_168    :=      \"SUBMIT\"\n_169    :=      \"CANCEL\"\n_170    :=      \"SHOW MORE\"\n_171    :=      \"SHOW LESS\"\n_172    :=      \"LOOK UP\"\n_173    :=      \"CHART\"\n_174    :=      \"CONFIRM PLEASE!\"\n_175    :=      \"ARCHIVE THE LISTED SELLS?\"\n_176    :=      \"DEFINED STOCK\"\n_177    :=      \"DUPLICATE\"\n_178    :=      \"ALREADY DEFINED!\"\n_179    :=      \"NOT ACCEPTED!\"\n_180    :=      \"PLEASE MAKE SURE THE INPUT DOESN'T CONTAIN THE FOLLOWING CHARACTERS `;\"\n_181    :=      \"EMPTY INPUT\"\n_182    :=      \"PLEASE MAKE SURE TO WRITE SOMETHING FIRST!\"\n_183    :=      \"ADD (TO) GROUP\"\n_184    :=      \"GROUP OF PRODUCTS\"\n_185    :=      \"WRITE DOWN A GROUP NAME\"\n_186    :=      \"PAY\"\n_187    :=      \"QUESTION\"\n_188    :=      \"PAYS\"\n_189    :=      \"CONFIRM?\"\n_190    :=      \"WILL BE CLEARED OUT!\"\n_191    :=      \"CLEAR OUT!\"\n_192    :=      \"UPDATE!\"\n_193    :=      \"FILL FORMS\"\n_194    :=      \"ARE YOU SURE TO DELETE\"\n_195    :=      \"DELETE GROUP\"\n_196    :=      \"REGISTER\"\n_197    :=      \"ADD VALUE OF\"\n_198    :=      \"+ NEW PERSON\"\n_199    :=      \"INVALID INPUTS!\"\n_200    :=      \"GROUPS\"\n_201    :=      \"#########\"\n_202    :=      \"INFO TYPE\"\n_203    :=      \"NORMAL\"\n_204    :=      \"MORE DETAILS\"\n_205    :=      \"HELP LIST\"\n_206    :=      \"NAME\"\n_207    :=      \"LEVEL\"\n_208    :=      \"VIEW\"\n_209    :=      \"VIEW ALL\"\n_210    :=      \"ELIMINATE GROUPS\"\n_211    :=      \"USER INFORMATION\"\n_212    :=      \"ADMIN\"\n_213    :=      \"USER\"\n_214    :=      \"PICTURE\"\n_215    :=      \"PREVILIGES\"\n_216    :=      \"ACCESS TO THE SELL SECTION\"\n_217    :=      \"ACCESS TO THE SUBMIT SECTION\"\n_218    :=      \"ACCESS TO THE DEFINE SECTION\"\n_219    :=      \"ACCESS TO THE REVIEW SECTION\"\n_220    :=      \"ACCESS TO THE KRIDI SECTION\"\n_221    :=      \"ACCESS TO THE USERS SECTION\"\n_222    :=      \"BE ABLE TO DO KRIDI\"\n_223    :=      \"BE ABLE TO VIEW STOCK CHANGES\"\n_224    :=      \"THERE IS NO ADMINS LEFT IN THE USER LIST, COMTINUE?\"\n_225    :=      \"PLEASE RE-CHECK YOUR ENTERED INFORMATION!\"\n;////////////////////////////////////////////////////////////////////////////////////////////////////"
  },
  {
    "path": "README.md",
    "content": "\n"
  },
  {
    "path": "StartUp.ahk",
    "content": "﻿#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\n#NoEnv\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\Class_CtlColors.ahk\n#Include, Lib\\Classes\\Class_ImageButton.ahk\n#Include, Lib\\Classes\\Class_GDIplus.ahk\n\n#Include, Lib\\Language.ahk\n\nFolderSet()\nColors := [0, 1, 3, 4, 5, 6, 7, 8, 9, \"A\", \"B\", \"C\", \"D\", \"E\", \"F\"]\n\nGui, +HwndMain\nGui, Margin, 10, 15\nGui, Color, 0xE6E6E6\nGui, Font, s12 Bold, Consolas\n\nIf (Acc := FileExist(\"Sets\\Acc.chu\")) {\n    Account := {}\n    FileRead, RawAccount, Sets\\Acc.chu\n    TextAccount := b64Decode(RawAccount)\n    \n    For Each, User in StrSplit(TextAccount, \",\") {\n        LOG := StrSplit(User, \"|\")\n        Account[LOG[1]] := [LOG[2], LOG[3]]\n    }\n}\n\nGui, Add, Pic,, Img\\Keys.png\nGui, Add, Text, xm+65 yp+5 w140 Center, % (Acc ? _87 : _92) \":\"\nGui, Add, Edit, xp+140 yp-3 w200 vUserName -E0x200 Border\nGui, Add, Text, xp-140 yp+35 w140 Center, % (Acc ? _88 : _93) \":\"\nGui, Add, Edit, xp+140 yp-3 w200 vPassWord -E0x200 Border\n\nGui, Add, Button, % \"xp+100 yp+35 w100 HwndHCtrl vLogin g\" (Acc ? E := \"Next\" : E := \"NewNext\"), % Acc ? _109 : _196\nImageButton.Create(HCtrl, [[3, 0x80FF80, 0x5ABB5A, 0x000000, 2,, 0x008000, 1]\n                         , [3, 0x44DB44, 0x2F982F, 0x000000, 2,, 0x008000, 1]\n                         , [3, 0x1AB81A, 0x107410, 0x000000, 2,, 0x008000, 1]\n                         , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]*)\nGui, Font, s10\nGui, Add, CheckBox, % \"xm yp+35 vRL\", % _32\n\nIf (!Acc) {\n    GuiControl, Disabled, CN\n    GuiControl, Disabled, RL\n}\n\nFileRead, CV, Version.txt\nGui, Add, Text, vCV w50, % \"v\" CV\nGui, Show,, LOGIN GUI\n\nIf FileExist(\"Sets\\RAcc.chu\") {\n    FileRead, RawRL, Sets\\RAcc.chu\n    TextRL := StrSplit(b64Decode(RawRL), \"|\")\n    If (Account[TextRL[1]][1] = TextRL[2]) {\n        GuiControl, Focus, UserName\n        SendInput, % TextRL[1]\n        GuiControl, Focus, PassWord\n        SendInput, % TextRL[2]\n        GuiControl,, RL, 1\n    }\n}\n\nIf IsConnected()  {\n    ;URLDownloadToFile, https://raw.githubusercontent.com/FreeP4lestine/Cassier/main/Program/Release/Version.txt, LVersion.txt\n    ;If (!ErrorLevel) {\n    ;    FileRead, LV, LVersion.txt\n    ;    LV := Trim(LV, \"`n\")\n    ;    If (StrReplace(LV, \".\") > StrReplace(CV, \".\")) {\n    ;        Gui, Add, Button, xp+70 yp-5 wp+100 gUpdate HwndHCtrl vUpdate, % \"[\" LV \"] - \" _192\n    ;        ImageButton.Create(HCtrl, [[3, 0xFF6F6F, 0xBC5454, 0x000000, 2,, 0xFF0000, 1]\n    ;                                 , [3, 0xDC6262, 0x9C4545, 0x000000, 2,, 0xFF0000, 1]\n    ;                                 , [3, 0xBF5454, 0x8A3C3C, 0x000000, 2,, 0xFF0000, 1]\n    ;                                 , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0xFF0000, 1]]*)\n    ;    }\n    ;}\n}\nReturn\n\n#If WinActive(\"ahk_id \" Main)\n    Enter::\n        GoSub, % E\n    Return\n#If\n\nGuiClose:\n    IniRead, PIDs, Sets\\PID.ini, PID\n    Loop, Parse, PIDs, `n, `r\n    {\n        Process, Close, % StrSplit(A_LoopField, \"=\")[2]\n    }\nExitApp\n\nUpdate:\n    ;Gui, Hide\n    ;Run, % \"GUIUpdate\" (A_IsCompiled ? \".exe\" : \".ahk\"),,, PID\n    ;URLDownloadToFile, https://github.com/FreeP4lestine/Cassier/raw/main/Installer/Install.exe, % A_Temp \"\\Install.exe\"\n    ;Process, Close, % PID\n    ;Run, % A_Temp \"\\Install.exe\"\n    ;ExitApp\nReturn\n\nNewNext:\n    GuiControlGet, UserName,, UserName\n    GuiControlGet, PassWord,, PassWord\n    If (UserName != \"\") && (PassWord != \"\") {\n        If (Obj := FileOpen(\"Sets\\Acc.chu\", \"w\")) {\n            Obj.Write(b64Encode(UserName \"|\" PassWord \"|Admin\")).Close()\n            Reload\n        }\n    }\nReturn\n\nNext:\n    GuiControlGet, UserName,, UserName\n    GuiControlGet, PassWord,, PassWord\n    If (UserName != \"\") && (PassWord == Account[UserName][1]) {\n        If (Account[UserName][1] != \"\") {\n            GuiControlGet, RL,, RL\n            If (RL) {\n                FileOpen(\"Sets\\RAcc.chu\", \"w\").Write(b64Encode(UserName \"|\" PassWord)).Close()\n            } Else {\n                FileDelete, Sets\\RAcc.chu\n            }\n            \n            Gui, Destroy\n            Gui, +HwndMain\n            Gui, Margin, 10, 10\n            Gui, Color, 0xE6E6E6\n            Gui, Font, s12 Bold, Consolas\n\n            Gui, Add, Button, w140 h90 gGUISell HwndHCtrl, % \"`n`n`n\" _115\n            ImageButton.Create(HCtrl, [[0, \"Img\\OM\\1.png\"]\n                                     , [0, \"Img\\OM\\2.png\",, 0x0080FF]\n                                     , [0, \"Img\\OM\\3.png\",, 0xFF0000]\n                                     , [0, \"Img\\OM\\4.png\"]]*)\n            If (Account[UserName][2] = \"Admin\") {\n                Gui, Add, Button, xp+150 yp w140 h90 gGUISubmit HwndHCtrl, % \"`n`n`n\" _116\n                ImageButton.Create(HCtrl, [ [0, \"Img\\ED\\1.png\"]\n                                        ,   [0, \"Img\\ED\\2.png\",, 0x0080FF]\n                                        ,   [0, \"Img\\ED\\3.png\",, 0xFF0000]\n                                        ,   [0, \"Img\\ED\\4.png\"]]*)\n                Gui, Add, Button, xp+150 yp w140 h90 gGUIDefine HwndHCtrl, % \"`n`n`n\" _117\n                ImageButton.Create(HCtrl, [ [0, \"Img\\DE\\1.png\"]\n                                        ,   [0, \"Img\\DE\\2.png\",, 0x0080FF]\n                                        ,   [0, \"Img\\DE\\3.png\",, 0xFF0000]\n                                        ,   [0, \"Img\\DE\\4.png\"]]*)\n                Gui, Add, Button, xp+150 yp w140 h90 gGUIReview HwndHCtrl, % \"`n`n`n\" _119\n                ImageButton.Create(HCtrl, [ [0, \"Img\\PR\\1.png\"]\n                                        ,   [0, \"Img\\PR\\2.png\",, 0x0080FF]\n                                        ,   [0, \"Img\\PR\\3.png\",, 0xFF0000]\n                                        ,   [0, \"Img\\PR\\4.png\"]]*)\n                Gui, Add, Button, xp+150 yp w140 h90 gGUIKridiM HwndHCtrl, % \"`n`n`n\" _121\n                ImageButton.Create(HCtrl, [ [0, \"Img\\KR\\1.png\"]\n                                        ,   [0, \"Img\\KR\\2.png\",, 0x0080FF]\n                                        ,   [0, \"Img\\KR\\3.png\",, 0xFF0000]\n                                        ,   [0, \"Img\\KR\\4.png\"]]*)\n                Gui, Add, Button, xp+150 yp w140 h90 gGUIUser HwndHCtrl, % \"`n`n`n\" _156\n                ImageButton.Create(HCtrl, [ [0, \"Img\\AM\\1.png\"]\n                                          , [0, \"Img\\AM\\2.png\",, 0x0080FF]\n                                          , [0, \"Img\\AM\\3.png\",, 0xFF0000]\n                                          , [0, \"Img\\AM\\4.png\"]]*)\n            }\n            Gui, Show,, START UP GUI\n            OnMessage(0x1000, \"Message\")\n            FileOpen(\"Sets\\Login.Hwnd\", \"w\").Write(Main).Close()\n        }\n    }\nReturn\n\nGUISell:\n    Run, % \"GUISell\" (A_IsCompiled ? \".exe\" : \".ahk\") \" \" UserName \" \" PassWord,,, PID\n    IniWrite, % PID, Sets\\PID.ini, PID, GUISell\nReturn\n\nGUISubmit:\n    Run, % \"GUISubmit\" (A_IsCompiled ? \".exe\" : \".ahk\") \" \" UserName \" \" PassWord,,, PID\n    IniWrite, % PID, Sets\\PID.ini, PID, GUISubmit\nReturn\n\nGUIDefine:\n    Run, % \"GUIDefine\" (A_IsCompiled ? \".exe\" : \".ahk\") \" \" UserName \" \" PassWord,,, PID\n    IniWrite, % PID, Sets\\PID.ini, PID, GUIDefine\nReturn\n    \nGUIReview:\n    Run, % \"GUIReview\" (A_IsCompiled ? \".exe\" : \".ahk\") \" \" UserName \" \" PassWord,,, PID\n    IniWrite, % PID, Sets\\PID.ini, PID, GUIReview\nReturn\n\nGUIKridiM:\n    Run, % \"GUIKridiM\" (A_IsCompiled ? \".exe\" : \".ahk\") \" \" UserName \" \" PassWord,,, PID\n    IniWrite, % PID, Sets\\PID.ini, PID, GUIKridiM\nReturn\n\nGUIUser:\n    Run, % \"GUIUser\" (A_IsCompiled ? \".exe\" : \".ahk\") \" \" UserName \" \" PassWord,,, PID\n    IniWrite, % PID, Sets\\PID.ini, PID, GUIUser\nReturn\n\nb64Encode(string) {\n    VarSetCapacity(bin, StrPut(string, \"UTF-8\")) && len := StrPut(string, &bin, \"UTF-8\") - 1 \n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    VarSetCapacity(buf, size << 1, 0)\n    if !(DllCall(\"crypt32\\CryptBinaryToString\", \"ptr\", &bin, \"uint\", len, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size))\n        throw Exception(\"CryptBinaryToString failed\", -1)\n    return StrGet(&buf)\n}\n\nb64Decode(string) {\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", 0, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        throw Exception(\"CryptStringToBinary failed\", -1)\n    VarSetCapacity(buf, size, 0)\n    if !(DllCall(\"crypt32\\CryptStringToBinary\", \"ptr\", &string, \"uint\", 0, \"uint\", 0x1, \"ptr\", &buf, \"uint*\", size, \"ptr\", 0, \"ptr\", 0))\n        throw Exception(\"CryptStringToBinary failed\", -1)\n    return StrGet(&buf, size, \"UTF-8\")\n}\n\nFolderSet() {\n    Array := [ \"Curr\"\n             , \"Sets\"\n             , \"Sets\\Def\"\n             , \"Valid\"\n             , \"Dump\"\n             , \"Kr\"\n             , \"Unvalid\"\n             , \"Hist\"    ]\n    For Every, Folder in Array {\n        If !FolderExist(Folder) {\n            FileCreateDir, % Folder\n        }\n    }\n}\n\nFolderExist(Folder) {\n    Return InStr(FileExist(Folder), \"D\")\n}\n\nIsConnected() {\n    Return DllCall(\"Wininet.dll\\InternetGetConnectedState\", \"Str\", 0x40, \"Int\", 0)\n}\n\nMessage() {\n    Global Account, UserName, PassWord\n    FileRead, Message, Sets\\Login.Request\n    MsgData := StrSplit(Message, \"|\")\n    If (MsgData[1] = \"Run\") {\n        If (Account[UserName][2] = \"Admin\") {\n            Run, % MsgData[2] \" \" UserName \" \" PassWord\n        } Else If InStr(MsgData[2], \"GUISell\") {\n            Run, % MsgData[2] \" \" UserName \" \" PassWord\n        }\n    } Else If (MsgData[1] = \"Reload\") {\n        IniRead, PIDs, Sets\\PID.ini, PID\n        Loop, Parse, PIDs, `n, `r\n        {\n            Process, Close, % StrSplit(A_LoopField, \"=\")[2]\n        }\n        Reload\n    }\n}\n\nRandomColor(Colors) {\n    Color := \"\"\n    Loop, 6 {\n        Random, Index, 1, 16\n        Color .= Colors[Index]\n    }\n    Return, Color\n}"
  },
  {
    "path": "Template.css",
    "content": ".highcharts-figure,\n.highcharts-data-table table {\n    min-width: 360px;\n    max-width: 100%;\n    margin: 1em auto;\n}\n\n.highcharts-data-table table {\n    font-family: Verdana, sans-serif;\n    border-collapse: collapse;\n    border: 1px solid #ebebeb;\n    margin: 10px auto;\n    text-align: center;\n    width: 100%;\n    max-width: 500px;\n}\n\n.highcharts-data-table caption {\n    padding: 1em 0;\n    font-size: 1.2em;\n    color: #555;\n}\n\n.highcharts-data-table th {\n    font-weight: 600;\n    padding: 0.5em;\n}\n\n.highcharts-data-table td,\n.highcharts-data-table th,\n.highcharts-data-table caption {\n    padding: 0.5em;\n}\n\n.highcharts-data-table thead tr,\n.highcharts-data-table tr:nth-child(even) {\n    background: #a0a0a0;\n}\n\n.highcharts-data-table tr:hover {\n    background: #5a78a0;\n}\n"
  },
  {
    "path": "Template.html",
    "content": "<script src=\"HighChart/highcharts.js\"></script>\n<script src=\"HighChart/modules/series-label.js\"></script>\n<script src=\"HighChart/modules/exporting.js\"></script>\n<script src=\"HighChart/modules/export-data.js\"></script>\n<script src=\"HighChart/modules/accessibility.js\"></script>\n<script src=\"Template.css\"></script>\n\n<figure class=\"highcharts-figure\">\n    <div id=\"container\">\n        <script src=\"Template.js\"></script>\n    </div>\n    <a href=\"https://www.highcharts.com/demo/line-basic\" style=\"font-family:calibri;\">A HighChart demo adapted</a>\n</figure>"
  },
  {
    "path": "Template.js",
    "content": "Highcharts.chart('container', {\n    chart: {\n        type: 'line',\n    },\n    \n    title: {\n        text: 'CASH HELPER CHART VIEW',\n        align: 'left'\n    },\n\n    subtitle: {\n        text: 'A graphic resume of your sells',\n        align: 'left'\n    },\n\n    yAxis: {\n        title: {\n            text: 'Amount in millims'\n        }\n    },\n\n    xAxis: {\n        categories: ['2023/02/21','2023/02/25','2023/03/04','2023/03/05','2023/06/01','2023/06/02','2023/06/03','2023/06/04'],\n    },\n\n    series: [{\n        name: 'SELLS',\n        color: '#008000',\n        data: [29550,31250,6000,45250,475650,540450,572000,264550],\n    }, {\n        name: 'COSTS',\n        color: '#FF0000',\n        data: [25984,25926,4913,39566,411282,460238,482860,224345]\n    }, {\n        name: 'PROFITS',\n        color: '#0066FF',\n        data: [3566,5324,1087,5684,64368,80212,89140,40205]\n    }],\n\n    responsive: {\n        rules: [{\n            condition: {\n                maxWidth: 500\n            },\n            chartOptions: {\n                legend: {\n                    layout: 'horizontal',\n                    align: 'center',\n                    verticalAlign: 'bottom'\n                }\n            }\n        }]\n    }\n\n});\n"
  },
  {
    "path": "Uninstall.ahk",
    "content": "#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\nFileInstall, Uninstall.png, Uninstall.png, 1\n\nGui, -MinimizeBox\nGui, Font, s20 Bold, Calibri\nGui, Color, White\nGui, Add, Text, Center BackgroundTrans w400, Cash Helper\nGui, Add, Pic, xm yp-10 w64 h64 BackgroundTrans, Uninstall.png\nGui, Font, Norm\nGui, Font, s10 Bold\nGui, Add, Edit, ReadOnly w400 vLoc, % A_ScriptDir\nIS := InstallState()\nGui, Add, Button, w100 vUB, % IS[1]\n\nIf (IS[1] = \"Not Installed\") {\n    GuiControl, Disabled, UB\n}\n\nGui, Add, Progress, vPB w100 -Smooth h15 w400 Hidden\nGui, Font, s8\nGui, Add, Text, xp yp+17 wp Center vPercent BackgroundTrans\nGui, Show\nReturn\n\nGuiClose:\nExitApp\n\nButtonUninstall:\n    GuiControl, Disabled, UB\n    RegDelete, HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Cash Helper\n    FileDelete, % A_Desktop \"\\Cash Helper.lnk\"\n    GuiControlGet, Loc\n    FileRemoveDir, % Loc, 1\n    FileOpen(A_Temp \"\\CH_Uninstall.bat\", \"w\").Write(\"timeout 1`nrd /s /q \"\"\" Loc \"\"\"\").Close()\n    MsgBox,, Complete, Uninstall Complete!\n    Run, % A_Temp \"\\CH_Uninstall.bat\",, Hide\n    ExitApp\nReturn\n\nInstallState() {\n    RegRead, IC, HKLM, SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Cash Helper, InstallLocation\n    GuiControlGet, Loc\n    IS := (IC = Loc \"\\\") ? [\"Uninstall\", \"Uninstalling...\"] : [\"Not Installed\", \"\"]\n    GuiControl,, IB, % IS[1]\n    Return, IS\n}"
  },
  {
    "path": "Version.txt",
    "content": "2.0.2.0"
  }
]