main 23e109c71713 cached
48 files
296.9 KB
93.3k tokens
1 requests
Download .txt
Showing preview only (312K chars total). Download the full file or copy to clipboard to get everything.
Repository: FreeP4lestine/Lost-Crypto-Finder-Helper
Branch: main
Commit: 23e109c71713
Files: 48
Total size: 296.9 KB

Directory structure:
gitextract_bty5ohzv/

├── .gitignore
├── GUIDefine.ahk
├── GUIDefine_Functions.ahk
├── GUIDefine_Hotkeys.ahk
├── GUIDefine_Labels.ahk
├── GUIDetails.ahk
├── GUIDetails_Functions.ahk
├── GUIDetails_Labels.ahk
├── GUIKridi.ahk
├── GUIKridiM.ahk
├── GUIKridiM_Functions.ahk
├── GUIKridiM_Hotkeys.ahk
├── GUIKridiM_Labels.ahk
├── GUIKridi_Functions.ahk
├── GUIKridi_Hotkeys.ahk
├── GUIKridi_Labels.ahk
├── GUIReview.ahk
├── GUIReview_Functions.ahk
├── GUIReview_Hotkeys.ahk
├── GUIReview_Labels.ahk
├── GUISell.ahk
├── GUISell_Functions.ahk
├── GUISell_Hotkeys.ahk
├── GUISell_Labels.ahk
├── GUISubmit.ahk
├── GUISubmit_Functions.ahk
├── GUISubmit_Hotkeys.ahk
├── GUISubmit_Labels.ahk
├── GUIUpdate.ahk
├── GUIUser.ahk
├── GUIUser_Functions.ahk
├── GUIUser_Hotkeys.ahk
├── GUIUser_Labels.ahk
├── GenerateRelease.ahk
├── Import.ahk
├── Install.ahk
├── Lib/
│   ├── Classes/
│   │   ├── Class_CtlColors.ahk
│   │   ├── Class_GDIplus.ahk
│   │   ├── Class_ImageButton.ahk
│   │   └── Class_RichEdit.ahk
│   └── Language.ahk
├── README.md
├── StartUp.ahk
├── Template.css
├── Template.html
├── Template.js
├── Uninstall.ahk
└── Version.txt

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
__Compiler/
__Release/
CKr/
Curr/
Dump/
HighChart/
Hist/
Kr/
Sets/
Unvalid/
Valid/
*.ico

================================================
FILE: GUIDefine.ahk
================================================
#Requires AutoHotkey v1.1
#SingleInstance, Force
SetBatchLines, -1
SetWorkingDir, % A_ScriptDir

#Include, Lib\Classes\Class_CtlColors.ahk
#Include, Lib\Classes\Class_ImageButton.ahk
#Include, Lib\Classes\Class_GDIplus.ahk

#Include, Lib\Language.ahk

FolderSet()

If !Level := LogIn(AdminName := A_Args[1], AdminPass := A_Args[2]) {
    FileRead, Reciever, Sets\Login.Hwnd
    FileOpen("Sets\Login.Request", "w").Write("Run|" A_ScriptFullPath).Close()
    SendMessage, 0x1000,,,, ahk_id %Reciever%
    Sleep, 1000
    MsgBox, 16, % _112, % _114
    ExitApp
}

Gui, +HwndMain +Resize
Gui, Add, Pic, % "x0 y0", Img\BG.png
Gui, Margin, 10, 10
Gui, Color, 0x7D7D3A
Gui, Font, s14 Bold, Calibri

qw := ((A_ScreenWidth - 255) // 5)

Gui, Add, Text, % "xm+220 y30 vDbcT w" qw " h32 Center BackgroundTrans", % _56 ":"
Gui, Add, Text, % "xp+" qw " yp wp hp Center BackgroundTrans", % _57 ":"
Gui, Add, Text, % "xp+" qw " yp wp hp Center BackgroundTrans", % _58 ":"
Gui, Add, Text, % "xp+" qw " yp wp hp Center BackgroundTrans", % _59 ":"
Gui, Add, Text, % "xp+" qw " yp wp hp Center BackgroundTrans", % _176 ":"
Gui, Font, s15
Gui, Add, Edit, % "xp-" qw * 4 " yp+32 wp Center Border vDbc -E0x200 cBlue"
Gui, Add, Edit, % "xp+" qw " yp wp Center Border vDnm -E0x200"
Gui, Add, Edit, % "xp+" qw " yp wp Center Border vDbp -E0x200 Number cRed"
Gui, Add, Edit, % "xp+" qw " yp wp Center Border vDsp -E0x200 Number cGreen"
Gui, Add, Edit, % "xp+" qw " yp wp Center Border vDst -E0x200"

Gui, Font, s15
Gui, Add, ListView, % "xm+220 yp+75 w" qw * 5 " h" A_ScreenHeight - 280 " Grid vLV2 HwndHCtrl gEdit BackgroundE6E6E6", % _63 "|" _38 "|" _40 "|" _39 "|" _118

LV_ModifyCol(1, qw)
LV_ModifyCol(2, qw)
LV_ModifyCol(3, qw)
LV_ModifyCol(4, qw)
LV_ModifyCol(5, qw)

Gui, Font, s17
Gui, Add, Edit, % "xp+" qw*3 " yp+" A_ScreenHeight - 275 " w" qw*2 " Center vStockSum -E0x200 HwndHCtrl Border"
CtlColors.Attach(HCtrl, "EAEAB5")

ButtonTheme := [[3, 0x80FF80, 0x5ABB5A, 0x000000, 2,, 0x008000, 1]
              , [3, 0x44DB44, 0x2F982F, 0x000000, 2,, 0x008000, 1]
              , [3, 0x1AB81A, 0x107410, 0x000000, 2,, 0x008000, 1]
              , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]

ButtonTheme2 := [[3, 0x00E7E7, 0x02A0A0, 0x000000, 2,, 0x007E80, 1]
               , [3, 0x02CBCB, 0x028080, 0x000000, 2,, 0x007E80, 1]
               , [3, 0x03A4A4, 0x036767, 0x000000, 2,, 0x007E80, 1]
               , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]

ButtonTheme3 := [[3, 0xFFC488, 0xBF9264, 0x000000, 2,, 0x804000, 1]
               , [3, 0xE0AB75, 0x96724E, 0x000000, 2,, 0x804000, 1]
               , [3, 0xC29465, 0x826344, 0x000000, 2,, 0x804000, 1]
               , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]

ButtonTheme4 := [[3, 0xFF6F6F, 0xBC5454, 0x000000, 2,, 0xFF0000, 1]
               , [3, 0xDC6262, 0x9C4545, 0x000000, 2,, 0xFF0000, 1]
               , [3, 0xBF5454, 0x8A3C3C, 0x000000, 2,, 0xFF0000, 1]
               , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0xFF0000, 1]]

Gui, Add, Text, xm+5 ym w190 Center BackgroundTrans, % _200

Gui, Font, s14
Gui, Add, Text, wp BackgroundTrans, % _208 ":"
Gui, Add, DDL, vViewMode wp AltSubmit gLoadProducts, % _209 "||" _210
Gui, Add, ListBox, % "0x100 wp r10 vGroup gDisplayGroup HwndHCtrl", % _74
CtlColors.Attach(HCtrl, "D8D8AD")
Gui, Font, s13
Gui, Add, Button, % "wp h30 gAddGroup HwndHCtrl", % _183
ImageButton.Create(HCtrl, ButtonTheme*)
                         
Gui, Add, Button, % "w190 h30 gDelGroup HwndHCtrl", % _195
ImageButton.Create(HCtrl, ButtonTheme4*)

Gui, Add, Button, % "xm+220 y100 wp h30 gEnter HwndHCtrl", % _36 " ↓"
ImageButton.Create(HCtrl, ButtonTheme*)

Gui, Add, Button, % "xp+" qw*4 + (qw - 190) " yp w190 hp gEdit HwndHCtrl", %  "↑ " _131
ImageButton.Create(HCtrl, ButtonTheme2*)

Gui, Font, Italic
Gui, Add, Button, % "xm+220 y" A_ScreenHeight - 130 " w100 h30 gFillForms HwndHCtrl", % _193
ImageButton.Create(HCtrl, ButtonTheme3*)
                         
Gui, Add, Button, % "xp+110 yp wp hp gResetAll HwndHCtrl", % _142
ImageButton.Create(HCtrl, ButtonTheme3*)
                         
Gui, Add, Button, % "xp+110 yp wp hp gDelete HwndHCtrl", % _130
ImageButton.Create(HCtrl, ButtonTheme3*)

Gui, Add, Button, % "xp+110 yp wp hp gEsc HwndHCtrl", % _169
ImageButton.Create(HCtrl, ButtonTheme3*)

Gui, Font
Gui, Font, s12 Bold, Calibri
Levels := ["Admin", "User"]
Gui, Add, StatusBar
SB_SetParts(10, 200, 200)
SB_SetText(_206 ": " AdminName, 2)
SB_SetText(_207 ": " Levels[Level], 3)

Gui, Show, Maximize, Definition GUI
ThemeAdd()
LoadGroups()
GuiControl, Choose, Group, |1
Return

#Include, GUIDefine_Labels.ahk
#Include, GUIDefine_Functions.ahk
#Include, GUIDefine_Hotkeys.ahk

================================================
FILE: GUIDefine_Functions.ahk
================================================
LoadGroups() {
    Global _74
    GuiControl,, Group, |
    GuiControl,, Group, % _74
    Loop, Files, Sets\Def\*, D
        GuiControl,, Group, % A_LoopFileName
    GuiControl, Choose, Group, |1
}

LogIn(Username, Password) {
    If (FileExist("Sets\Acc.chu")) {
        Account := {}
        FileRead, RawAccount, Sets\Acc.chu
        TextAccount := b64Decode(RawAccount)
        
        For Each, User in StrSplit(TextAccount, ",") {
            LOG := StrSplit(User, "|")
            Account[LOG[1]] := [LOG[2], LOG[3]]
        }
        
        If (Account[Username][1] = Password) {
            If (Account[Username][2] = "Admin")
                Return, 1
            Else If (Account[Username][2] = "User")
                Return, 2
        }
    }
    Return, 0
}

b64Encode(string) {
    VarSetCapacity(bin, StrPut(string, "UTF-8")) && len := StrPut(string, &bin, "UTF-8") - 1 
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", 0, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    VarSetCapacity(buf, size << 1, 0)
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", &buf, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    return StrGet(&buf)
}

b64Decode(string) {
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", 0, "uint*", size, "ptr", 0, "ptr", 0))
        throw Exception("CryptStringToBinary failed", -1)
    VarSetCapacity(buf, size, 0)
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", &buf, "uint*", size, "ptr", 0, "ptr", 0))
        throw Exception("CryptStringToBinary failed", -1)
    return StrGet(&buf, size, "UTF-8")
}

LoadProducts() {
    LV_Delete(), Files := "", Loc := {}
    GuiControl,, StockSum
    Loop, Files, % "Sets\Def\*.def", R
    {
        Bc := StrReplace(A_LoopFileName, ".def")
        Files .= Files != "" ? "`n" Bc : Bc
        Loc["" Bc ""] := A_LoopFileFullPath
    }

    Sort, Files, N
    StockSum := 0

    GuiControlGet, ViewMode,, ViewMode
    Loop, Parse, Files, `n
    {
        If (ViewMode = 2) && !FileExist("Sets\Def\" A_LoopField ".def") {
            Continue
        }
        FileRead, Content, % Loc["" A_LoopField ""]
        Content := StrSplit(Content, ";"), Content[4] != "" ? StockSum += Content[4] * Content[3] : 0
        LV_Add(, A_LoopField, Content[1], Content[2], Content[3], "[" (Content[4] != "" ? Content[4] : 0) "]")
        GuiControl,, StockSum, % StockSum " " ConvertMillimsToDT(StockSum)
        
    }
    Return, StockSum
}

ConvertMillimsToDT(Value, Sign := "") {
    If (Value + 1 = "")
        Return
    ValueArr := StrSplit(Value / 1000, ".")
    Return, "[" ValueArr[1] (ValueArr[2] ? "." RTrim(ValueArr[2], 0) : "") " DT]"
}

FolderSet() {
    Array := [ "Curr"
             , "Sets"
             , "Sets\Def"
             , "Valid"
             , "Dump"
             , "Kr"
             , "CKr" 
             , "Unvalid" 
             , "Hist" ]

    For Every, Folder in Array {
        If !FolderExist(Folder) {
            FileCreateDir, % Folder
        }
    }
}

FolderExist(Folder) {
    Return InStr(FileExist(Folder), "D")
}

ThemeAdd() {
    Loop, 5 {
        Gui, Add, Text, % "y0 x" 208 + A_Index * 2 " w1 h" A_ScreenHeight " HwndHCtrl"
        CtlColors.Attach(HCtrl, "7D7D64")
    }
}

Add() {
    Global StockSum, _177, _178
    GuiControlGet, Dbc,, Dbc
    
    ExistedDef := ""
    Loop, Files, % "Sets\Def\" Dbc ".def", R
    {
        ExistedDef := A_LoopFileFullPath
    }

    If (ExistedDef != "") {
        FileRead, Content, % ExistedDef
        MsgBox, 48, % _177, % _178 "`n`n" Dbc " = " StrSplit(Content, ";")[1]
        Return, 0
    }
    
    GuiControlGet, Group,, Group
    WD := (Group = "ALL") ? "Sets\Def\" : "Sets\Def\" Group "\"

    GuiControlGet, Dnm,, Dnm
    GuiControlGet, Dbp,, Dbp
    GuiControlGet, Dsp,, Dsp
    GuiControlGet, Dst,, Dst

    LV_Insert(1,, Dbc, Dnm, Dbp, Dsp, "[" Dst "]")
    FileOpen(WD Dbc ".def", "w").Write(Dnm ";" Dbp ";" Dsp ";" Dst).Close()
    
    GuiControl,, Dbc
    GuiControl,, Dnm
    GuiControl,, Dbp
    GuiControl,, Dsp
    GuiControl,, Dst

    StockSum += Dsp * Dst
    GuiControl,, StockSum, % StockSum " " ConvertMillimsToDT(StockSum)
    GuiControl, Focus, Dbc

    FileOpen("Sets\Message.Request", "w").Write("Update_Definitions").Close()
    FileRead, Reciever, Sets\GUISell.Hwnd
    SendMessage, 0x1000,,,, ahk_id %Reciever%
    Return, 1
}

Modify() {
    Global Row, _177, _178, StockSum
    GuiControlGet, Dbc,, Dbc
    LV_GetText(Bc, Row, 1)
    ExistedDef := ""
    Loop, Files, % "Sets\Def\" Dbc ".def", R
    {
        ExistedDef := A_LoopFileFullPath
    }

    If (Bc != Dbc) && (ExistedDef != "") {
        FileRead, Content, % ExistedDef
        MsgBox, 48, % _177, % _178 "`n`n" Dbc " = " StrSplit(Content, ";")[1]
        Return, 0
    }

    ExistedDef := ""
    Loop, Files, % "Sets\Def\" Bc ".def", R
    {
        ExistedDef := A_LoopFileFullPath
    }

    If (ExistedDef != "") {
        SplitPath, % ExistedDef,, WD
        WD .= "\"
    } Else {
        GuiControlGet, Group,, Group
        WD := (Group = "ALL") ? "Sets\Def\" : "Sets\Def\" Group "\"
    }

    GuiControlGet, Dnm,, Dnm
    GuiControlGet, Dbp,, Dbp
    GuiControlGet, Dsp,, Dsp
    GuiControlGet, Dst,, Dst
    
    FileDelete, % WD Bc ".def"
    FileOpen(WD Dbc ".def", "w").Write(Dnm ";" Dbp ";" Dsp ";" Dst).Close()
    
    LV_GetText(St, Row, 5)
    LV_GetText(Sp, Row, 4)
    StockSum -= Trim(St, "[]") * Sp
    StockSum += Dsp * Dst
    LV_Modify(Row,, Dbc, Dnm, Dbp, Dsp, "[" Dst "]")

    GuiControl,, Dbc
    GuiControl,, Dnm
    GuiControl,, Dbp
    GuiControl,, Dsp
    GuiControl,, Dst
    GuiControl,, StockSum, % StockSum " " ConvertMillimsToDT(StockSum)
    GuiControl, Focus, Dbc

    FileOpen("Sets\Message.Request", "w").Write("Update_Definitions").Close()
    FileRead, Reciever, Sets\GUISell.Hwnd
    SendMessage, 0x1000,,,, ahk_id %Reciever%
    Return, 1
}

VerifyInputs() {
    Global _181, _182, _177, _178
    GuiControlGet, Dbc,, Dbc
    If (Dbc = "") {
        GuiControl, Focus, Dbc
        ShakeControl("Dbc")
        Return, 0
    }
    GuiControlGet, Dnm,, Dnm
    If (Dnm = "") {
        GuiControl, Focus, Dnm
        ShakeControl("Dnm")
        Return, 0
    }
    If InStr(Dnm, ";") {
        GuiControl, Focus, Dnm
        ShakeControl("Dnm")
        Return, 0
    }
    GuiControlGet, Dbp,, Dbp
    If (Dbp = "") {
        GuiControl, Focus, Dbp
        ShakeControl("Dbp")
        Return, 0
    }
    GuiControlGet, Dsp,, Dsp
    If (Dsp = "") {
        GuiControl, Focus, Dsp
        ShakeControl("Dsp")
        Return, 0
    }
    GuiControlGet, Dst,, Dst
    If (Dst = "") {
        GuiControl, Focus, Dst
        ShakeControl("Dst")
        Return, 0
    }
    Return, 1
}

ShakeControl(Ctrl) {
    GuiControlGet, Pos, Pos, % Ctrl
    Loop, 5 {
        GuiControl, Move, % Ctrl, % "x" PosX -= 4
        Sleep, 50
        GuiControl, Move, % Ctrl, % "x" PosX += 4
        Sleep, 50
    }
}

================================================
FILE: GUIDefine_Hotkeys.ahk
================================================
#If WinActive("ahk_id " Main)
    Enter::
        If !VerifyInputs()
            Return
        If (!EditModOn) {
            Add()
            Return
        }
        If Modify() {
            EditModOn := 0
        }
    Return

    Delete::
        If (Row := LV_GetNext()) {
            LV_GetText(Bc, Row, 1)
            LV_GetText(St, Row, 5)
            LV_GetText(Sp, Row, 4)
        
            LV_Delete(Row)

            ExistedDef := ""
            Loop, Files, % "Sets\Def\" Bc ".def", R
            {
                ExistedDef := A_LoopFileFullPath
            }

            If (ExistedDef != "")
                FileDelete, % ExistedDef

            GuiControlGet, StockSum
            StockSum -= Trim(St, "[]") * Sp
            GuiControl,, StockSum, % StockSum " " ConvertMillimsToDT(StockSum)

            EditModOn := 0
        }
    Return

    Esc::
        GuiControl,, Dbc
        GuiControl,, Dnm
        GuiControl,, Dbp
        GuiControl,, Dsp
        GuiControl,, Dst
        EditModOn := 0
        GuiControl, Focus, Dbc
        LoadProducts()
    Return
    
    ^!LButton::
        MouseClick
        GoSub, FillForms
    Return
    
    ^F::
        GuiControlGet, Group,, Group
        GuiControlGet, Dbc,, Dbc
        GuiControlGet, Dnm,, Dnm
        GuiControlGet, Dbp,, Dbp
        GuiControlGet, Dsp,, Dsp
        GuiControlGet, Dst,, Dst
        If (Group = "ALL") {
            If (Dbc != "") || (Dnm != "") || (Dst != "") || (Dbp != "") || (Dsp != "") {
                LV_Delete()
                Loop, Files, Sets\Def\*.def, R
                {
                    FileRead, Content, % A_LoopFileFullPath
                    Content := StrSplit(Content, ";")
                    If InStr(StrReplace(A_LoopFileName, ".def"), Dbc) && InStr(Content[1], Dnm) && InStr(Content[2], Dbp) && InStr(Content[3], Dsp) && InStr(Content[4], Dst) {
                        LV_Add(, StrReplace(A_LoopFileName, ".def"), Content[1], Content[2], Content[3], "[" (Content[4] != "" ? Content[4] : 0) "]")
                    }
                }
            }
        } Else {
            If (Dbc != "") || (Dnm != "") || (Dst != "") || (Dbp != "") || (Dsp != "") {
                LV_Delete()
                Loop, Files, Sets\Def\%Group%\*.def
                {
                    FileRead, Content, % A_LoopFileFullPath
                    Content := StrSplit(Content, ";")
                    If InStr(StrReplace(A_LoopFileName, ".def"), Dbc) && InStr(Content[1], Dnm) && InStr(Content[2], Dbp) && InStr(Content[3], Dsp) && InStr(Content[4], Dst) {
                        LV_Add(, StrReplace(A_LoopFileName, ".def"), Content[1], Content[2], Content[3], "[" (Content[4] != "" ? Content[4] : 0) "]")
                    }
                }
            }
        }
    Return
#If

================================================
FILE: GUIDefine_Labels.ahk
================================================
DelGroup:
    GuiControlGet, Group,, Group
    If (Group != "ALL") {
        Msgbox, 36,% _187, % _194 " " Group " ?"
        IfMsgBox, Yes
        {
            Msgbox, 36,% _187, % _174
            IfMsgBox, Yes
            {
                FileRemoveDir, % "Sets\Def\" Group, 1
                LoadGroups()
            }
        }
    }
Return

FillForms:
    If (Row := LV_GetNext()) {
        LV_GetText(Dbc, Row, 1)
        LV_GetText(Dnm, Row, 2)
        LV_GetText(Dbp, Row, 3)
        LV_GetText(Dsp, Row, 4)
        LV_GetText(Dst, Row, 5)

        GuiControl,, Dbc, % Dbc
        GuiControl,, Dnm, % Dnm
        GuiControl,, Dbp, % Dbp
        GuiControl,, Dsp, % Dsp
        GuiControl,, Dst, % Trim(Dst, "[]")
    }
Return

AddGroup:
    InputBox, Groupname, % _184, % _185,, 300, 130
    If !InStr(FileExist("Sets\Def\" Groupname), "D") && (Groupname != "ALL") {
        FileCreateDir, % "Sets\Def\" Groupname
        If (!ErrorLevel) {
            GuiControl,, Group, % Groupname
        }
    }
    Groupname   := Groupname = "ALL" ? "" : Groupname "\"
    Row         := 0
    While (Row := LV_GetNext(Row)) {
        LV_GetText(Bc, Row, 1)
        Loop, Files, % "Sets\Def\" Bc ".def", R
            Src := A_LoopFileFullPath
        FileMove, % Src, % "Sets\Def\" Groupname Bc ".def"
    }
    GuiControl, ChooseString, Group, % "|" (Groupname = "" ? "ALL" : SubStr(Groupname, 1, -1))
Return

ResetAll:
    GuiControlGet, Group,, Group
    If (Group = "ALL") {
        Loop, Files, Sets\Def\*.def, R
        {
            FileRead, Content, % A_LoopFileFullPath
            Content := StrSplit(Content, ";")
            FileOpen(A_LoopFileFullPath, "w").Write(Content[1] ";" Content[2] ";" Content[3] ";0").Close()
        }
        StockSum := LoadProducts()
    } Else {
        Loop, Files, Sets\Def\%Group%\*.def
        {
            FileRead, Content, % A_LoopFileFullPath
            Content := StrSplit(Content, ";")
            FileOpen(A_LoopFileFullPath, "w").Write(Content[1] ";" Content[2] ";" Content[3] ";0").Close()
        }
        GoSub, DisplayGroup
    }
    
Return

DisplayGroup:
    GuiControlGet, Group,, Group
    GuiControl,, StockSum
    If (GROUP != "ALL") {
        LV_Delete(), Files := ""
        Loop, Files, % "Sets\Def\" Group "\*.def"
        {
            Bc := StrReplace(A_LoopFileName, ".def")
            Files .= Files != "" ? "`n" Bc : Bc
        }
    
        Sort, Files, N
        StockSum := 0
        
        Loop, Parse, Files, `n
        {
            FileRead, Content, % "Sets\Def\" Group "\" A_LoopField ".def"
            Content := StrSplit(Content, ";"), Content[4] != "" ? StockSum += Content[4] * Content[3] : 0
            LV_Add(, A_LoopField, Content[1], Content[2], Content[3], "[" (Content[4] != "" ? Content[4] : 0) "]")
            GuiControl,, StockSum, % StockSum " " ConvertMillimsToDT(StockSum)
        }
    } Else {
        StockSum := LoadProducts()
    }
Return

Edit:
    If (Row := LV_GetNext()) {
        LV_GetText(Dbc, Row, 1)
        LV_GetText(Dnm, Row, 2)
        LV_GetText(Dbp, Row, 3)
        LV_GetText(Dsp, Row, 4)
        LV_GetText(Dst, Row, 5)

        GuiControl,, Dbc, % Dbc
        GuiControl,, Dnm, % Dnm
        GuiControl,, Dbp, % Dbp
        GuiControl,, Dsp, % Dsp
        GuiControl,, Dst, % Trim(Dst, "[]")

        EditModOn := 1
    }
Return

GuiClose:
    IniDelete, Sets\PID.ini, PID, GUIDefine
ExitApp

================================================
FILE: GUIDetails.ahk
================================================
#Requires AutoHotkey v1.1
#SingleInstance, Force
SetBatchLines, -1
SetWorkingDir, % A_ScriptDir

#Include, Lib\Classes\Class_CtlColors.ahk
#Include, Lib\Classes\Class_ImageButton.ahk
#Include, Lib\Classes\Class_GDIplus.ahk

#Include, Lib\Language.ahk

FolderSet()

Gui, Color, 0xD8D8AD
Gui, -MinimizeBox
Gui, Font, s15 Bold, Calibri
Gui, Margin, 5, 5
Gui, Add, ListBox, w200 h250 0x100 vReInLB gDisplayDetails AltSubmit
Gui, Add, Edit, xp+210 yp w500 h200 ReadOnly vDInfo -E0x200 Border -VScroll
Gui, Add, Edit, xp yp+212 ReadOnly w500 vOverAll -E0x200 Border cGreen Center h38
Gui, Font, s12 Underline
Gui, Add, CheckBox, xm+600 yp+45 vShowMore gShowMore, % _170
Gui, Font, Norm
Gui, Font, s15 Bold
Gui, Add, Text, xm yp+30, % _123 ":"
Gui, Add, Edit, xp yp+30 w300 vRemise ReadOnly -E0x200 Border cGreen
Gui, Add, Text, xp yp+35, % _124 ":"
Gui, Add, Edit, xp yp+30 w710 vClient -E0x200 Border ReadOnly cBlue
Gui, Add, Text, xp yp+35 wp, % _125 ":"
Gui, Add, Edit, xp yp+30 wp vSellDesc cBlue r10 -E0x200 Border ReadOnly -VScroll
Gui, Show, h290

If (A_Args[1]) {
    FileRead, Content, %1%

    Content := StrSplit(Content, "> ")
    Sells   := StrSplit(Content[2], "|")

    Array := {}, OverAll := 0
    For Each, One in Sells {
        Section := StrSplit(One, ";")
        Array[A_Index] := [Section[1]       ; Barcode
                         , Section[2]       ; Name
                         , Section[3]       ; SellStr
                         , Section[4]       ; Sells
                         , Section[5]       ; BuyStr
                         , Section[6]       ; Buys
                         , Section[7]]      ; Profit
        GuiControl,, ReInLB, % Array[A_Index][2]
        OverAll += Section[7]
    }

    GuiControl,, OverAll, % OverAll " " ConvertMillimsToDT(OverAll)

    If (Content[4]) {
        AddInfo := StrSplit(Content[4], ";")
        If (AddInfo[1])
        GuiControl,, Remise, % AddInfo[1] " %"
        If (AddInfo[2])
        GuiControl,, Client, % AddInfo[2]
        If (AddInfo[3])
        GuiControl,, SellDesc, % AddInfo[3]
    }

    GuiControl, Choose, ReInLB, |1
}
Return

#Include, GUIDetails_Labels.ahk
#Include, GUIDetails_Functions.ahk

================================================
FILE: GUIDetails_Functions.ahk
================================================
ConvertMillimsToDT(Value, Sign := "") {
    If (Value = "..." || !Value)
        Return
    ValueArr := StrSplit(Value / 1000, ".")
    Return, "(" (Sign ? " " Sign " " : "") ValueArr[1] (ValueArr[2] ? "." RTrim(ValueArr[2], 0) : "") " DT)"
}

FolderSet() {
    Array := [ "Curr"
             , "Sets"
             , "Sets\Def"
             , "Valid"
             , "Dump"
             , "Kr"
             , "CKr" 
             , "Unvalid" 
             , "Hist" ]

    For Every, Folder in Array {
        If !FolderExist(Folder) {
            FileCreateDir, % Folder
        }
    }
}

FolderExist(Folder) {
    Return InStr(FileExist(Folder), "D")
}

================================================
FILE: GUIDetails_Labels.ahk
================================================
GuiClose:
ExitApp

DisplayDetails:
    GuiControlGet, ReInLB,, ReInLB
    If (ReInLB) {
        GuiControl,, DInfo, % _27 ": " Array[ReInLB][1]
                       . "`n" _38 ": " Array[ReInLB][2]
                       . "`n" _39 ": " Array[ReInLB][3] " = " Array[ReInLB][4]
                       . "`n" _40 ": " Array[ReInLB][5] " = " Array[ReInLB][6]
                       . "`n" _41 ": " Array[ReInLB][7]
    }
    
Return

ShowMore:
    GuiControlGet, ShowMore,, ShowMore
    If (ShowMore) {
        Gui, Show, h705 Center
        GuiControl,, ShowMore, % _171
    } Else {
        Gui, Show, h290 Center
        GuiControl,, ShowMore, % _170
    }
Return

================================================
FILE: GUIKridi.ahk
================================================
#SingleInstance, Force
SetBatchLines, -1
SetWorkingDir, % A_ScriptDir

#Include, Lib\Classes\Class_CtlColors.ahk
#Include, Lib\Classes\Class_ImageButton.ahk
#Include, Lib\Classes\Class_GDIplus.ahk

#Include, Lib\Language.ahk

FolderSet()

Gui, -MinimizeBox
Gui, Color, 0xD8D8AD
Gui, Margin, 10, 10
Gui, Font, s15 Bold, Calibri
Gui, Add, Edit, w200 vKName -E0x200 Border gCheckKExist
Gui, Font, s13
Gui, Add, Button, xm+210 ym w100 h33 HwndHCtrl gEnter, % _36
ImageButton.Create(HCtrl,[[0, 0x2ECB52, , 0x000000, 0, , 0x28A745, 2]
                        , [0, 0x31E059, , 0x000000, 0, , 0x28A745, 2]
                        , [0, 0x37F462, , 0x000000, 0, , 0x28A745, 2]
                        , [0, 0xD8D8AD, , 0xB2B2B2, 0, , 0xB2B2B2, 2]]* )
Gui, Font, s15
Gui, Add, ListBox, w200 xm ym+40 vKLB h450 gDisplayThisKridi -Multi
Gui, Add, ListView, xm+210 ym+40 w760 h435 Grid cBlue HwndHCtrl -Hdr, Col1|Col2|Col3|Col4|Col5

LV_ModifyCol(1, 0)
LV_ModifyCol(2, 190)
LV_ModifyCol(3, 190 " Center")
LV_ModifyCol(4, 190 " Center")
LV_ModifyCol(5, 190 " Center")
Gui, Add, Edit, xm+550 ym w200 h33 -E0x200 Border ReadOnly vTotal Center
Gui, Add, Edit, xm+768 ym w200 h33 -E0x200 Border ReadOnly vThisTotal Center cRed HwndE
CtlColors.Attach(E, "FFFFFF", "000000")

Gui, Show
LoadKridiUsers()
Return

#Include, GUIKridi_Functions.ahk
#Include, GUIKridi_Labels.ahk
#Include, GUIKridi_Hotkeys.ahk

================================================
FILE: GUIKridiM.ahk
================================================
#SingleInstance, Force
SetBatchLines, -1
SetWorkingDir, % A_ScriptDir

#Include, Lib\Classes\Class_CtlColors.ahk
#Include, Lib\Classes\Class_ImageButton.ahk
#Include, Lib\Classes\Class_GDIplus.ahk

#Include, Lib\Language.ahk

FolderSet()

If !Level := LogIn(AdminName := A_Args[1], AdminPass := A_Args[2]) {
    FileRead, Reciever, Sets\Login.Hwnd
    FileOpen("Sets\Login.Request", "w").Write("Run|" A_ScriptFullPath).Close()
    SendMessage, 0x1000,,,, ahk_id %Reciever%
    Sleep, 1000
    MsgBox, 16, % _112, % _114
    ExitApp
}

Gui, +HwndMain +Resize
Gui, Add, Pic, % "x0 y0", Img\BG.png
Gui, Margin, 10, 10
Gui, Color, 0x7D7D3A
Gui, Font, s14 Bold, Calibri

ButtonTheme := [[3, 0x80FF80, 0x5ABB5A, 0x000000, 2,, 0x008000, 1]
              , [3, 0x44DB44, 0x2F982F, 0x000000, 2,, 0x008000, 1]
              , [3, 0x1AB81A, 0x107410, 0x000000, 2,, 0x008000, 1]
              , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]

ButtonTheme2 := [[3, 0xFF6F6F, 0xBC5454, 0x000000, 2,, 0xFF0000, 1]
               , [3, 0xDC6262, 0x9C4545, 0x000000, 2,, 0xFF0000, 1]
               , [3, 0xBF5454, 0x8A3C3C, 0x000000, 2,, 0xFF0000, 1]
               , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0xFF0000, 1]]
               
ButtonTheme3 := [[3, 0xFFC080, 0xBE8F60, 0x000000, 2,, 0xFF8000, 1]
               , [3, 0xE0AA72, 0xA47C53, 0x000000, 2,, 0xFF8000, 1]
               , [3, 0xC89664, 0x906D48, 0x000000, 2,, 0xFF8000, 1]
               , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0xFF8000, 1]]

ButtonTheme4 := [[3, 0x96C864, 0x739A4C, 0x000000, 2,, 0x80FF00, 1]
               , [3, 0x8CBB5D, 0x658643, 0x000000, 2,, 0x80FF00, 1]
               , [3, 0x79A051, 0x56733A, 0x000000, 2,, 0x80FF00, 1]
               , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x80FF00, 1]]

Gui, Add, Button, % "xm+5 ym+20 gAdd HwndHCtrl w190 h60", % _198
ImageButton.Create(HCtrl, ButtonTheme* )

Gui, Font, s16
Gui, Add, Edit, % "xm+5 ym+90 wp r2 vAllKridi -E0x200 Border Center ReadOnly HwndHCtrl -VScroll"
CtlColors.Attach(HCtrl, "EAEAB5")

Gui, Font, s14
qw := ((A_ScreenWidth - 255) // 3)
Gui, Add, ListBox, % "wp h" A_ScreenHeight - 340 " vKLB HwndHCtrl Multi gShowKridiInfo 0x100"
CtlColors.Attach(HCtrl, "EAEAB5")
Gui, Font, s16
Gui, Add, Button, % "gDelete HwndHCtrl wp h60", % _191
ImageButton.Create(HCtrl, ButtonTheme2* )

Gui, Font, s14
Gui, Add, ListView, % "xm+421 ym+20 w" qw * 3 - 391 " h" A_ScreenHeight - 200 " vLV", % "|" _38 "|" _68 "|" _39

LV_ModifyCol(1, "0 Center")
LV_ModifyCol(2, qw - 130)
LV_ModifyCol(3, qw - 130)
LV_ModifyCol(4, qw - 130)

Gui, Font, s16
Gui, Add, Edit, % "xp-201 yp w190 r2 vThisKridi -E0x200 Border Center ReadOnly HwndHCtrl -VScroll"
CtlColors.Attach(HCtrl, "FFC080")

Gui, Font, s14
Gui, Add, ListBox, % "wp h" A_ScreenHeight - 425 " vKDate gSelectFromLv AltSubmit HwndHCtrl Multi 0x100"
CtlColors.Attach(HCtrl, "FFC080")

Gui, Font, s16
Gui, Add, Edit, % "wp r2 vSubThisKridi -E0x200 Border Center ReadOnly HwndHCtrl -VScroll"
CtlColors.Attach(HCtrl, "FFC080")

Gui, Add, Edit, % "wp vKridi -E0x200 Border Center HwndHCtrl -VScroll Number"
CtlColors.Attach(HCtrl, "FFFFFF")

Gui, Add, Button, % "wp h30 HwndHCtrl gKridiOut", % _29
ImageButton.Create(HCtrl, ButtonTheme3*)

Gui, Add, Edit, % "xm+" qw * 3 - 391 + 12 + 421 " ym+20 wp r2 vPay -E0x200 Border Center ReadOnly HwndHCtrl -VScroll"
CtlColors.Attach(HCtrl, "96C864")

Gui, Font, s14
Gui, Add, ListBox, % "wp h" A_ScreenHeight - 425 " vPDate HwndHCtrl AltSubmit gShowPayVal 0x100"
CtlColors.Attach(HCtrl, "96C864")

Gui, Font, s16
Gui, Add, Edit, % "wp r2 vThisPay -E0x200 Border Center ReadOnly HwndHCtrl -VScroll"
CtlColors.Attach(HCtrl, "96C864")

Gui, Add, Edit, % "wp vPayBack -E0x200 Border Center HwndHCtrl -VScroll Number"
CtlColors.Attach(HCtrl, "FFFFFF")

Gui, Add, Button, % "wp h30 HwndHCtrl gPayOut", % _186
ImageButton.Create(HCtrl, ButtonTheme4*)

Gui, Font, s20
Gui, Add, Edit, % "vBalance xm+421 y" A_ScreenHeight - 160 " w" qw * 3 - 391 " -E0x200 Border Center HwndHCtrl ReadOnly"
CtlColors.Attach(HCtrl, "D8D8AD", "FF0000")

Gui, Font, s12
Levels := ["Admin", "User"]
Gui, Add, StatusBar
SB_SetParts(10, 200, 200)
SB_SetText(_206 ": " AdminName, 2)
SB_SetText(_207 ": " Levels[Level], 3)

Gui, Show, Maximize, Review GUI
ThemeAdd()
LoadKridis()
Return

#Include, GUIKridiM_Hotkeys.ahk
#Include, GUIKridiM_Functions.ahk
#Include, GUIKridiM_Labels.ahk

================================================
FILE: GUIKridiM_Functions.ahk
================================================
FolderSet() {
    Array := [ "Curr"
             , "Sets"
             , "Sets\Def"
             , "Valid"
             , "Dump"
             , "Kr"
             , "CKr" 
             , "Unvalid" 
             , "Hist" ]

    For Every, Folder in Array {
        If !FolderExist(Folder) {
            FileCreateDir, % Folder
        }
    }
}

FolderExist(Folder) {
    Return InStr(FileExist(Folder), "D")
}

LogIn(Username, Password) {
    If (FileExist("Sets\Acc.chu")) {
        Account := {}
        FileRead, RawAccount, Sets\Acc.chu
        TextAccount := b64Decode(RawAccount)
        
        For Each, User in StrSplit(TextAccount, ",") {
            LOG := StrSplit(User, "|")
            Account[LOG[1]] := [LOG[2], LOG[3]]
        }
        
        If (Account[Username][1] = Password) {
            If (Account[Username][2] = "Admin")
                Return, 1
            Else If (Account[Username][2] = "User")
                Return, 2
        }
    }
    Return, 0
}

b64Encode(string) {
    VarSetCapacity(bin, StrPut(string, "UTF-8")) && len := StrPut(string, &bin, "UTF-8") - 1 
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", 0, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    VarSetCapacity(buf, size << 1, 0)
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", &buf, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    return StrGet(&buf)
}

b64Decode(string) {
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", 0, "uint*", size, "ptr", 0, "ptr", 0))
        throw Exception("CryptStringToBinary failed", -1)
    VarSetCapacity(buf, size, 0)
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", &buf, "uint*", size, "ptr", 0, "ptr", 0))
        throw Exception("CryptStringToBinary failed", -1)
    return StrGet(&buf, size, "UTF-8")
}

ThemeAdd() {
    Loop, 5 {
        Gui, Add, Text, % "y0 x" 208 + A_Index * 2 " w1 h" A_ScreenHeight " HwndHCtrl"
        CtlColors.Attach(HCtrl, "7D7D64")
    }
}

ConvertMillimsToDT(Value, Sign := "") {
    If (Value = "..." || !Value)
        Return
    ValueArr := StrSplit(Value / 1000, ".")
    Return, "[" (Sign ? Sign " " : "") ValueArr[1] (ValueArr[2] ? "." RTrim(ValueArr[2], 0) : "") " DT]"
}

LoadKridis(ChooseName := "") {
    GuiControl,, KLB, |
    GuiControl,, SelectFromLv, |
    LV_Delete()

    GuiControl,, SubThisKridi
    GuiControl,, ThisKridi
    GuiControl,, AllKridi
    GuiControl,, ThisPay
    GuiControl,, PayBack
    GuiControl,, Pay
    GuiControl,, PDate
    GuiControl,, Balance
    
    AK := 0
    Loop, Files, Kr\*, D
    {
        Name := A_LoopFileName
        Loop, Files, % "Kr\" Name "\*.sell"
        {
            FileRead, Content, % A_LoopFileFullPath
            AK += StrSplit(StrSplit(Content, "> ")[3], ";")[1]
        }
        GuiControl,, KLB, % Name
        GuiControl,, AllKridi, % AK "`n" ConvertMillimsToDT(AK)
    }
    
    If (ChooseName = "")
        GuiControl, Choose, KLB, |1
    Else {
        GuiControl, ChooseString, KLB, |%ChooseName%
    }
}

KridiDates(KLB) {
    LV_Delete()
    GuiControl,, KDate, |

    DateRow := {}, ItemSum := {}, I := 0, TK := 0
    Loop, Files, % "Kr\" KLB "\*.sell"
    {
        FileRead, Content, % A_LoopFileFullPath
        Content := StrSplit(Content, "> ")
        Date    := StrSplit(Content[1], "|")[2]
        
        DateRow[++I]  := []
        ItemSum[I]    := StrSplit(Content[3], ";")[1]
        TK      += ItemSum[I]
        
        GuiControl,, ThisKridi, % TK "`n" ConvertMillimsToDT(TK)
        GuiControl,, KDate, % Date
        
        Sells   := StrSplit(Trim(Content[2], "|"), "|")
        
        For Every, Sell in Sells {
            SubSell := StrSplit(Sell, ";")
            Row := LV_Add(, SubSell[1], SubSell[2], SubSell[3], SubSell[4])
            DateRow[I].Push(Row)
        }
    }
    GuiControl,, SubThisKridi
    Return, [DateRow, ItemSum, TK]
}

PayDates(KLB) {
    P := 0, PayVal := {}
    GuiControl,, PDate, |
    GuiControl,, Pay
    GuiControl,, ThisPay
    Loop, Files, % "Kr\" KLB "\*.pay"
    {
        FileRead, Content, % A_LoopFileFullPath
        P               += Content
        PayVal[A_Index] := Content
        
        GuiControl,, Pay, % P "`n" ConvertMillimsToDT(P)
        
        FormatTime, oTime, % StrReplace(A_LoopFileName, ".pay"), yyyy/MM/dd HH:mm:ss
        GuiControl,, PDate, % oTime
    }
    Return, [PayVal, P]
}

================================================
FILE: GUIKridiM_Hotkeys.ahk
================================================
#If WinActive("ahk_id " Main)
    Delete::
        GuiControlGet, KLB,, KLB
        If (KLB) {
            MsgBox, 36, % _187, % KLB " " _190
            IfMsgBox, Yes
            {
                MsgBox, 36, % _187, % _189
                IfMsgBox, Yes
                {
                    FileMoveDir, % "Kr\" KLB, % "CKr\", 1
                    LoadKridis()
                }
            }
        }
    Return
#If

================================================
FILE: GUIKridiM_Labels.ahk
================================================
ShowKridiInfo:
    GuiControlGet, KLB,, KLB
    If (KLB) {
        DateRow := KridiDates(KLB)
        PayVal := PayDates(KLB)
        Ba := DateRow[3] - PayVal[2]
        GuiControl,, Balance, % KLB ": " Ba " " ConvertMillimsToDT(Ba)
    }
Return

PayOut:
    GuiControlGet, PayBack,, PayBack
    If (PayBack) {
        GuiControlGet, KLB,, KLB
        MsgBox, 36, % _187, % KLB " " _188 " " PayBack " " ConvertMillimsToDT(PayBack)
        IfMsgBox, Yes
        {
            MsgBox, 36, % _187, % _189
            IfMsgBox, Yes
            {
                FileAppend, % PayBack, % "Kr\" KLB "\" A_Now ".pay"
                GuiControl,, PayBack
                PayVal := PayDates(KLB)
                Ba := DateRow[3] - PayVal[2]
                GuiControl,, Balance, % KLB ": " Ba " " ConvertMillimsToDT(Ba)
            }
        }
        
    }
Return

KridiOut:
    GuiControlGet, Kridi,, Kridi
    If (Kridi > 0) {
        GuiControlGet, KLB,, KLB
        MsgBox, 36, % _187, % KLB " " _197 " " Kridi " " ConvertMillimsToDT(PayBack)
        IfMsgBox, Yes
        {
            MsgBox, 36, % _187, % _189
            IfMsgBox, Yes
            {
                FormatTime, OutTime, % Now := A_Now, yyyy/MM/dd HH:mm:ss
                FileAppend, % AdminName "|" OutTime "> > " Kridi ";" Kridi ";0", % "Kr\" KLB "\" A_Now ".sell"
                GuiControl,, Kridi
                DateRow := KridiDates(KLB)
                Ba := DateRow[3] - PayVal[2]
                GuiControl,, Balance, % KLB ": " Ba " " ConvertMillimsToDT(Ba)
            }
        }
    }
Return

SelectFromLV:
    GuiControlGet, KDate,, KDate
    If (!KDate)
        Return
    Loop, % LV_GetCount() {
        LV_Modify(A_Index, "-Select")
    }
    If (!InStr(KDate, "|")) {
        For Each, Row in DateRow[1][KDate] {
            LV_Modify(Row, "Select")
        }
        GuiControl, Focus, LV
    } Else {
        For Each, Date in StrSplit(KDate, "|") {
            For Each, Row in DateRow[1][Date] {
                LV_Modify(Row, "Select")
            }
            GuiControl, Focus, LV
        }
    }
    
    GuiControl,, SubThisKridi, % DateRow[2][KDate] "`n" ConvertMillimsToDT(DateRow[2][KDate])
Return

ShowPayVal:
    GuiControlGet, PDate,, PDate
    If (PDate) {
        GuiControl,, ThisPay, % PayVal[1][PDate] "`n" ConvertMillimsToDT(PayVal[1][PDate])
    }
Return

Add:
    InputBox, PersonName, Name?, Person Name?,, 300, 130
    Validity := ErrorLevel
    If (Validity = 0) {
        If (PersonName != "") && (PersonName ~= "\b\w+\b") && !InStr(FileExist("Kr\" PersonName), "D") {
            FileCreateDir, % "Kr\" PersonName
            LoadKridis(PersonName)
        } Else {
            MsgBox, 16, % _13, % _199
        }
    }
Return

KUpdateVal:

Return

GUIClose:
    IniDelete, Sets\PID.ini, PID, GUIKridiM
ExitApp

================================================
FILE: GUIKridi_Functions.ahk
================================================
LoadKridiUsers() {
    GuiControl, , KLB, |
    Loop, Files, % "Kr\*", D
        GuiControl,, KLB, % A_LoopFileName

    TotalValue := 0
    Obj := FileOpen("Dump\tmp.sell", "r")
    While !Obj.AtEOF() {
        Line := Obj.ReadLine()
        Col     := StrSplit(Line, ",")
        LV_Add(, Col[1], Col[2], Col[3], Col[4], Col[5])
        TotalValue += Col[5]
    }
    Obj.Close()
    GuiControl,, Total, % "+" TotalValue " " ConvertMillimsToDT(TotalValue, "+")
}

SetExplorerTheme(HCTL) {
    If (DllCall("GetVersion", "UChar") > 5) {
        VarSetCapacity(ClassName, 1024, 0)
        If DllCall("GetClassName", "Ptr", HCTL, "Str", ClassName, "Int", 512, "Int") {
            Return !DllCall("UxTheme.dll\SetWindowTheme", "Ptr", HCTL, "WStr", "Explorer", "Ptr", 0)
        }
    }
   Return False
}

ConvertMillimsToDT(Value, Sign := "") {
    If (Value = "..." || !Value)
        Return
    ValueArr := StrSplit(Value / 1000, ".")
    Return, "(" (Sign ? " " Sign " " : "") ValueArr[1] (ValueArr[2] ? "." RTrim(ValueArr[2], 0) : "") " DT)"
}

FolderSet() {
    Array := [ "Curr"
             , "Sets"
             , "Sets\Def"
             , "Valid"
             , "Dump"
             , "Kr"
             , "CKr" 
             , "Unvalid" 
             , "Hist" ]

    For Every, Folder in Array {
        If !FolderExist(Folder) {
            FileCreateDir, % Folder
        }
    }
}

FolderExist(Folder) {
    Return InStr(FileExist(Folder), "D")
}

================================================
FILE: GUIKridi_Hotkeys.ahk
================================================
#If WinActive("ahk_id " Kridi)
    Enter::
        GuiControlGet, KName,, KName
        If (KName = "")
            GuiControlGet, KName,, KLB
            
        If (KName != "") {
            FileOpen("Dump\Kridi.sell", "w").Write(KName).Close()
            ;FileDelete, % "Dump\Kridi.sell"
            ExitApp
        }
    Return
#If

================================================
FILE: GUIKridi_Labels.ahk
================================================
GuiClose:
    FileDelete, % "Dump\Kridi.sell"
ExitApp

CheckKExist:
    GuiControlGet, KName,, KName
    GuiControl, Choose, KLB, 0
    GuiControl, ChooseString, KLB, % "|" KName
Return

DisplayThisKridi:
    MaxValue := 0
    GuiControlGet, KLB,, KLB
    Loop, Files, % "Kr\" KLB "\*.sell"
    {
        FileRead, Content, % A_LoopFileFullPath
        Content := StrSplit(Content, "> ")[3]
        MaxValue += StrSplit(Content, ";")[1]
    }
    GuiControl,, ThisTotal, % MaxValue " " ConvertMillimsToDT(MaxValue)
Return

================================================
FILE: GUIReview.ahk
================================================
#SingleInstance, Force
SetBatchLines, -1
#NoEnv
SetWorkingDir, % A_ScriptDir

#Include, Lib\Classes\Class_CtlColors.ahk
#Include, Lib\Classes\Class_ImageButton.ahk
#Include, Lib\Classes\Class_GDIplus.ahk

#Include, Lib\Language.ahk

FolderSet()

If !Level := LogIn(AdminName := A_Args[1], AdminPass := A_Args[2]) {
    FileRead, Reciever, Sets\Login.Hwnd
    FileOpen("Sets\Login.Request", "w").Write("Run|" A_ScriptFullPath).Close()
    SendMessage, 0x1000,,,, ahk_id %Reciever%
    Sleep, 1000
    MsgBox, 16, % _112, % _114
    ExitApp
}

Gui, +HwndMain +Resize
Gui, Add, Pic, % "x0 y0", Img\BG.png
Gui, Margin, 10, 10
Gui, Color, 0x7D7D3A
Gui, Font, s14 Bold Italic, Calibri

ButtonTheme := [[3, 0x80FF80, 0x5ABB5A, 0x000000, 2,, 0x008000, 1]
              , [3, 0x44DB44, 0x2F982F, 0x000000, 2,, 0x008000, 1]
              , [3, 0x1AB81A, 0x107410, 0x000000, 2,, 0x008000, 1]
              , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]

Gui, Font, Norm
Gui, Font, s15 Bold

qw := ((A_ScreenWidth - 255) / 4)

Gui, Add, Text, % "xm+5 ym w190 vProfByProductText BackgroundTrans", % _202 ":"
Gui, Add, DDL, xp yp+30 wp vProfByProduct gShowTheInfo AltSubmit, % _203 "||" _204

Gui, Add, Text, wp vShowTheInfo BackgroundTrans, % _156 ":"
Gui, Add, DDL, xp yp+30 wp vProfByName gShowTheInfo

Gui, Add, DateTime, w190 vBegin Center h30, yyyy/MM/dd
Gui, Add, DateTime, wp vEnd Center hp, yyyy/MM/dd

Gui, Font, Norm
Gui, Font, s13 Bold italic

Gui, Add, Button, wp gCheckTheListBox HwndHCtrl h30, % "↓ " _172
ImageButton.Create(HCtrl, ButtonTheme*)

Gui, Add, ListBox, % "0x100 wp h" A_ScreenHeight - 410 " vDates HwndHCtrl gShowTheInfo Multi"
CtlColors.Attach(HCtrl, "D8D8AD", "404000")

Gui, Font, s12
Gui, Add, Edit, % "xm+220 ym+10 w" qw*2 " vOverview -E0x200 HwndHCtrl"
CtlColors.Attach(HCtrl, "000000", "FFFF00")

Gui, Font, Norm
Gui, Font, s15 Bold
Gui, Add, Progress, % "xm+" A_ScreenWidth - 240 " yp cC3C378 vPB w200 hp", 0
Gui, Add, ListView, % "xm+220 yp+40 w" qw*4 " h" A_ScreenHeight - 200 " Grid HwndHLV -Multi BackgroundE6E6E6 gShowDetails", % _70 "|" _72 "|" _39 "|" _40 "|" _41 "|Notused"
Global HLV

LV_ModifyCol(1, 0)
LV_ModifyCol(2, qw)
LV_ModifyCol(3, qw)
LV_ModifyCol(4, qw)
LV_ModifyCol(5, qw)

Gui, Add, Edit, % "xp+" qw + 4 " yp+" A_ScreenHeight - 190 " -E0x200 ReadOnly vSPr w" qw - 4 " Border HwndHCtrl Center"
CtlColors.Attach(HCtrl, "EAEAB5", "000000")

Gui, Add, Edit, % "xp+" qw " yp -E0x200 ReadOnly vCPr wp Border HwndHCtrl Center"
CtlColors.Attach(HCtrl, "EAEAB5", "FF0000")

Gui, Add, Edit, % "xp+" qw " yp -E0x200 ReadOnly vOAProfit wp Border HwndHCtrl Center"
CtlColors.Attach(HCtrl, "EAEAB5", "008000")

Gui, Add, Button, % "xm+220 yp w" qw " hp vSinceBegin HwndHCtrl gCalculateAll", % _85 " ↑"
ImageButton.Create(HCtrl, ButtonTheme*)

Gui, Add, Button, xm+5 yp w190 gChart vChart HwndHCtrl hp, % "→ " _173 " ←"
ImageButton.Create(HCtrl, ButtonTheme*)

Gui, Font, s12
Levels := ["Admin", "User"]
View := ["Normal", "More Details"]
Gui, Add, StatusBar
SB_SetParts(10, 200, 200)
SB_SetText(_206 ": " AdminName, 2)
SB_SetText(_207 ": " Levels[Level], 3)

Gui, Show, Maximize, Review GUI
ThemeAdd()

Global LVContent, Header := 1
LoadAllSells()
AnalyzeUsers()
AnalyzeDates()
GuiControl, Choose, Dates, |1
Return

#Include, GUIReview_Hotkeys.ahk
#Include, GUIReview_Functions.ahk
#Include, GUIReview_Labels.ahk

================================================
FILE: GUIReview_Functions.ahk
================================================
FolderSet() {
    Array := [ "Curr"
             , "Sets"
             , "Sets\Def"
             , "Valid"
             , "Dump"
             , "Kr"
             , "CKr" 
             , "Unvalid" 
             , "Hist" ]

    For Every, Folder in Array {
        If !FolderExist(Folder) {
            FileCreateDir, % Folder
        }
    }
}

FolderExist(Folder) {
    Return InStr(FileExist(Folder), "D")
}

LogIn(Username, Password) {
    If (FileExist("Sets\Acc.chu")) {
        Account := {}
        FileRead, RawAccount, Sets\Acc.chu
        TextAccount := b64Decode(RawAccount)
        
        For Each, User in StrSplit(TextAccount, ",") {
            LOG := StrSplit(User, "|")
            Account[LOG[1]] := [LOG[2], LOG[3]]
        }
        
        If (Account[Username][1] = Password) {
            If (Account[Username][2] = "Admin")
                Return, 1
            Else If (Account[Username][2] = "User")
                Return, 2
        }
    }
    Return, 0
}

b64Encode(string) {
    VarSetCapacity(bin, StrPut(string, "UTF-8")) && len := StrPut(string, &bin, "UTF-8") - 1 
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", 0, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    VarSetCapacity(buf, size << 1, 0)
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", &buf, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    return StrGet(&buf)
}

b64Decode(string) {
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", 0, "uint*", size, "ptr", 0, "ptr", 0))
        throw Exception("CryptStringToBinary failed", -1)
    VarSetCapacity(buf, size, 0)
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", &buf, "uint*", size, "ptr", 0, "ptr", 0))
        throw Exception("CryptStringToBinary failed", -1)
    return StrGet(&buf, size, "UTF-8")
}

SetExplorerTheme(HCTL) {
    If (DllCall("GetVersion", "UChar") > 5) {
        VarSetCapacity(ClassName, 1024, 0)
        If DllCall("GetClassName", "Ptr", HCTL, "Str", ClassName, "Int", 512, "Int") {
            Return !DllCall("UxTheme.dll\SetWindowTheme", "Ptr", HCTL, "WStr", "Explorer", "Ptr", 0)
        }
    }
    Return False
}

ThemeAdd() {
    Loop, 5 {
        Gui, Add, Text, % "y0 x" 208 + A_Index * 2 " w1 h" A_ScreenHeight " HwndHCtrl"
        CtlColors.Attach(HCtrl, "7D7D64")
    }
}

AddToList(File) {
    FileRead, Content, % File
    SplitPath, % File, OutFileName
    Date := SubStr(OutFileName, 1, 8)
    DataAll  := StrSplit(Content, "> ")

    DateUser := StrSplit(DataAll[1], "|")
    If (DateUser.Length() = 2) && !LVContent["Users"].HasKey("" DateUser[1] "") {
        LVContent["Users"]["" DateUser[1] ""] := ""
    }

    Data     := StrSplit(DataAll[3], ";")
    If (Data[1] Data[2] Data[3] ~= "\b\d+\b") {
        Names := "", Items := {}
        For Each, Prod in StrSplit(Trim(DataAll[2], "|"), "|") {
            Info := StrSplit(Prod, ";")
            If !Items.HasKey("" Info[1] "") {
                Items["" Info[1] ""] := [Info[2], 0, 0, 0, 0]
            }
            Items["" Info[1] ""][2] += StrSplit(Info[3], "x")[2]
            Items["" Info[1] ""][3] += Info[4]
            Items["" Info[1] ""][4] += Info[6]
            Items["" Info[1] ""][5] += Info[7]
            Names .= Names ? " | " Info[2] : Info[2]
        }

        C1 := [Date, File]
        C2 := DateUser
        C3 := "+ " Data[1] " " ConvertMillimsToDT(Data[1], "+")
        C4 := "- " Data[2] " " ConvertMillimsToDT(Data[2], "+")
        C5 := "+ " Data[3] " " ConvertMillimsToDT(Data[3], "+")
        C6 := Names
        C7 := Items
        C8 := Data

        LVContent["Lines"].Push([C1, C2, C3, C4, C5, C6, C7, C8])
        If !LVContent["Dates"].HasKey("" Date "") {
            LVContent["Dates"]["" Date ""] := ""
        }
    }
    GuiControl,, PB, +1
}

GetFilesCount() {
    FilesNum := 0
    Loop, Files, Valid\*.sell, R
        FilesNum += 1
    Loop, Files, Curr\*.sell, R
        FilesNum += 1
    Return, FilesNum
}

LoadAllSells() {
    LVContent   := { "Lines"  : []
                   , "Users"  : {}
                   , "Dates"  : {} }

    GuiControl,, SPr
    GuiControl,, CPr
    GuiControl,, OAProfit

    GuiControl, , PB, 0
    Range := GetFilesCount()
    GuiControl, +Range0-%Range%, PB
    
    Loop, Files, Valid\*.sell, R
        AddToList(A_LoopFileFullPath)
    
    Loop, Files, Curr\*.sell, R
        AddToList(A_LoopFileFullPath)
}

ConvertMillimsToDT(Value, Sign := "") {
    If (Value = "..." || !Value)
        Return
    ValueArr := StrSplit(Value / 1000, ".")
    Return, "[" (Sign ? Sign " " : "") ValueArr[1] (ValueArr[2] ? "." RTrim(ValueArr[2], 0) : "") " DT]"
}

UpdateSumValues(DataSum) {
    GuiControl,, SPr, % "+ " DataSum[1] " " ConvertMillimsToDT(DataSum[1], "+")
    GuiControl,, CPr, % "- " DataSum[2] " " ConvertMillimsToDT(DataSum[2], "-")
    GuiControl,, OAProfit, % "+ " DataSum[3] " " ConvertMillimsToDT(DataSum[3], "+")
}

AnalyzeUsers() {
    Global _74
    GuiControl,, ProfByName, |
    GuiControl,, ProfByName, % _74
    For User in LVContent["Users"] {
        GuiControl,, ProfByName, % User
    }
    GuiControl, Choose, ProfByName, 1
}

AnalyzeDates() {
    GuiControl,, Dates, |
    For Date in LVContent["Dates"] {
        FormatTime, ThisDay, % Date, yyyy/MM/dd
        GuiControl,, Dates, % "-- " ThisDay " --"
    }
}

UpdateHeaders() {
    Global
    LV_Delete()
    If (ProfByProduct = 1) && (Header = 2) {
        For Each, Title in [[_70, 0], [_72, qw], [_39, qw], [_40, qw], [_41, qw]]
            LV_ModifyCol(Each, Title[2], Title[1])
        Header := 1
    } 
    If (ProfByProduct = 2) && (Header = 1) {
        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"]]
            LV_ModifyCol(Each, Title[2] Title[3], Title[1])
        Header := 2
    }
}

================================================
FILE: GUIReview_Hotkeys.ahk
================================================
#If WinActive("ahk_id " Main)
Enter::
    GuiControlGet, Begin,, Begin
    GuiControlGet, End,, End
    GuiControl, Choose, Dates, 0

    While (End >= Begin) {
        FormatTime, FBegin, % Begin, yyyy/MM/dd
        GuiControl, ChooseString, Dates, % "|-- " FBegin " --"
        Begin += 1, Days
    }
Return

================================================
FILE: GUIReview_Labels.ahk
================================================
ShowDetails:
    GuiControlGet, ProfByProduct,, ProfByProduct
    If (!(Row := LV_GetNext()) || ProfByProduct = 2)
        Return
    LV_GetText(FileName, LV_GetNext(), 1)
    Run, % "GUIDetails." (A_IsCompiled ? "exe" : "ahk") " " FileName
Return

CalculateAll:
    For Date in LVContent["Dates"] {
        GuiControl, Choose, Dates, % A_Index
    }

ShowTheInfo:
    GuiControlGet, ProfByProduct,, ProfByProduct
    GuiControlGet, ProfByName,, ProfByName
    GuiControlGet, Dates,, Dates

    GuiControl,, Overview, % View[ProfByProduct] " | " ProfByName " | " Dates

    ProfByName := (ProfByName = _74) ? "" : ProfByName
    UpdateHeaders()

    DataSum := [0, 0, 0]
    If (ProfByProduct = 1) {
        For Each, Line in LVContent["Lines"] {
            FormatTime, ThisDay, % Line[1][1], '--' yyyy/MM/dd '--'
            UName := (Line[2].Length() = 2) ? Line[2][1] : ""

            If InStr(Dates, ThisDay) && InStr(UName, ProfByName) {
                LV_Add(, Line[1][2], Line[2][1] (Line[2][2] ? " | " Line[2][2] : ""), Line[3], Line[4], Line[5], Line[6])
                DataSum[1] += Line[8][1]
                DataSum[2] += Line[8][2]
                DataSum[3] += Line[8][3]
                UpdateSumValues(DataSum)
            }
        }
    }

    If (ProfByProduct = 2) {
        Info := {}
        For Each, Line in LVContent["Lines"] {
            FormatTime, ThisDay, % Line[1][1], '--' yyyy/MM/dd '--'
            UName := (Line[2].Length() = 2) ? Line[2][1] : ""
            If InStr(Dates, ThisDay) && InStr(UName, ProfByName) {
                For Barcode, Detail in Line[7] {
                    If !Info.HasKey("" Barcode "") {
                        Info["" Barcode ""] := [ LV_Add(, Barcode, Detail[1], Detail[2], Detail[3], Detail[4], Detail[5])
                                               , Detail[1]
                                               , Detail[2]
                                               , Detail[3]
                                               , Detail[4]
                                               , Detail[5] ]
                    } Else {
                        Info["" Barcode ""][3] += Detail[2]
                        Info["" Barcode ""][4] += Detail[3]
                        Info["" Barcode ""][5] += Detail[4]
                        Info["" Barcode ""][6] += Detail[5]
                        LV_Modify(  Info["" Barcode ""][1]
                                  ,,
                                  ,
                                  , Info["" Barcode ""][3]
                                  , Info["" Barcode ""][4]
                                  , Info["" Barcode ""][5]
                                  , Info["" Barcode ""][6] )
                    }
                }
                DataSum[1] += Line[8][1]
                DataSum[2] += Line[8][2]
                DataSum[3] += Line[8][3]
                UpdateSumValues(DataSum)
            }
        }
    }
Return

CheckTheListBox:
    GuiControlGet, Begin,, Begin
    GuiControlGet, End,, End
    GuiControl, Choose, Dates, |0

    While (End >= Begin) {
        FormatTime, FBegin, % Begin, yyyy/MM/dd
        GuiControl, ChooseString, Dates, % "|-- " FBegin " --"
        Begin += 1, Days
    }
Return

Chart:
    GuiControl, Disabled, Chart
    GuiControlGet, ProfByProduct,, ProfByProduct
    If (ProfByProduct = 1) {
        If (RowCount := LV_GetCount()) {
            Dummy := {}
            Loop, % RowCount {
                LV_GetText(F, A_Index, 1)
                LV_GetText(S, A_Index, 3)
                LV_GetText(B, A_Index, 4)
                LV_GetText(P, A_Index, 5)

                SplitPath, % F,,,, O

                RegExMatch(S, "\d+", S)
                RegExMatch(B, "\d+", B)
                RegExMatch(P, "\d+", P)

                If !Dummy.HasKey("" (O := SubStr(O, 1, 8)) "") {
                    Dummy["" O ""] := [0, 0, 0]
                }

                Dummy["" O ""][1] += S
                Dummy["" O ""][2] += B
                Dummy["" O ""][3] += P
            }

            Dates   := ""
            Sells   := ""
            Costs   := ""
            Profits := ""

            For Each, Date in Dummy {
                FormatTime, D, % Each, yyyy/MM/dd
                Dates   .= Dates   != ""  ? ",'"  D "'"    : "'" D "'"
                Sells   .= Sells   != ""  ? ","  Date[1]   : Date[1]
                Costs   .= Costs   != ""  ? ","  Date[2]   : Date[2]
                Profits .= Profits != ""  ? ","  Date[3]   : Date[3] 
            }
            Dates   := "[" Dates   "]"
            Sells   := "[" Sells   "]"
            Costs   := "[" Costs   "]"
            Profits := "[" Profits "]"

            FileCopy, HighChart\template\Chart.html, Template.html, 1
            FileCopy, HighChart\template\Chart.css, Template.css, 1
            FileCopy, HighChart\template\Chart.js, Template.js, 1

            FileRead, JS, Template.js

            JS := StrReplace(JS, "'[CASH_HELPER_DATES_HOLDER]'", Dates)
            JS := StrReplace(JS, "'[CASH_HELPER_SELLS_HOLDER]'", Sells)
            JS := StrReplace(JS, "'[CASH_HELPER_BUYS_HOLDER]'", Costs)
            JS := StrReplace(JS, "'[CASH_HELPER_PROFITS_HOLDER]'", Profits)

            FileOpen("Template.js"  , "w").Write(JS).Close()
            Run, Template.html
        }
    }
    GuiControl, Enabled, Chart
Return

GuiClose:
    IniDelete, Sets\PID.ini, PID, GUIReview
ExitApp

================================================
FILE: GUISell.ahk
================================================
#Requires AutoHotkey v1.1
#SingleInstance, Force
SetBatchLines, -1
#NoEnv
SetWorkingDir, % A_ScriptDir

#Include, Lib\Classes\Class_CtlColors.ahk
#Include, Lib\Classes\Class_ImageButton.ahk
#Include, Lib\Classes\Class_GDIplus.ahk

#Include, Lib\Language.ahk

FolderSet()
Global UserPic
If !Level := LogIn(AdminName := A_Args[1], AdminPass := A_Args[2]) {
    FileRead, Reciever, Sets\Login.Hwnd
    FileOpen("Sets\Login.Request", "w").Write("Run|" A_ScriptFullPath).Close()
    SendMessage, 0x1000,,,, ahk_id %Reciever%
    Sleep, 1000
    MsgBox, 16, % _112, % _114
    ExitApp
}
Gui, +HwndMain +Resize
Gui, Add, Pic, % "x0 y0", Img\BG.png
Gui, Add, Pic, % "x" A_ScreenWidth - 120 " ym w80 h80", % UserPic ? UserPic : "Img\UserLogo.png"
Gui, Margin, 10, 10
Gui, Color, 0x7D7D3A
Gui, Font, s14 Bold Italic, Calibri

Gui, Add, Text, xm+5 ym w190 BackgroundTrans, % _205 ":"
Gui, Add, ListBox, 0x100 w190 r10 vSearch gWriteToBc AltSubmit HwndHCtrl
CtlColors.Attach(HCtrl, "D8D8AD", "404000")

Gui, Font, s18 norm Bold
Gui, Add, Edit, % "xp y" A_ScreenHeight - 450 " w190 vItemsSold r2 -E0x200 ReadOnly Center -VScroll Hidden HwndHCtrl", 0
CtlColors.Attach(HCtrl, "EAEAB5", "FF0000")
Gui, Add, Edit, % "xp yp+70 w190 vSoldP -E0x200 r2 ReadOnly Center -VScroll cGreen Hidden HwndHCtrl", 0
CtlColors.Attach(HCtrl, "EAEAB5", "008000")
Gui, Add, Edit, % "xp yp+70 w190 vCostP -E0x200 r2 ReadOnly Center -VScroll cRed Hidden HwndHCtrl", 0
CtlColors.Attach(HCtrl, "EAEAB5", "FF0000")
Gui, Add, Edit, % "xp yp+70 w190 vProfitP -E0x200 r2 ReadOnly Center -VScroll cGreen Hidden HwndHCtrl", 0
CtlColors.Attach(HCtrl, "EAEAB5", "008000")

ButtonTheme := [[3, 0x80FF80, 0x5ABB5A, 0x000000, 2,, 0x008000, 1]
              , [3, 0x44DB44, 0x2F982F, 0x000000, 2,, 0x008000, 1]
              , [3, 0x1AB81A, 0x107410, 0x000000, 2,, 0x008000, 1]
              , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]

Gui, Font, s25
pw := (A_ScreenWidth - 235) / 3
Gui, Add, Edit, % "x225 ym+85 w" pw " h45 vGivenMoney -E0x200 gCalc Center Border Hidden"
CtlColors.Attach(HCtrl, "EAEAB5", "FF0000")

Gui, Add, Edit, % "xp+" pw " yp wp h45 vAllSum -E0x200 ReadOnly Center Border cGreen Hidden HwndHCtrl"
CtlColors.Attach(HCtrl, "EAEAB5", "000000")

Gui, Add, Edit, % "xp+" pw " yp wp h45 vChange -E0x200 ReadOnly Center Border cRed Hidden HwndHCtrl"
CtlColors.Attach(HCtrl, "EAEAB5", "FF0000")

Gui, Font, s25
Gui, Add, Edit, % "x225 y30 w" pw " -VScroll vBc Center -E0x200 gAnalyzeAvail Border HwndHCtrl "
SetEditCueBanner(HCtrl, _201)
Gui, Add, Button, % "xp+" pw + 5 " yp vAddEnter gEnter w80 hp HwndHCtrl Disabled", % "→"
ImageButton.Create(HCtrl, ButtonTheme*)

Gui, Add, Edit, % "xp-" (pw + 5) " yp+85 w" pw " vNm h45 -E0x200 ReadOnly Center HwndHCtrl Border"
CtlColors.Attach(HCtrl, "C5C585")

Gui, Add, Edit, % "xp+" pw " yp wp h45 vQn Center -E0x200 ReadOnly HwndHCtrl Border cRed"
CtlColors.Attach(HCtrl, "C5C585")

Gui, Add, Edit, % "xp+" pw " wp h45 -E0x200 ReadOnly Center HwndHCtrl Border vSum"
CtlColors.Attach(HCtrl, "C5C585")

Gui, Add, Button, % "vAddUp xp-" pw/2 + 50 " yp+70 gUp HwndHCtrl w50 h30 Disabled", % "+"
ImageButton.Create(HCtrl, ButtonTheme*)

Gui, Add, Button, % "vAddDown xp+50 yp gDown HwndHCtrl wp hp Disabled", % "-"
ImageButton.Create(HCtrl, ButtonTheme*)
Gui, Font, s16
Gui, Add, Text, % "x225 yp w" pw - 31 " h30 vTransc HwndTHCtrl Center gViewLastTrans Hidden"
CtlColors.Attach(THCtrl, "B2B2B2")
Gui, Add, Pic, % "x" 225 + pw - 31 " yp w30 h30 vTranscOK  gViewLastTrans Hidden", Img\Idle.png

Gui, Font, s18
Gui, Add, ListView, % "HwndHCtrl x225 yp+37 w" pw*3 " h" A_ScreenHeight - 380 " vListView Grid ", % _63 "|" _61 "|" _38 "|" _68 "|" _69

LV_ModifyCol(1, "0 Center")
LV_ModifyCol(2, Level = 1? pw / 2 : 0)
LV_ModifyCol(3, (Level = 1? pw / 2 : pw) " Center")
LV_ModifyCol(4, pw " Center")
LV_ModifyCol(5, pw " Center")

;Gui, Font, s15
Gui, Add, Edit, % "xp+" pw*2 " yp-50 w" pw " vThisListSum -E0x200 ReadOnly HwndHCtrl Center"
CtlColors.Attach(HCtrl, "D8D8AD", "FF0000")

Gui, Font, s12

Gui, Add, Button, % "vAddSell x225 y" A_ScreenHeight - 150 " gSpace w100 hp HwndHCtrl Disabled", % _115
ImageButton.Create(HCtrl, ButtonTheme*)

Gui, Add, Button, % "vAddDelete xp+100 yp gDelete HwndHCtrl wp hp Disabled", % _130
ImageButton.Create(HCtrl, ButtonTheme* )

Gui, Add, Button, % "vAddSubmit xp+100 yp gEnter w100 hp HwndHCtrl Disabled", % _168
ImageButton.Create(HCtrl, ButtonTheme*)

Gui, Add, Button, % "vSubKridi xp+100 yp gSubKridi HwndHCtrl wp hp Disabled", % _29
ImageButton.Create(HCtrl, ButtonTheme* )

Gui, Add, Button, % "vCancel xp+100 yp gEsc HwndHCtrl wp hp Disabled", % _169
ImageButton.Create(HCtrl, ButtonTheme* )

Gui, Font, s15

;Gui, Add, Pic, % "x" A_ScreenWidth - 70 " yp", Img\User.png

;Gui, Add, Edit, % "xp-200 yp w200 vUser hp -E0x200 ReadOnly HwndHCtrl Border -VScroll", % _206 ": " AdminName
;                                                                                               . "`n" _207 ": " Levels[Level]
;CtlColors.Attach(HCtrl, "C5C585")

Gui, Add, Button, % "xm+15 y" A_ScreenHeight - 160 " w30 h25 vSession1 HwndHCtrl gSession1 ", 1
ImageButton.Create(HCtrl, ButtonTheme*)
Gui, Add, Button, % "xp+35 yp wp hp vSession2 HwndHCtrl gSession2 ", 2
ImageButton.Create(HCtrl, ButtonTheme*)
Gui, Add, Button, % "xp+35 yp wp hp vSession3 HwndHCtrl gSession3 ", 3
ImageButton.Create(HCtrl, ButtonTheme*)
Gui, Add, Button, % "xp+35 yp wp hp vSession4 HwndHCtrl gSession4 ", 4
ImageButton.Create(HCtrl, ButtonTheme*)
Gui, Add, Button, % "xp+35 yp wp hp vSession5 HwndHCtrl gSession5 ", 5
ImageButton.Create(HCtrl, ButtonTheme*)
Gui, Add, Button, % "xm+15 yp+35 wp hp vSession6 HwndHCtrl gSession6 ", 6
ImageButton.Create(HCtrl, ButtonTheme*)
Gui, Add, Button, % "xp+35 yp wp hp vSession7 HwndHCtrl gSession7 ", 7
ImageButton.Create(HCtrl, ButtonTheme*)
Gui, Add, Button, % "xp+35 yp wp hp vSession8 HwndHCtrl gSession8 ", 8
ImageButton.Create(HCtrl, ButtonTheme*)
Gui, Add, Button, % "xp+35 yp wp hp vSession9 HwndHCtrl gSession9 ", 9
ImageButton.Create(HCtrl, ButtonTheme*)
Gui, Add, Button, % "xp+35 yp wp hp vSession10 HwndHCtrl gSession10 ", 10
ImageButton.Create(HCtrl, ButtonTheme*)

Gui, Font, s12
Levels := ["Admin", "User"]
Gui, Add, StatusBar
SB_SetParts(10, 200, 200)
SB_SetText(_206 ": " AdminName, 2)
SB_SetText(_207 ": " Levels[Level], 3)

Gui, Show, Maximize, Sell GUI
OnMessage(0x1000, "Message")
FileOpen("Sets\GUISell.Hwnd", "w").Write(Main).Close()

ThemeAdd()

GuiControl, Disabled, Session1
Selling     := 0
ProdDefs    := LoadDefinitions()
Session     := 1
If FileExist("Dump\" Session ".session") {
    RestoreSession()
    CalculateSum()
}
CheckLatestSells()
CurrentProfit := CalculateCurrent()

Return

#Include, GUISell_Hotkeys.ahk
#Include, GUISell_Functions.ahk
#Include, GUISell_Labels.ahk

================================================
FILE: GUISell_Functions.ahk
================================================
ConvertMillimsToDT(Value, Sign := "") {
    If (Value = "..." || !Value)
        Return
    ValueArr := StrSplit(Value / 1000, ".")
    Return, "[" (Sign ? Sign " " : "") ValueArr[1] (ValueArr[2] ? "." RTrim(ValueArr[2], 0) : "") " DT]"
}

RestoreSession() {
    Global Session
    If LV_GetCount() {
        LV_Delete()
        GuiControl, Disabled, AddUp
        GuiControl, Disabled, AddDown
        GuiControl, Disabled, AddSell
        GuiControl, Disabled, AddDelete
    }

    If FileExist("Dump\" Session ".session") {
        Obj := FileOpen("Dump\" Session ".session", "r")
        While !Obj.AtEOF() {
            Line := Trim(Obj.ReadLine(), "`n")
            Col := StrSplit(Line, ",")
            LV_Add(, Col[1], Col[2], Col[3], Col[4], Col[5])
        }
        Obj.Close()
        If LV_GetCount() {
            GuiControl, Enabled, AddUp
            GuiControl, Enabled, AddDown
            GuiControl, Enabled, AddSell
            GuiControl, Enabled, AddDelete
        }
    }
    GuiControl, Focus, Bc
}

WriteSession() {
    Global Session
    Obj := FileOpen("Dump\" Session ".session", "w")
    Loop, % LV_GetCount() {
        LV_GetText(Col1, A_Index, 1)
        LV_GetText(Col2, A_Index, 2)
        LV_GetText(Col3, A_Index, 3)
        LV_GetText(Col4, A_Index, 4)
        LV_GetText(Col5, A_Index, 5)
        Obj.WriteLine(Col1 "," Col2 "," Col3 "," Col4 "," Col5)
    }
    Obj.Close()
}

SetExplorerTheme(HCTL) {
    If (DllCall("GetVersion", "UChar") > 5) {
        VarSetCapacity(ClassName, 1024, 0)
        If DllCall("GetClassName", "Ptr", HCTL, "Str", ClassName, "Int", 512, "Int") {
            Return !DllCall("UxTheme.dll\SetWindowTheme", "Ptr", HCTL, "WStr", "Explorer", "Ptr", 0)
        }
    }
    Return False
}

LoadDefinitions() {
    Definitions := {}
    Loop, Files, Sets\Def\*.Def, R
    {
        FileRead, Content, % A_LoopFileFullPath
        Content := StrSplit(Content, ";")
        Definitions["" StrReplace(A_LoopFileName, ".def") ""] := { "Name" : Content[1]
            , "BuyPrice" : Content[2]
            , "SellPrice" : Content[3]
        , "Quantity" : Content[4] }
    }
    Return, Definitions
}

CalculateSum() {
    Global AdditionalInfo
    CharSum := 0
    Loop, % LV_GetCount() {
        LV_GetText(ThisCharSum, A_Index, 5)
        CharSum += ThisCharSum
    }
    If (CharSum) {
        GuiControlGet, Remise, , Remise
        CharSumRemise := CharSum
        If (Remise) && (AdditionalInfo) {
            CharSumRemise -= Round(Remise / 100 * CharSum)
        }
        GuiControl, , ThisListSum, % CharSumRemise " " ConvertMillimsToDT(CharSumRemise)
        GuiControl, , AllSum, % CharSumRemise
    } Else {
        GuiControl, , ThisListSum
    }
}

CartView() {
    Global Selling
    Selling := 0
    GuiControl, , AllSum
    GuiControl, , Change
    GuiControl, , GivenMoney
    GuiControl, Hide, GivenMoney
    GuiControl, Hide, AllSum
    GuiControl, Hide, Change
    GuiControl, Show, Bc
    GuiControl, Show, AddEnter
    GuiControl, Show, Nm
    GuiControl, Show, Qn
    GuiControl, Show, Sum
    LV_Delete()
    GuiControl, Focus, Bc
}

SellView() {
    Global Selling
    Selling := 1
    GuiControl, Hide, Bc
    GuiControl, Hide, AddEnter
    GuiControl, Hide, Nm
    GuiControl, Hide, Qn
    GuiControl, Hide, Sum
    GuiControl, Show, GivenMoney
    GuiControl, Show, AllSum
    GuiControl, Show, Change
    GuiControl, Focus, GivenMoney
}

TrancsView(Tranc, View) {
    Global _126, THCtrl, CountToHide := 1
    If (View) {
        GuiControl, Show, Transc
        GuiControl, Show, TranscOK
        If (Tranc) {
            FormatTime, Now, % A_Now, yyyy/MM/dd 'at' HH:mm:ss
            CtlColors.Change(THCtrl, "008000", "FFFFFF")
            GuiControl, , Transc, % Now
            GuiControl, , TranscOK, Img\OK.png
            SetTimer, TranscHide, 1000
        } Else {
            CtlColors.Change(THCtrl, "CCCCCC")
            GuiControl, , Transc
            GuiControl, , TranscOK, Img\Idle.png
        }
    } Else {
        GuiControl, Hide, Transc
        GuiControl, Hide, TranscOK
    }
}

CheckLatestSells() {
    Global ProdDefs, SearchList := []
    GuiControl,, Search, |
    If FileExist("Dump\Last.sell") {
        Loop, Read, Dump\Last.sell
        {
            If (ProdDefs["" Trim(A_LoopReadLine, "`n") ""] != "") {
                GuiControl,, Search, % " -- " ProdDefs["" Trim(A_LoopReadLine, "`n") ""]["Name"] " -- "
                SearchList.Push("" A_LoopReadLine "")
            }
        }
    }
}

CalculateCurrent() {
    Global _37
    S := B := P := I := 0
    Loop, Files, Curr\*.sell
    {
        FileRead, Content, % A_LoopFileFullPath
        Content := StrSplit(StrSplit(Content, "> ")[2], "|")
        For Each, One in Content {
            F := StrSplit(One, ";")
            I += StrSplit(F[3], "x")[2]
            S += F[4]
            B += F[6]
            P += F[7]
        }
    }

    GuiControl,, ItemsSold, % I " " _37
    GuiControl,, SoldP, % S "`n" ConvertMillimsToDT(S)
    GuiControl,, CostP, % B "`n" ConvertMillimsToDT(B)
    GuiControl,, ProfitP, % P "`n" ConvertMillimsToDT(P)

    Return, [I, S, B, P]
}

LogIn(Username, Password) {
    If (FileExist("Sets\Acc.chu")) {
        Account := {}
        FileRead, RawAccount, Sets\Acc.chu
        TextAccount := b64Decode(RawAccount)

        For Each, User in StrSplit(TextAccount, ",") {
            LOG := StrSplit(User, "|")
            Account[LOG[1]] := [LOG[2], LOG[3], LOG[4]]
        }

        If (Account[Username][1] = Password) {
            If (Account[Username][3]) {
                UserPic := Account[Username][3]
            }
            If (Account[Username][2] = "Admin")
                Return, 1
            Else If (Account[Username][2] = "User")
                Return, 2
        }
    }
    Return, 0
}

b64Encode(string) {
    VarSetCapacity(bin, StrPut(string, "UTF-8")) && len := StrPut(string, &bin, "UTF-8") - 1 
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", 0, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    VarSetCapacity(buf, size << 1, 0)
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", &buf, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    return StrGet(&buf)
}

b64Decode(string) {
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", 0, "uint*", size, "ptr", 0, "ptr", 0))
        throw Exception("CryptStringToBinary failed", -1)
    VarSetCapacity(buf, size, 0)
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", &buf, "uint*", size, "ptr", 0, "ptr", 0))
        throw Exception("CryptStringToBinary failed", -1)
    return StrGet(&buf, size, "UTF-8")
}

GUISellHistory(Text) {
    FormatTime, OutTime, % A_Now, yyyy/MM/dd HH:mm:ss
    Obj := FileOpen("Hist\SellHistory.Hist", "a")
    Obj.WriteLine(OutTime " ==> " Text)
    Obj.Close()
}

FolderSet() {
    Array := [ "Curr"
    , "Sets"
    , "Sets\Def"
    , "Valid"
    , "Dump"
    , "Kr"
    , "CKr" 
    , "Unvalid" 
    , "Hist" ]

    For Every, Folder in Array {
        If !FolderExist(Folder) {
            FileCreateDir, % Folder
        }
    }
}

FolderExist(Folder) {
    Return InStr(FileExist(Folder), "D")
}

ThemeAdd() {
    Loop, 5 {
        Gui, Add, Text, % "y0 x" 208 + A_Index * 2 " w1 h" A_ScreenHeight " HwndHCtrl"
        CtlColors.Attach(HCtrl, "7D7D64")
    }
}

Message() {
    Global ProdDefs
    FileRead, Message, Sets\Message.Request
    If (Message = "Update_Definitions") {
        ProdDefs := LoadDefinitions()
    }
}

SetEditCueBanner(HWND, Cue) {
    Static EM_SETCUEBANNER := (0x1500 + 1)
    Return DllCall("User32.dll\SendMessageW", "Ptr", HWND, "Uint", EM_SETCUEBANNER, "Ptr", True, "WStr", Cue)
}

InsertLineAtStart(File, Text) {
    rText := FileOpen("Dump\Last.sell", "r").Read(5000)
    FileOpen("Dump\Last.sell", "w").Write(Text "`n" rText).Close()
}


================================================
FILE: GUISell_Hotkeys.ahk
================================================
#If WinActive("ahk_id " Main)
    Enter::
        GuiControlGet, Bc, , Bc
        GuiControl, Disabled, Bc
        If (!Selling) {
            Barcode := Bc
            If (ProdDefs["" Barcode ""]["Name"] != "")
            && (ProdDefs["" Barcode ""]["SellPrice"] != "") 
            && (ProdDefs["" Barcode ""]["Quantity"] != "") {
                Nm                  := ProdDefs["" Barcode ""]["Name"]
                SellPrice           := ProdDefs["" Barcode ""]["SellPrice"]
                ThisCurrQuantity    := ProdDefs["" Barcode ""]["Quantity"] ? ProdDefs["" Barcode ""]["Quantity"] : 0
                QuantitySumArg      := SellPrice "x1"

                JobDone             := 0
                Loop, % LV_GetCount() {
                    LV_GetText(ThisBc, Row := A_Index, 1)
                    If (ThisBc = Barcode) {
                        LV_GetText(AddedCurrQuantity, Row, 2), AddedCurrQuantity := StrSplit(AddedCurrQuantity, "  >>  ")
                        LV_GetText(AddedQuantitySumArg, Row, 4), AddedQuantitySumArg := StrSplit(AddedQuantitySumArg, "x"), QuantitySumArg := AddedQuantitySumArg[1] "x" AddedQuantitySumArg[2] + 1
                        LV_GetText(PreviousSum, Row, 5)
                        SellPrice := ProdDefs["" Barcode ""]["SellPrice"]
                        LV_Modify(Row,,, AddedCurrQuantity[1] "  >>  " AddedCurrQuantity[2] - 1,, QuantitySumArg, PreviousSum + SellPrice)
                        JobDone := 1
                        Break
                    }
                }
                If (!JobDone) {
                    LV_Add("", Barcode, ThisCurrQuantity "  >>  " ThisCurrQuantity - 1, Nm, QuantitySumArg, SellPrice)
                }
                CalculateSum()
                WriteSession()
                GuiControl, Enabled, AddUp
                GuiControl, Enabled, AddDown
                GuiControl, Enabled, AddSell
                GuiControl, Enabled, AddDelete
            }
        } Else {
            FormatTime, OutTime, % (Now := A_Now), yyyy/MM/dd HH:mm:ss
            SellOBJ := FileOpen(LastestSO := "Curr\" Now ".sell", "w")
            SellOBJ.Write(AdminName "|" OutTime)
            
            I := Sum := Cost := 0
            Loop, % LV_GetCount() {
                LV_GetText(Bc, A_Index, 1)
                LV_GetText(Qn, A_Index, 4)
                Qn := StrSplit(Qn, "x")[2]

                If (!Qn) || (!Bc) {
                    MsgBox, 16, % _13, % _160 "`nRow: " A_Index
                    Continue
                }

                ProdDefs["" Bc ""]["Quantity"] -= Qn

                FileRead, Content, % "Sets\Def\" Bc ".def"
                Content := StrSplit(Content, ";")

                DefObj := FileOpen("Sets\Def\" Bc ".def", "w")
                DefObj.Write(Content[1] ";" Content[2] ";" Content[3] ";" Content[4] - Qn)
                DefObj.Close()

                Name    := ProdDefs["" Bc ""]["Name"]
                SellStr := ProdDefs["" Bc ""]["SellPrice"] "x" Qn
                Sell    := ProdDefs["" Bc ""]["SellPrice"] * Qn
                Sum     += Sell
                BuyStr  := ProdDefs["" Bc ""]["BuyPrice"] "x" Qn
                Buy     := ProdDefs["" Bc ""]["BuyPrice"] * Qn

                Cost += Buy
                SellOBJ.Write(((A_Index > 1) ? "|" : "> ") Bc ";" Name ";" SellStr ";" Sell ";" BuyStr ";" Buy ";" Sell - Buy)

                I += Qn
                InsertLineAtStart("Dump\Last.sell", Bc)
            }
            
            SellOBJ.Write("> " Sum ";" Cost ";" Sum - Cost)
            SellOBJ.Close()
            
            If FileExist("Dump\Kridi.sell") {
                FileRead, Content, Dump\Kridi.sell
                If !InStr(FileExist("Kr\" Content), "D") {
                    FileCreateDir, % "Kr\" Content
                }
                FileMove, % LastestSO, % "Kr\" Content
                FileDelete, % "Dump\Kridi.sell"
                LastestSO := StrReplace(LastestSO, "Curr\", "Kr\" Content "\")
            }
            
            Selling := 0
            GuiControl, Disabled, AddEnter
            GuiControl, Disabled, AddUp
            GuiControl, Disabled, AddDown
            GuiControl, Disabled, AddSell
            GuiControl, Disabled, AddSubmit
            If (Level = 1)
                GuiControl, Disabled, SubKridi
            GuiControl, Disabled, AddDelete
            GuiControl, Disabled, Cancel
            
            GuiControl,, AllSum
            GuiControl,, Change
            GuiControl,, GivenMoney
            GuiControl, Hide, GivenMoney
            GuiControl, Hide, AllSum
            GuiControl, Hide, Change
            
            GuiControl, Show, Bc
            GuiControl, Show, AddEnter
            GuiControl, Show, Nm
            GuiControl, Show, Qn
            GuiControl, Show, Sum
            LV_Delete()
            
            WriteSession()
            CalculateSum()
            TrancsView(1, 1)
            CheckLatestSells()
            
            CurrentProfit[1] += I
            CurrentProfit[2] += Sum
            CurrentProfit[3] += Cost
            CurrentProfit[4] += Sum - Cost

            GuiControl,, ItemsSold, % (CurrentProfit[1]) " " _37
            GuiControl,, SoldP,     % (CurrentProfit[2]) "`n" ConvertMillimsToDT(CurrentProfit[2])
            GuiControl,, CostP,     % (CurrentProfit[3]) "`n" ConvertMillimsToDT(CurrentProfit[3])
            GuiControl,, ProfitP,   % (CurrentProfit[4]) "`n" ConvertMillimsToDT(CurrentProfit[4])
        }
        GuiControl, Enabled, Bc
        GuiControl, , Bc
        GuiControl, Focus, Bc
        Sleep, 125
    Return

    Space::
        GuiControlGet, FocusedControl, FocusV
        If (FocusedControl ~= "Client|SellDesc") {
            SendInput, {Space}
        } Else {
            If LV_GetCount() {
                SellView()
                AllSum := 0
                Loop, % LV_GetCount() {
                    LV_GetText(ThisAllSum, A_Index, 5)
                    AllSum += ThisAllSum
                }
                GuiControl, , AllSum, % AllSum
                GuiControl, Disabled, AddUp
                GuiControl, Disabled, AddDown
                GuiControl, Disabled, AddDelete
                GuiControl, Disabled, AddSell
                If (Level = 1)
                    GuiControl, Enabled, SubKridi
                GuiControl, Enabled, AddSubmit
                GuiControl, Enabled, Cancel
                GuiControl, Focus, GivenMoney
                CalculateSum()
                Selling := 1
            } Else {
                GuiControl, Focus, Bc
            }
        }
        Sleep, 125
    Return

    Left::
        If !(--Session) {
            Session += 10
        }

        Loop, 10 {
            If (A_Index = Session) {
                GuiControl, Disabled, Session%A_Index%
            } Else {
                GuiControl, Enabled, Session%A_Index%
            }
        }

        RestoreSession()
        CalculateSum()
        Sleep, 125
    Return

    Right::
        If (++Session = 11) {
            Session -= 10
        }

        Loop, 10 {
            If (A_Index = Session) {
                GuiControl, Disabled, Session%A_Index%
            } Else {
                GuiControl, Enabled, Session%A_Index%
            }
        }

        RestoreSession()
        CalculateSum()
        Sleep, 125
    Return

    Up::
        If (Row := LV_GetNext()) {
            LV_GetText(ThisQn, Row, 4)
            LV_GetText(ThisBc, Row, 1)
            VQ := StrSplit(ThisQn, "x")
            LV_Modify(Row,,, ProdDefs["" ThisBc ""]["Quantity"] "  >>  " ProdDefs["" ThisBc ""]["Quantity"] - (VQ[2] + 1),, VQ[1] "x" VQ[2] + 1, VQ[1] * (VQ[2] + 1))
        } Else If (Row := LV_GetCount()) {
            LV_GetText(ThisQn, Row, 4)
            LV_GetText(ThisBc, Row, 1)
            VQ := StrSplit(ThisQn, "x")
            LV_Modify(Row,,, ProdDefs["" ThisBc ""]["Quantity"] "  >>  " ProdDefs["" ThisBc ""]["Quantity"] - (VQ[2] + 1),, VQ[1] "x" VQ[2] + 1, VQ[1] * (VQ[2] + 1))
        }
        CalculateSum()
        WriteSession()
        Sleep, 125
    Return

    Down::
        GuiControlGet, Focused, FocusV
        If (Row := LV_GetNext()) {
            LV_GetText(ThisQn, Row, 4)
            LV_GetText(ThisBc, Row, 1)
            VQ := StrSplit(ThisQn, "x")
            If (VQ[2] > 1) {
                LV_Modify(Row,,, ProdDefs["" ThisBc ""]["Quantity"] "  >>  " ProdDefs["" ThisBc ""]["Quantity"] - (VQ[2] - 1),, VQ[1] "x" VQ[2] - 1, VQ[1] * (VQ[2] - 1))
            }
        } Else If (Row := LV_GetCount()) {
            LV_GetText(ThisQn, Row, 4)
            LV_GetText(ThisBc, Row, 1)
            VQ := StrSplit(ThisQn, "x")
            If (VQ[2] > 1) {
                LV_Modify(Row,,, ProdDefs["" ThisBc ""]["Quantity"] "  >>  " ProdDefs["" ThisBc ""]["Quantity"] - (VQ[2] - 1),, VQ[1] "x" VQ[2] - 1, VQ[1] * (VQ[2] - 1))
            }
        }
        CalculateSum()
        WriteSession()
        Sleep, 125
    Return

    Delete::
        If (LV_GetCount()) {
            If (Row := LV_GetNext()) {
                LV_Delete(Row)
                CalculateSum()
            } Else {
                LV_Delete(1)
                CalculateSum()
            }
            If (!LV_GetCount()) {
                GuiControl, Disabled, AddEnter
                GuiControl, Disabled, AddUp
                GuiControl, Disabled, AddDown
                GuiControl, Disabled, AddSell
                GuiControl, Disabled, AddSubmit
                GuiControl, Disabled, SubKridi
                GuiControl, Disabled, AddDelete
                GuiControl, Disabled, Cancel
                LV_Delete()
                GuiControl, Focus, Bc
            }
        }
        WriteSession()
        Sleep, 125
    Return

    Esc::
        If (Selling) {
            Selling := 0
            
            GuiControl, Disabled, AddEnter
            GuiControl, Disabled, AddUp
            GuiControl, Disabled, AddDown
            GuiControl, Disabled, AddSell
            GuiControl, Disabled, AddSubmit
            GuiControl, Disabled, SubKridi
            GuiControl, Disabled, AddDelete
            GuiControl, Disabled, Cancel
            
            GuiControl,, AllSum
            GuiControl,, Change
            GuiControl,, GivenMoney
            GuiControl, Hide, GivenMoney
            GuiControl, Hide, AllSum
            GuiControl, Hide, Change

            GuiControl,, Bc
            GuiControl, Show, Bc
            GuiControl, Show, AddEnter
            GuiControl, Show, Nm
            GuiControl, Show, Qn
            GuiControl, Show, Sum
            ;LV_Delete()
            GuiControl, Focus, Bc
            WriteSession()
            CalculateSum()
        }
        CheckLatestSells()
        Sleep, 125
    Return

    ^F::
        GuiControlGet, Bc,, Bc
        GuiControl,, Search, |
        SearchList := []
        For Every, Product in ProdDefs {
            If InStr(Product["Name"], Bc) {
                SearchList.Push("" Every "")
                GuiControl, , Search, % Product["Name"]
            }
        }
        Sleep, 125
    Return

    Tab::
        If (Level = 1) {
            GuiControlGet, Visi, Visible, ItemsSold
            Action := (Visi) ? "Hide" : "Show"

            GuiControl, % Action, ItemsSold
            GuiControl, % Action, SoldP
            GuiControl, % Action, CostP
            GuiControl, % Action, ProfitP
        } Else {
            SendInput, {Tab}
        }
        Sleep, 125
    Return
#If

================================================
FILE: GUISell_Labels.ahk
================================================
GuiClose:
    IniDelete, Sets\PID.ini, PID, GUISell
ExitApp

LaunchKeyboard:
    Run, osk.exe
Return

SubKridi:
    Obj := FileOpen("Dump\tmp.sell", "w")
    Loop, % LV_GetCount() {
        LV_GetText(C1, A_Index, 1)
        LV_GetText(C2, A_Index, 2)
        LV_GetText(C3, A_Index, 3)
        LV_GetText(C4, A_Index, 4)
        LV_GetText(C5, A_Index, 5)
        Obj.Write(C1 "," C2 "," C3 "," C4 "," C5 "`n")
    }
    Obj.Close()

    RunWait, % "GUIKridi" (A_IsCompiled ? ".exe" : ".ahk")
    GoSub, Enter
Return

Calc:
    GuiControlGet, GivenMoney,, GivenMoney
    GuiControlGet, AllSum,, AllSum
    GuiControl, , Change

    Change := GivenMoney - AllSum
    If GivenMoney is Digit
    {
        GuiControl, , Change, % (Change >= 0) ? Change : 0
    }
Return

AnalyzeAvail:
    GuiControlGet, Bc,, Bc
    If (Bc != "") {
        If (ProdDefs.HasKey("" Bc "")) {
            GuiControl, , Nm,   % ProdDefs["" Bc ""]["Name"]
            GuiControl, , Qn,   % ProdDefs["" Bc ""]["Quantity"]
            GuiControl, , Sum,  % ProdDefs["" Bc ""]["SellPrice"]
            GuiControl, Enabled, AddEnter
        } Else {
            GuiControl, , Nm
            GuiControl, , Sum
            GuiControl, , Qn
            GuiControl, Disabled, AddEnter
        }
    } Else {
        GuiControl, , Nm
        GuiControl, , Sum
        GuiControl, , Qn
        GuiControl, Disabled, AddEnter
    }
Return

Remise:
    GuiControlGet, Remise, , Remise
    If (Remise > 100) 
        GuiControl, , Remise, % Remise := ""
    CalculateSum()
Return

Client:
    SellDesc:
        CalculateSum()
    Return
Return

AdditionalInfo:
    If (AdditionalInfo := !AdditionalInfo) {
        GuiControl, Enabled, Remise
        GuiControl, Enabled, Client
        GuiControl, Enabled, SellDesc
        GuiControl, ,AdditionalInfoPic, % "Img\MIE.png"
    } Else {
        GuiControl, Disabled, Remise
        GuiControl, Disabled, Client
        GuiControl, Disabled, SellDesc
        GuiControl, ,AdditionalInfoPic, % "Img\MID.png"
    }
    CalculateSum()
Return

ViewLastTrans:
    If (LastestSO) {
        Run, % "GUIDetails" (A_IsCompiled ? ".exe" : ".ahk") " " LastestSO
    }
Return

Session1:
    Session := 1
    Loop, 10 {
        If (A_Index = 1) {
            GuiControl, Disabled, Session%A_Index%
        } Else {
            GuiControl, Enabled, Session%A_Index%
        }
    }

    RestoreSession()
    CalculateSum()
Return

Session2:
    Session := 2
    Loop, 10 {
        If (A_Index = 2) {
            GuiControl, Disabled, Session%A_Index%
        } Else {
            GuiControl, Enabled, Session%A_Index%
        }
    }

    RestoreSession()
    CalculateSum()
Return

Session3:
    Session := 3
    Loop, 10 {
        If (A_Index = 3) {
            GuiControl, Disabled, Session%A_Index%
        } Else {
            GuiControl, Enabled, Session%A_Index%
        }
    }

    RestoreSession()
    CalculateSum()
Return

Session4:
    Session := 4
    Loop, 10 {
        If (A_Index = 4) {
            GuiControl, Disabled, Session%A_Index%
        } Else {
            GuiControl, Enabled, Session%A_Index%
        }
    }

    RestoreSession()
    CalculateSum()
Return

Session5:
    Session := 5
    Loop, 10 {
        If (A_Index = 5) {
            GuiControl, Disabled, Session%A_Index%
        } Else {
            GuiControl, Enabled, Session%A_Index%
        }
    }

    RestoreSession()
    CalculateSum()
Return

Session6:
    Session := 6
    Loop, 10 {
        If (A_Index = 6) {
            GuiControl, Disabled, Session%A_Index%
        } Else {
            GuiControl, Enabled, Session%A_Index%
        }
    }

    RestoreSession()
    CalculateSum()
Return

Session7:
    Session := 7
    Loop, 10 {
        If (A_Index = 7) {
            GuiControl, Disabled, Session%A_Index%
        } Else {
            GuiControl, Enabled, Session%A_Index%
        }
    }

    RestoreSession()
    CalculateSum()
Return

Session8:
    Session := 8
    Loop, 10 {
        If (A_Index = 8) {
            GuiControl, Disabled, Session%A_Index%
        } Else {
            GuiControl, Enabled, Session%A_Index%
        }
    }

    RestoreSession()
    CalculateSum()
Return

Session9:
    Session := 9
    Loop, 10 {
        If (A_Index = 9) {
            GuiControl, Disabled, Session%A_Index%
        } Else {
            GuiControl, Enabled, Session%A_Index%
        }
    }

    RestoreSession()
    CalculateSum()
Return

Session10:
    Session := 10
    Loop, 10 {
        If (A_Index = 10) {
            GuiControl, Disabled, Session%A_Index%
        } Else {
            GuiControl, Enabled, Session%A_Index%
        }
    }

    RestoreSession()
    CalculateSum()
Return

WriteToBc:
    GuiControlGet, Search,, Search
    If (Search) {
        GuiControl,, Bc, % SearchList[Search]
    }
Return

TranscHide:
    If (++CountToHide = 30) {
        SetTimer, TranscHide, Off
        CountToHide := 0
        GuiControl, Hide, Transc
        GuiControl, Hide, TranscOK
    }
Return

================================================
FILE: GUISubmit.ahk
================================================
#Requires AutoHotkey v1.1
#SingleInstance, Force
SetBatchLines, -1
SetWorkingDir, % A_ScriptDir

#Include, Lib\Classes\Class_CtlColors.ahk
#Include, Lib\Classes\Class_ImageButton.ahk
#Include, Lib\Classes\Class_GDIplus.ahk

#Include, Lib\Language.ahk

FolderSet()

If !Level := LogIn(AdminName := A_Args[1], AdminPass := A_Args[2]) {
    FileRead, Reciever, Sets\Login.Hwnd
    FileOpen("Sets\Login.Request", "w").Write("Run|" A_ScriptFullPath).Close()
    SendMessage, 0x1000,,,, ahk_id %Reciever%
    Sleep, 1000
    MsgBox, 16, % _112, % _114
    ExitApp
}

Gui, +HwndMain +Resize
Gui, Add, Pic, % "x0 y0", Img\BG.png
Gui, Margin, 10, 10
Gui, Color, 0x7D7D3A
Gui, Font, s14 Bold, Calibri

Gui, Add, Text, % "xm+5 ym w190 vProfByProductText BackgroundTrans", % _202 ":"
Gui, Add, DDL, xp yp+30 wp vProfByProduct gShowTheInfo AltSubmit, % _203 "||" _204

Gui, Add, Text, % "wp vProfByNameText BackgroundTrans", % _156 ":"
Gui, Add, DDL, xp yp+30 wp vProfByName gShowTheInfo

Gui, Add, Text, % "wp vDatesText BackgroundTrans", % _72 ":"
Gui, Font, Italic
Gui, Add, ListBox, % "0x100 wp h" A_ScreenHeight - 330 " vDates HwndHCtrl gShowTheInfo Multi"
CtlColors.Attach(HCtrl, "D8D8AD", "404000")

Gui, Font, Norm
Gui, Font, s15 Bold

qw := ((A_ScreenWidth - 255) / 2)

ButtonTheme := [[3, 0x80FF80, 0x5ABB5A, 0x000000, 2,, 0x008000, 1]
              , [3, 0x44DB44, 0x2F982F, 0x000000, 2,, 0x008000, 1]
              , [3, 0x1AB81A, 0x107410, 0x000000, 2,, 0x008000, 1]
              , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]

Gui, Add, Button, % "x" A_ScreenWidth - 327 " ym+40 vEnsBtn w300 h40 HwndHCtrl gValid", % _9
ImageButton.Create(HCtrl, ButtonTheme*)

Gui, Font, s12 Italic
Gui, Add, Edit, % "xm+220 yp+10 w" qw " vOverview -E0x200 HwndHCtrl"
CtlColors.Attach(HCtrl, "000000", "FFFF00")

Gui, Font, Norm
Gui, Font, s15 Bold
Gui, Add, ListView, % "w" (qw * 2) " h" A_ScreenHeight - 240 " vLV Grid gShowDetails HwndHCtrl BackgroundE6E6E6 -Multi", % _70 "|" _71 "|" _39 "|" _40 "|" _41 "|" _79

LV_ModifyCol(1, "0")
LV_ModifyCol(2, qw)
LV_ModifyCol(3, 0)
LV_ModifyCol(4, 0)
LV_ModifyCol(5, 0)
LV_ModifyCol(6, qw)

Gui, Font, s20
Gui, Add, Edit, % "xm+220 y" A_ScreenHeight - 132 " w" (qw * 2) / 3 " vSold Center -E0x200 ReadOnly cGreen Border HwndHCtrl"
CtlColors.Attach(HCtrl, "EAEAB5", "404000")
Gui, Font, s15
Gui, Add, Button, xm+5 yp w190 gChart vChart HwndHCtrl h40, % "→ " _173 " ←"
ImageButton.Create(HCtrl, ButtonTheme*)

Gui, Font, s20
Gui, Add, Edit, % "xp+" (qw * 2)/3 + 215 " yp w" (qw * 2) / 3 " h40 vBought -E0x200 ReadOnly Center cRed Border HwndHCtrl"
CtlColors.Attach(HCtrl, "EAEAB5", "FF0000")
Gui, Add, Edit, % "xp+" (qw * 2)/3 " yp wp hp vProfitEq -E0x200 ReadOnly Center cGreen Border HwndHCtrl"
CtlColors.Attach(HCtrl, "EAEAB5", "008000")
ThemeAdd()

Gui, Font, s12
Levels := ["Admin", "User"]
View := ["Normal", "More Details"]
Gui, Add, StatusBar
SB_SetParts(10, 200, 200)
SB_SetText(_206 ": " AdminName, 2)
SB_SetText(_207 ": " Levels[Level], 3)
Gui, Show, Maximize, Submit GUI
Global LVContent, Header := 1
LoadAllSells()
AnalyzeUsers()
AnalyzeDates()
GuiControl, Choose, Dates, |1
Return

#Include, GUISubmit_Hotkeys.ahk
#Include, GUISubmit_Functions.ahk
#Include, GUISubmit_Labels.ahk

================================================
FILE: GUISubmit_Functions.ahk
================================================
ThemeAdd() {
    Loop, 5 {
        Gui, Add, Text, % "y0 x" 208 + A_Index * 2 " w1 h" A_ScreenHeight " HwndHCtrl"
        CtlColors.Attach(HCtrl, "7D7D64")
    }
}

LogIn(Username, Password) {
    If (FileExist("Sets\Acc.chu")) {
        Account := {}
        FileRead, RawAccount, Sets\Acc.chu
        TextAccount := b64Decode(RawAccount)

        For Each, User in StrSplit(TextAccount, ",") {
            LOG := StrSplit(User, "|")
            Account[LOG[1]] := [LOG[2], LOG[3]]
        }

        If (Account[Username][1] = Password) {
            If (Account[Username][2] = "Admin")
                Return, 1
            Else If (Account[Username][2] = "User")
                Return, 2
        }
    }
    Return, 0
}

b64Encode(string) {
    VarSetCapacity(bin, StrPut(string, "UTF-8")) && len := StrPut(string, &bin, "UTF-8") - 1 
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", 0, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    VarSetCapacity(buf, size << 1, 0)
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", &buf, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    return StrGet(&buf)
}

b64Decode(string) {
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", 0, "uint*", size, "ptr", 0, "ptr", 0))
        throw Exception("CryptStringToBinary failed", -1)
    VarSetCapacity(buf, size, 0)
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", &buf, "uint*", size, "ptr", 0, "ptr", 0))
        throw Exception("CryptStringToBinary failed", -1)
    return StrGet(&buf, size, "UTF-8")
}

ConvertMillimsToDT(Value, Sign := "") {
    If (Value = "..." || !Value)
        Return
    ValueArr := StrSplit(Value / 1000, ".")
    Return, "[" (Sign ? Sign " " : "") ValueArr[1] (ValueArr[2] ? "." RTrim(ValueArr[2], 0) : "") " DT]"
}

AddToList(File, DataSum) {
    FileRead, Content, % File
    SplitPath, % File, OutFileName
    Date := SubStr(OutFileName, 1, 8)
    DataAll  := StrSplit(Content, "> ")

    DateUser := StrSplit(DataAll[1], "|")
    If (DateUser.Length() = 2) && !LVContent["Users"].HasKey("" DateUser[1] "") {
        LVContent["Users"]["" DateUser[1] ""] := ""
    }

    Data     := StrSplit(DataAll[3], ";")
    If (Data[1] Data[2] Data[3] ~= "\b\d+\b") {
        Names := "", Items := {}
        For Each, Prod in StrSplit(Trim(DataAll[2], "|"), "|") {
            Info := StrSplit(Prod, ";")
            If !Items.HasKey("" Info[1] "") {
                Items["" Info[1] ""] := [Info[2], 0, 0, 0, 0]
            }
            Items["" Info[1] ""][2] += StrSplit(Info[3], "x")[2]
            Items["" Info[1] ""][3] += Info[4]
            Items["" Info[1] ""][4] += Info[6]
            Items["" Info[1] ""][5] += Info[7]
            Names .= Names ? " | " Info[2] : Info[2]
        }

        C1 := ["" Date "", File]
        C2 := DateUser
        C3 := "+ " Data[1] " " ConvertMillimsToDT(Data[1], "+")
        C4 := "- " Data[2] " " ConvertMillimsToDT(Data[2], "+")
        C5 := "+ " Data[3] " " ConvertMillimsToDT(Data[3], "+")
        C6 := Names
        C7 := Items
        C8 := Data

        LVContent["Lines"].Push([C1, C2, C3, C4, C5, C6, C7, C8])
        If !LVContent["Dates"].HasKey("" Date "") {
            LVContent["Dates"]["" Date ""] := ""
        }
    }
}

LoadAllSells() {
    DataSum     := [0, 0, 0]
    LVContent   := { "Lines"  : []
                   , "Users"  : {}
                   , "Dates"  : {} }

    GuiControl,, Sold
    GuiControl,, Bought
    GuiControl,, ProfitEq
    Loop, Files, Curr\*.sell, R
        DataSum := AddToList(A_LoopFileFullPath, DataSum)
}

AnalyzeUsers() {
    Global _74
    GuiControl,, ProfByName, |
    GuiControl,, ProfByName, % _74
    For User in LVContent["Users"] {
        GuiControl,, ProfByName, % User
    }
    GuiControl, Choose, ProfByName, 1
}

AnalyzeDates() {
    GuiControl,, Dates, |
    For Date in LVContent["Dates"] {
        FormatTime, ThisDay, % Date, yyyy/MM/dd
        GuiControl,, Dates, % "-- " ThisDay " --"
    }
}

UpdateHeaders() {
    Global
    LV_Delete()
    If (ProfByProduct = 1) && (Header = 2) {
        For Each, Title in [[_70, 0], [_71, qw], [_39, 0], [_40, 0], [_41, 0], [_79, qw]]
            LV_ModifyCol(Each, Title[2], Title[1])
        Header := 1
    } 
    If (ProfByProduct = 2) && (Header = 1) {
        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"]]
            LV_ModifyCol(Each, Title[2] Title[3], Title[1])
        Header := 2
    }
}

UpdateSumValues(DataSum) {
    GuiControl,, Sold, % "+ " DataSum[1] " " ConvertMillimsToDT(DataSum[1], "+")
    GuiControl,, Bought, % "- " DataSum[2] " " ConvertMillimsToDT(DataSum[2], "-")
    GuiControl,, ProfitEq, % "+ " DataSum[3] " " ConvertMillimsToDT(DataSum[3], "+")
}

FolderSet() {
    Array := [ "Curr"
    , "Sets"
    , "Sets\Def"
    , "Valid"
    , "Dump"
    , "Kr"
    , "CKr" 
    , "Unvalid" 
    , "Hist" ]

    For Every, Folder in Array {
        If !FolderExist(Folder) {
            FileCreateDir, % Folder
        }
    }
}

FolderExist(Folder) {
    Return InStr(FileExist(Folder), "D")
}

================================================
FILE: GUISubmit_Hotkeys.ahk
================================================


================================================
FILE: GUISubmit_Labels.ahk
================================================
Valid:
    MsgBox, 33, % _174, % _175
    IfMsgBox, OK
    {
        FileCreateDir, % "Valid\" (Now := A_Now)
        Loop, % LV_GetCount() {
            LV_GetText(File, A_Index, 1)
            FileMove, % File, % "Valid\" Now
        }
        LoadAllSells()
        AnalyzeUsers()
        AnalyzeDates()
    }
Return

Chart:
    GuiControl, Disabled, Chart
    GuiControlGet, ProfByProduct,, ProfByProduct
    If (ProfByProduct = 1){
        If (RowCount := LV_GetCount()) {
            Dummy := {}
            Loop, % RowCount {
                LV_GetText(F, A_Index, 1)
                LV_GetText(S, A_Index, 3)
                LV_GetText(B, A_Index, 4)
                LV_GetText(P, A_Index, 5)

                SplitPath, % F,,,, O

                RegExMatch(S, "\d+", S)
                RegExMatch(B, "\d+", B)
                RegExMatch(P, "\d+", P)

                If !Dummy.HasKey("" (O := SubStr(O, 1, 8)) "") {
                    Dummy["" O ""] := [0, 0, 0]
                }

                Dummy["" O ""][1] += S
                Dummy["" O ""][2] += B
                Dummy["" O ""][3] += P
            }

            Dates   := ""
            Sells   := ""
            Costs   := ""
            Profits := ""

            For Each, Date in Dummy {
                FormatTime, D, % Each, yyyy/MM/dd
                Dates   .= Dates   != ""  ? ",'"  D "'"    : "'" D "'"
                Sells   .= Sells   != ""  ? ","  Date[1]   : Date[1]
                Costs   .= Costs   != ""  ? ","  Date[2]   : Date[2]
                Profits .= Profits != ""  ? ","  Date[3]   : Date[3] 
            }
            Dates   := "[" Dates   "]"
            Sells   := "[" Sells   "]"
            Costs   := "[" Costs   "]"
            Profits := "[" Profits "]"

            FileCopy, HighChart\template\Chart.html, Template.html, 1
            FileCopy, HighChart\template\Chart.css, Template.css, 1
            FileCopy, HighChart\template\Chart.js, Template.js, 1

            FileRead, JS, Template.js

            JS := StrReplace(JS, "'[CASH_HELPER_DATES_HOLDER]'", Dates)
            JS := StrReplace(JS, "'[CASH_HELPER_SELLS_HOLDER]'", Sells)
            JS := StrReplace(JS, "'[CASH_HELPER_BUYS_HOLDER]'", Costs)
            JS := StrReplace(JS, "'[CASH_HELPER_PROFITS_HOLDER]'", Profits)

            FileOpen("Template.js"  , "w").Write(JS).Close()
            Run, Template.html
        }
    }
    GuiControl, Enabled, Chart
Return

ShowDetails:
    GuiControlGet, ProfByProduct,, ProfByProduct
    If !(Row := LV_GetNext()) || ProfByProduct = 2
        Return
    LV_GetText(FileName, Row, 1)
    Run, % "GUIDetails." (A_IsCompiled ? "exe" : "ahk") " " FileName
Return

ShowTheInfo:
    GuiControlGet, ProfByProduct,, ProfByProduct
    GuiControlGet, ProfByName,, ProfByName
    GuiControlGet, Dates,, Dates

    GuiControl,, Overview, % View[ProfByProduct] " | " ProfByName " | " Dates

    ProfByName := (ProfByName = _74) ? "" : ProfByName
    UpdateHeaders()

    DataSum := [0, 0, 0]
    Info    := {}
    If (ProfByProduct = 1) {
        For Each, Line in LVContent["Lines"] {
            FormatTime, ThisDay, % SubStr(Line[1][1], 1, 8), '--' yyyy/MM/dd '--'
            UName := (Line[2].Length() = 2) ? Line[2][1] : ""

            If InStr(Dates, ThisDay) && InStr(UName, ProfByName) {
                LV_Add(, Line[1][2], Line[2][1] (Line[2][2] ? " | " Line[2][2] : ""), Line[3], Line[4], Line[5], Line[6])
                DataSum[1] += Line[8][1]
                DataSum[2] += Line[8][2]
                DataSum[3] += Line[8][3]
                UpdateSumValues(DataSum)
            }
        }
    }

    If (ProfByProduct = 2) {
        For Each, Line in LVContent["Lines"] {
            FormatTime, ThisDay, % SubStr(Line[1][1], 1, 8), '--' yyyy/MM/dd '--'
            UName := (Line[2].Length() = 2) ? Line[2][1] : ""
            If InStr(Dates, ThisDay) && InStr(UName, ProfByName) {
                For Barcode, Detail in Line[7] {
                    If !Info.HasKey("" Barcode "") {
                        Info["" Barcode ""] := [LV_Add(, Barcode, Detail[1], Detail[2], Detail[3], Detail[4], Detail[5])
                                              , Detail[1]
                                              , Detail[2]
                                              , Detail[3]
                                              , Detail[4]
                                              , Detail[5]]
                    } Else {
                        Info["" Barcode ""][3] += Detail[2]
                        Info["" Barcode ""][4] += Detail[3]
                        Info["" Barcode ""][5] += Detail[4]
                        Info["" Barcode ""][6] += Detail[5]
                        LV_Modify(Info["" Barcode ""][1],,,, Info["" Barcode ""][3], Info["" Barcode ""][4], Info["" Barcode ""][5], Info["" Barcode ""][6])
                    }
                }
                DataSum[1] += Line[8][1]
                DataSum[2] += Line[8][2]
                DataSum[3] += Line[8][3]
                UpdateSumValues(DataSum)
            }
        }
    }
Return

GuiClose:
    IniDelete, Sets\PID.ini, PID, GUISubmit
ExitApp

================================================
FILE: GUIUpdate.ahk
================================================
#Requires AutoHotkey v1.1
#SingleInstance, Force
SetBatchLines, -1
#NoEnv
SetWorkingDir, % A_ScriptDir

Gui, Font, Bold s12, Consolas
Gui, +HwndMain -Border +Resize
FileRead, Version, LVersion.txt
Gui, Add, Text, w300 Center, % "Cash Helper v" Version
Gui, Add, Text, w300 Center vDownloadInfo cRed
Gui, Add, Progress, xp yp+50 wp h15 +0x00000008 HwndPB -Smooth
DllCall("User32.dll\SendMessage", "Ptr", PB, "Int", 0x00000400 + 10, "Ptr", 1, "Ptr", 50)
SetTimer, CheckSize, 1000
Gui, Show
Return

CheckSize:
    FileGetSize, Size, % A_Temp "\Install.exe", B
    GuiControl,, DownloadInfo, % "↓ " Round(Size/1000000, 2) " mb..."
Return

GuiClose:
ExitApp

================================================
FILE: GUIUser.ahk
================================================
#Requires AutoHotkey v1.1
#SingleInstance, Force
SetBatchLines, -1
SetWorkingDir, % A_ScriptDir

#Include, Lib\Classes\Class_CtlColors.ahk
#Include, Lib\Classes\Class_ImageButton.ahk
#Include, Lib\Classes\Class_GDIplus.ahk

#Include, Lib\Language.ahk

FolderSet()

If !Level := LogIn(AdminName := A_Args[1], AdminPass := A_Args[2]) {
    FileRead, Reciever, Sets\Login.Hwnd
    FileOpen("Sets\Login.Request", "w").Write("Run|" A_ScriptFullPath).Close()
    SendMessage, 0x1000,,,, ahk_id %Reciever%
    Sleep, 1000
    MsgBox, 16, % _112, % _114
    ExitApp
}

Gui, +HwndMain +Resize
Gui, Add, Pic, % "x0 y0", Img\BG.png
Gui, Margin, 10, 10
Gui, Color, 0x7D7D3A
Gui, Font, s12 Bold, Calibri

ButtonTheme := [[3, 0x80FF80, 0x5ABB5A, 0x000000, 2,, 0x008000, 1]
              , [3, 0x44DB44, 0x2F982F, 0x000000, 2,, 0x008000, 1]
              , [3, 0x1AB81A, 0x107410, 0x000000, 2,, 0x008000, 1]
              , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0x999999, 1]]

ButtonTheme2 := [[3, 0xFF6F6F, 0xBC5454, 0x000000, 2,, 0xFF0000, 1]
               , [3, 0xDC6262, 0x9C4545, 0x000000, 2,, 0xFF0000, 1]
               , [3, 0xBF5454, 0x8A3C3C, 0x000000, 2,, 0xFF0000, 1]
               , [3, 0xCCCCCC, 0xCCCCCC, 0x000000, 2,, 0xFF0000, 1]]
qw := (A_ScreenWidth - 20) / 3
Gui, Add, GroupBox, % "BackgroundTrans xm+5 ym w" qw " h" A_ScreenHeight - 100, % _156

Gui, Add, Button, % "HwndHCtrl xp+" qw - 320 " yp+30 w150 gAddUser h30", % _89 " [++]"
ImageButton.Create(HCtrl, ButtonTheme* )

Gui, Add, Button, % "HwndHCtrl xp+160 yp wp gDelUser h30", % _91 " [--]"
ImageButton.Create(HCtrl, ButtonTheme2* )

Gui, Add, ListView, % "AltSubmit xm+15 ym+65 w" qw - 20 " h" A_ScreenHeight - 180 " gShowInfo c804000", % _38 "|" _88 "|" _207
LV_ModifyCol(1, (qw-20) / 3)
LV_ModifyCol(2, (qw-20) / 3)
LV_ModifyCol(3, (qw-20) / 3)
Gui, Add, GroupBox, % "BackgroundTrans xm+" qw + 10 " ym w" qw " h" A_ScreenHeight - 100, % _211
Gui, Add, Text, xp+10 yp+30 BackgroundTrans, % _214 ": "
Gui, Add, Pic, % "xp+" ((qw - 220) / 2) " yp+30 w200 h200 vUserPic Border BackgroundTrans gChooseAPic", Img\UserLogo.png
Gui, Add, Text, % "xp-" ((qw - 220) / 2) " yp+220 BackgroundTrans" , % _87 ": "
Gui, Add, Edit, % "vUN w" qw - 20 " -E0x200 Border cGreen"
Gui, Add, Text, BackgroundTrans , % _88 ": "
Gui, Add, Edit, % "w" qw - 20 " vPW -E0x200 Border cRed"
Gui, Add, Text, BackgroundTrans , % _207 ": "
Gui, Add, DDL, % "w" qw - 20 " vLVL -E0x200 Border", %_212%|%_213%
Gui, Add, Button, % "HwndHCtrl xp yp+50 wp gSaveChanges h30", % _62
ImageButton.Create(HCtrl, ButtonTheme* )

Gui, Add, GroupBox, % "BackgroundTrans xm+" (qw + 8) * 2 " ym w" qw - 15 " h" A_ScreenHeight - 100, % _215
Gui, Add, CheckBox, % "BackgroundTrans Center xp+10 yp+30 wp-20", % _216
Gui, Add, CheckBox, % "BackgroundTrans Center wp", % _222
Gui, Add, CheckBox, % "BackgroundTrans Center wp", % _223
Gui, Add, CheckBox, % "BackgroundTrans Center wp", % _217
Gui, Add, CheckBox, % "BackgroundTrans Center wp", % _218
Gui, Add, CheckBox, % "BackgroundTrans Center wp", % _219
Gui, Add, CheckBox, % "BackgroundTrans Center wp", % _220
Gui, Add, CheckBox, % "BackgroundTrans Center wp", % _221

Global UserList
LoadAccounts()

Gui, Font, s12
Levels := ["Admin", "User"]
Gui, Add, StatusBar
SB_SetParts(10, 200, 200)
SB_SetText(_206 ": " AdminName, 2)
SB_SetText(_207 ": " Levels[Level], 3)
Gui, Show, Maximize, GUI User
Return

#Include, GUIUser_Functions.ahk
#Include, GUIUser_Hotkeys.ahk
#Include, GUIUser_Labels.ahk

================================================
FILE: GUIUser_Functions.ahk
================================================
FolderSet() {
    Array := [ "Curr"
             , "Sets"
             , "Sets\Def"
             , "Valid"
             , "Dump"
             , "Kr"
             , "CKr" 
             , "Unvalid" 
             , "Hist" ]

    For Every, Folder in Array {
        If !FolderExist(Folder) {
            FileCreateDir, % Folder
        }
    }
}

FolderExist(Folder) {
    Return InStr(FileExist(Folder), "D")
}

LogIn(Username, Password) {
    If (FileExist("Sets\Acc.chu")) {
        Account := {}
        FileRead, RawAccount, Sets\Acc.chu
        TextAccount := b64Decode(RawAccount)
        
        For Each, User in StrSplit(TextAccount, ",") {
            LOG := StrSplit(User, "|")
            Account[LOG[1]] := [LOG[2], LOG[3]]
        }
        
        If (Account[Username][1] = Password) {
            If (Account[Username][2] = "Admin")
                Return, 1
            Else If (Account[Username][2] = "User")
                Return, 2
        }
    }
    Return, 0
}

UpdateAccounts() {
    Data := ""
    For User, Info in UserList {
        Data .= Data != "" ? "," User "|" Info[1] "|" Info[2] (Info[3] != "" ? "|" Info[3] : "") : User "|" Info[1] "|" Info[2] (Info[3] != "" ? "|" Info[3] : "")
    }
    If (Data != "")
        FileOpen("Sets\Acc.chu", "w").Write(b64Encode(Data)).Close()
    Else {
        FileDelete, Sets\Acc.chu
        FileDelete, Sets\RAcc.chu
        FileRead, Reciever, Sets\Login.Hwnd
        FileOpen("Sets\Login.Request", "w").Write("Reload").Close()
        SendMessage, 0x1000,,,, ahk_id %Reciever%
        ExitApp
    }
}

LoadAccounts() {
    UserList := {}
    LV_Delete()
    If FileExist("Sets\Acc.chu") {
        FileRead, RawAccount, Sets\Acc.chu
        Account := b64Decode(RawAccount)
        For Every, Acc in StrSplit(Account, ",") {
            Info := StrSplit(Acc, "|")
            UserList[Info[1]] := [Info[2], Info[3], Info[4]]
            LV_Add(, Info[1], Info[2], Info[3])
        }
    }
}

NoAdminsLeft(Nm) {
    tmp := UserList
    tmp.Delete(Nm)
    For User, Info in tmp {
        If (Info[2] = "ADMIN") {
            Return, 0
        }
    }
    Return, 1
}

b64Encode(string) {
    VarSetCapacity(bin, StrPut(string, "UTF-8")) && len := StrPut(string, &bin, "UTF-8") - 1 
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", 0, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    VarSetCapacity(buf, size << 1, 0)
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", &buf, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    return StrGet(&buf)
}

b64Decode(string) {
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", 0, "uint*", size, "ptr", 0, "ptr", 0))
        throw Exception("CryptStringToBinary failed", -1)
    VarSetCapacity(buf, size, 0)
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", &buf, "uint*", size, "ptr", 0, "ptr", 0))
        throw Exception("CryptStringToBinary failed", -1)
    return StrGet(&buf, size, "UTF-8")
}

================================================
FILE: GUIUser_Hotkeys.ahk
================================================
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


================================================
FILE: GUIUser_Labels.ahk
================================================
ShowInfo:
    If (R := LV_GetNext()) {
        LV_GetText(Nm, R, 1)
        LV_GetText(Pw, R, 2)
        LV_GetText(Lv, R, 3)
        GuiControl,, UN, % Nm
        GuiControl,, PW, % Pw
        GuiControl, ChooseString, LVL, % Lv
        If (UserList[Nm][3]) {
            GuiControl,, UserPic, % UserList[Nm][3]
        } Else {
            GuiControl,, UserPic, Img\UserLogo.png
        }
    }
Return

DelUser:
    If (R := LV_GetNext()) {
        LV_GetText(Nm, R, 1)
        If NoAdminsLeft(Nm) {
            MsgBox, 33, % _174, % _224
            IfMsgBox, Cancel
                Return
        }
        MsgBox, 33, % _174, % _91 " '" Nm "'"
        IfMsgBox, OK
        {
            UserList.Delete(Nm)
            UpdateAccounts()
            LoadAccounts()
        }
    }
Return

AddUser:
    InputBox, UN, % _87, % _87,, 300, 130
    InputBox, PW, % _88, % _88,, 300, 130
    LVL := "USER"
    
    If (UN != "") && (PW != "") && !UserList.HasKey(UN) {
        UserList[UN] := [PW, LVL]
        UpdateAccounts()
        LoadAccounts()
    } Else {
        Msgbox, 16, % _13, % _225
    }
Return

SaveChanges:
    GuiControlGet, UN,, UN
    GuiControlGet, PW,, PW
    GuiControlGet, LVL,, LVL
    
    If (R := LV_GetNext()) && (UN != "" && UN = Nm) && (PW != "") {
        UserList[Nm][1] := PW
        UserList[Nm][2] := LVL
        UpdateAccounts()
        LoadAccounts()
    } Else {
        Msgbox, 16, % _13, % _225
    }
Return

ChooseAPic:
    if !(R := LV_GetNext()) {
        Return
    }
    LV_GetText(Nm, R, 1)
    FileSelectFile, UserPic
    iF (UserPic != "") {
        GuiControl,, UserPic, % UserPic
        SplitPath, % UserPic,,, OutExt
        FileCopy, % UserPic, % "Img\Users\" Nm "." OutExt, 1
        UserList[Nm][3] := "Img\Users\" Nm "." OutExt
    } Else {
        GuiControl,, UserPic, Img\UserLogo.png
        FileDelete, % UserList[Nm][3]
        UserList[Nm].RemoveAt(3)
    }
Return

GuiClose:
    IniDelete, Sets\PID.ini, PID, GUIUser
ExitApp

================================================
FILE: GenerateRelease.ahk
================================================
#Requires AutoHotkey v1.1
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
SetBatchLines, -1

#Persistent
#SingleInstance, Force

7zipExitCode:= {  0	    : "No error"
                , 1	    : "Warning (Non fatal error(s)). For example, one or more files were locked by some other application, so they were not compressed."
                , 2	    : "Fatal error"
                , 7	    : "Command line error"
                , 8	    : "Not enough memory for operation"
                , 255	: "User stopped the process"}

Gui, Add, ListBox, w100 r10 vCompileAHK, % "StartUp"
                                        . "|Import"
                                        . "|GUIUser"
                                        . "|GUISubmit"
                                        . "|GUISell"
                                        . "|GUIReview"
                                        . "|GUIKridiM"
                                        . "|GUIKridi"
                                        . "|GUIDetails"
                                        . "|GUIDefine"
                                        . "|GUIUpdate"
                                        . "|Uninstall"

Gui, Add, ListBox, xp+110 wp hp vCopyRES, % "Img"
                                         . "|Lib"

Gui, Add, ListBox, xp+110 wp hp vCompressF, % "HighChart"
                                           . "|CH-Install"

Gui, Add, Button, xm wp gCompileSel, Compile
Gui, Add, Button, xp yp+25 wp gCompileAll, Compile All

Gui, Add, Button, xp+110 yp-25 wp gCopySel, Copy
Gui, Add, Button, xp yp+25 wp gCopyAll, Copy All

Gui, Add, Button, xp+110 yp-25 wp gCompressSel, Compress
Gui, Add, Button, xp yp+25 wp gCompressAll, Compress All

Gui, Add, Edit, xm w320 vLog -VScroll -HScroll ReadOnly
FileRead, Version, Version.txt
Gui, Add, Edit, Center cRed vVersion w100, % Version 
Gui, Add, Button, wp, Prepare All
Gui, Show,, Create a release
Return

CompileSel:
    GuiControlGet, CompileAHK
    If (CompileAHK) {
        For Each, Script in StrSplit(CompileAHK, "|") {
            CompileScript(Script)
        }
    }
Return

CompileAll:
    CompileScript("StartUp")
    CompileScript("Import")
    CompileScript("GUIUser")
    CompileScript("GUISubmit")
    CompileScript("GUISell")
    CompileScript("GUIReview")
    CompileScript("GUIKridiM")
    CompileScript("GUIKridi")
    CompileScript("GUIDetails")
    CompileScript("GUIDefine")
    CompileScript("GUIUpdate")
    CompileScript("Uninstall")
Return

CopySel:
    GuiControlGet, CopyRES
    If (CopyRES)
        PrepareResource(CopyRES)
Return

CopyAll:
    PrepareResource("Img")
    PrepareResource("Lib")
Return

CompressSel:
    GuiControlGet, CompressF
    Switch CompressF {
        Case "HighChart":
            GuiControl,, Log, Compressing into HighChart...
            FileDelete, __Release\HighChart.zip
            RunWait, %ComSpec% /c __Compiler\7za.exe a -aoa __Release\HighChart.zip HighChart\
            If (ErrorLevel) {
                Msgbox, 16, Error, % "Error Code: " ErrorLevel "`n" 7zipExitCode[ErrorLevel]
            } ELse {
                GuiControl,, Log, Compressing into HighChart.zip... - OK!
            }
        Return

        Case "CH-Install":
            GuiControl,, Log, Compressing into CH-Install.zip...
            FileDelete, __Release\CH-Install.zip
            FileDelete, __Release\Install.exe
            GuiControlGet, Version
            FileOpen("Version.txt", "w").Write(Version).Close()
            FileCopy, Version.txt, __Release\Version.txt, 1
            RunWait, %ComSpec% /c cd __Release && ..\__Compiler\7za.exe a -aoa CH-Install.zip *
            If (E := ErrorLevel) {
                Msgbox, 16, Error, % "Error Code: " E "`n" 7zipExitCode[E]
            } ELse {
                GuiControl,, Log, Compressing into CH-Install.zip... - OK!
            }
        Return
    }
Return

CompressAll:
    GuiControl,, Log, Compressing into HighChart...
    FileDelete, __Release\HighChart.zip
    RunWait, %ComSpec% /c __Compiler\7za.exe a -aoa __Release\HighChart.zip HighChart\
    If (ErrorLevel) {
        Msgbox, 16, Error, % "Error Code: " ErrorLevel "`n" 7zipExitCode[ErrorLevel]
    } ELse {
        GuiControl,, Log, Compressing into HighChart.zip... - OK!
    }
    
    GuiControl,, Log, Compressing into CH-Install.zip...
    FileDelete, __Release\CH-Install.zip
    FileDelete, __Release\Install.exe
    GuiControlGet, Version
    FileOpen("Version.txt", "w").Write(Version).Close()
    FileCopy, Version.txt, __Release\Version.txt, 1
    RunWait, %ComSpec% /c cd __Release && ..\__Compiler\7za.exe a -aoa CH-Install.zip *
    If (ErrorLevel) {
        Msgbox, 16, Error, % "Error Code: " ErrorLevel "`n" 7zipExitCode[ErrorLevel]
    } ELse {
        GuiControl,, Log, Compressing into CH-Install.zip... - OK!
    }
Return

ButtonPrepareAll:
    GoSub, CompileAll
    GoSub, CopyAll
    GoSub, CompressAll
    CompileScript("Install")
    GuiControl,, Log, %A_ScriptDir%\__Release\Install.exe
Return

GuiClose:
ExitApp

CompileScript(AHKName, MoveTo := "") {
    GuiControlGet, Log
    RunWait, % """__Compiler\Ahk2Exe.exe"""
             . " /in   """    AHKName ".ahk"""
             . " /out  """    AHKName ".exe"""
             . " /icon "      (FileExist(AHKName ".ico") ? AHKName ".ico" : "Default.ico")
             . " /base ""__Compiler\Unicode 32-bit.bin"""
    If (!ErrorLevel) {
        GuiControl,, Log, % "Compiling " AHKName " - OK!"
        If (!MoveTo)
            FileMove, %AHKName%.exe, __Release\%AHKName%.exe, 1
        Else 
            FileMove, %AHKName%.exe, __Release\%AHKName%.exe, 1
    }
    Else
        Msgbox, 16, Error, % "Compiling " AHKName ".ahk... - ERROR!"
}

PrepareResource(Element) {
    GuiControl,, Log, % "Copying " Element "..."
    Sleep, 250
    If !InStr(FileExist(Element), "D") {
        FileCopy, % Element, % "__Release\" Element, 1
    } Else {
        FileCopyDir, % Element, % "__Release\" Element, 1
    }
    If (!ErrorLevel)
        GuiControl,, Log, % "Copying " Element ".. - OK!"
    Else
        Msgbox, 16, Error, % "Copying " Element "... - ERROR!"
}

================================================
FILE: Import.ahk
================================================
#Requires AutoHotkey v1.1
#SingleInstance, Force
SetBatchLines, -1
SetWorkingDir, % A_ScriptDir

Gui, Font, Bold s10, Consolas
Gui, Add, Button, w300 gImportAccounts, 1 - Import Accounts
Gui, Add, Button, wp gImportRAccounts Disabled, 2 - Import Remembered Account
Gui, Add, Button, wp gImportPD, 3 - Import Product Definitions
Gui, Add, Button, wp gImportKridi, 4 - Import Kridis
Gui, Add, Button, wp gImportKridiKO, 5 - Import Kridis From Kridi Organizer
Gui, Add, Button, wp gImportSells, 6 - Import Sells
Gui, Show,, Load Custom Setting
Return

GuiClose:
ExitApp

;---------------------------

ImportKridiKO:
    FileSelectFolder, Folder
    If (Folder) {
        InputBox, Responsable, Responsable, Responsable User Name,, 300, 120
        If (Responsable != "") {
            Loop, Files, % Folder "\*.txt"
            {
                FileRead, CurrentAmount, % A_LoopFileFullPath
                If (CurrentAmount = "")
                    Continue
                SplitPath, % A_LoopFileFullPath,,,, Name
                Name := Trim(Name, " ")
                If !InStr(FileExist("Kr\" Name), "D") {
                    FileCreateDir, % "Kr\" Name
                }
                If (CurrentAmount != "") {
                    Result := Eval(CurrentAmount)
                    Amount := StrJoin(Result, "`n")
                    FormatTime, OutTime, % Now := A_Now, yyyy/MM/dd HH:mm:ss
                    FileOpen("Kr\" Name "\" Now ".sell", "w").Write(Responsable "|" OutTime "> > " Amount ";" Amount ";0").Close()
                }
                
            }
        }
    Msgbox, % "OK"
    Run, Kr
    }
Return

ImportRAccounts:
    FileSelectFile, File,,, Select Remembered Account File
    If (File) {
        Out .= StrReplace(DB_Read(File), ";", "|")
        Msgbox % "Data to be encoded:`n" Out
        FileOpen("Sets\RAcc.chu", "w").Write(b64Encode(Out)).Close()
    }
Return

ImportAccounts:
    FileSelectFile, File,,, Select Accounts File
    If (File) {
        Out := ""
        A := StrSplit(DB_Read(File), ";")
        A.RemoveAt(1)
        
        Out .= A[1] "|" A[2] "|Admin"
        
        Loop, 2
            A.RemoveAt(1)
            
        For Each, Element in A {
            UP := StrSplit(Element, "/")
            Out .= "," UP[1] "|" UP[2] "|User"
        }
        
        Msgbox % "Data to be encoded:`n" Out
        
        If !InStr(FileExist("Sets"), "D") {
            FileCreateDir, Sets
        }
        
        FileOpen("Sets\Acc.chu", "w").Write(b64Encode(Out)).Close()
        Msgbox % "OK"
        Run, Sets
    }
Return

ImportSells:
    FileSelectFolder, Folder
    If (Folder) {
        SplitPath, % Folder,,,, oFolder
        FileCopyDir, % Folder, % oFolder, 1
        Run, % oFolder
        Msgbox % "Copied:`n-> " Folder "`n-> " oFolder
        
        Loop, Files, %oFolder%\*.db, R
        {
            RD := DB_Read(A_LoopFileFullPath)
            If (RD) {
                SplitPath, % A_LoopFileFullPath,, OutDir,, OutNameNoExt
                FileOpen(OutDir "\" OutNameNoExt ".sell", "w").Write(RD).Close()
            }
        }
        
        Loop, Files, %oFolder%\*.db, R
            FileDelete, % A_LoopFileFullPath
        Msgbox % "OK"
    }
Return

ImportKridi:
    FileSelectFolder, Folder
    If (Folder) {
        Folders := []
        Loop, Files, %Folder%\*, D
            Folders.Push(A_LoopFileFullPath)

        If !InStr(FileExist("Kr"), "D") {
            FileCreateDir, % "Kr"
        }
        
        For Every, Dir in Folders {
            SplitPath, % Dir, OutFileName, OutDir
            Msgbox % "Moving:`n-> " Dir "`n-> Kr\" DecodeAlpha(OutFileName)
            FileCopyDir, % Dir, % "Kr\" DecodeAlpha(OutFileName)
        }
        Msgbox % "OK"
        Run, Kr
    }
Return

ImportPD:
    FileSelectFile, File
    If (File) {
        SplitPath, % File,, OutDir

        If !InStr(FileExist("Sets\Def"), "D") {
            FileCreateDir, % "Sets\Def"
        }
        
        Msgbox % "Data to be encoded:`n" Out := DB_Read(File)
        
        For each, one in StrSplit(DB_Read(File), "|") {
            _one := StrSplit(one, ";")
            If (_one[1] && _one[2] && _one[3] && _one[4]) {
                FileOpen("Sets\Def\" _one[1] ".def", "w").Write(_one[2] ";" _one[3] ";" _one[4] ";" (_one[5] ? _one[5] : 0)).Close()
            }
        }
        Msgbox % "OK"
        Run, Sets\Def
    }
Return

b64Encode(string) {
    VarSetCapacity(bin, StrPut(string, "UTF-8")) && len := StrPut(string, &bin, "UTF-8") - 1 
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", 0, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    VarSetCapacity(buf, size << 1, 0)
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", &buf, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    return StrGet(&buf)
}

DB_Read(FileName, FastMode := 0) {
    DBObj := FileOpen(FileName, "r")
    If !(FastMode) {
        Hedr := ""
        Loop, 14 {
            Hedr .= Chr(DBObj.ReadChar())
        }
        If (Hedr != "CH-26259084-DB")
            Return, 0
        Info := ""
        DBObj.Pos := 1024
        Loop {
            Info .= (ThisChar := Chr(DBObj.ReadChar()))
        } Until (ThisChar = "")
    } Else {
        DBObj.RawRead(Data, Len := DBObj.Length())
        Pos := 1023, Info := ""
        While (Byte := NumGet(Data, Pos += 1, "Char")) {
            Info .= Chr(Byte)
        }
        DBObj.Close()
    }
Return, Decode(Info)
}

Decode(string) {
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", 0, "uint*", size, "ptr", 0, "ptr", 0))
        Return
    VarSetCapacity(buf, size, 0)
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", &buf, "uint*", size, "ptr", 0, "ptr", 0))
        Return
return, StrGet(&buf, size, "UTF-8")
}

DecodeAlpha(Str) {
    DecStr := ""
    Loop, Parse, Str
    {
        If (A_LoopField ~= "[B-Zb-z]") || (A_LoopField ~= "[1-9]")
            DecStr .= Chr(Asc(A_LoopField) - 1)
        Else If (A_LoopField = "A")
            DecStr .= Chr(Asc(A_LoopField) + 25)
        Else If (A_LoopField = "0")
            DecStr .= "9"
        Else
            DecStr .= A_LoopField
    }
Return, DecStr
}

Encode(string) {
    VarSetCapacity(bin, StrPut(string, "UTF-8")) && len := StrPut(string, &bin, "UTF-8") - 1
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", 0, "uint*", size))
        Return
    VarSetCapacity(buf, size << 1, 0)
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", &buf, "uint*", size))
        Return
return, StrGet(&buf)
}

EncodeAlpha(Str) {
    EncStr := ""
    Loop, Parse, Str
    {
        If (A_LoopField ~= "[A-Ya-y]") || (A_LoopField ~= "[0-8]")
            EncStr .= Chr(Asc(A_LoopField) + 1)
        Else If (A_LoopField = "Z")
            EncStr .= Chr(Asc(A_LoopField) - 25)
        Else If (A_LoopField = "9")
            EncStr .= "0"
        Else
            EncStr .= A_LoopField
    }
Return, EncStr
}

;=======================================================================================
;
; Function:			Eval
; Description:		Evaluate Expressions in Strings.
; Return value:		An array (object) with the result of each expression.
;
; Author:			Pulover [Rodolfo U. Batista]
; Credits:			ExprEval() by Uberi
;
;=======================================================================================
;
; Parameters:
;
;	$x:				The input string to be evaluated. You can enter multiple expressions
;						separated by commas (inside the string).
;	_CustomVars:	An optional Associative Array object containing variables names
;					  as keys and values to replace them.
;					For example, setting it to {A_Index: A_Index} inside a loop will replace
;						occurrences of A_Index with the correct value for the iteration.
;	_Init:			Used internally for the recursive calls. If TRUE it resets the static
;						object _Objects, which holds objects references to be restored.
;
;=======================================================================================
Eval($x, _CustomVars := "", _Init := true)
{
	Static _Objects, $Quote := Chr(2)
	_Elements := {}
	If (_Init)
		_Objects := {}
	
	; Strip off comments
	$x := RegExReplace($x, "U)/\*.*\*/"), $x := RegExReplace($x, "U)\s;.*(\v|$)")
	
	; Replace brackets, braces, parenthesis and literal strings
	
	While (RegExMatch($x, "sU)"".*""", _String))
		_Elements["&_String" A_Index "_&"] := _String
	,	$x := RegExReplace($x, "sU)"".*""", "&_String" A_Index "_&",, 1)
	While (RegExMatch($x, "\[([^\[\]]++|(?R))*\]", _Bracket))
		_Elements["&_Bracket" A_Index "_&"] := _Bracket
	,	$x := RegExReplace($x, "\[([^\[\]]++|(?R))*\]", "&_Bracket" A_Index "_&",, 1)
	While (RegExMatch($x, "\{[^\{\}]++\}", _Brace))
		_Elements["&_Brace" A_Index "_&"] := _Brace
	,	$x := RegExReplace($x, "\{[^\{\}]++\}", "&_Brace" A_Index "_&",, 1)
	While (RegExMatch($x, "\(([^()]++|(?R))*\)", _Parent))
		_Elements["&_Parent" A_Index "_&"] := _Parent
	,	$x := RegExReplace($x, "\(([^()]++|(?R))*\)", "&_Parent" A_Index "_&",, 1)
	
	; Split multiple expressions
	$z := StrSplit($x, ",", " `t")
	
	For $i, $v in $z
	{
		; Check for Ternary expression and evaluate
		If (RegExMatch($z[$i], "([^\?:=]+?)\?([^\?:]+?):(.*)", _Match))
		{
			Loop, 3
			{
				$o := A_Index, _Match%$o% := Trim(_Match%$o%)
			,	_Match%$o% := RestoreElements(_Match%$o%, _Elements)
			}
			EvalResult := Eval(_Match1, _CustomVars, false)
		,	$y := EvalResult[1]
			If ($y)
			{
				EvalResult := Eval(_Match2, _CustomVars, false)
			,	$y := StrJoin(EvalResult,, true, false)
			,	ObjName := RegExReplace(_Match2, "\W", "_")
				If (IsObject($y))
					_Objects[ObjName] := $y
				$z[$i] := StrReplace($z[$i], _Match, IsObject($y) ? """<~#" ObjName "#~>""" : $y)
			}
			Else
			{
				EvalResult := Eval(_Match3, _CustomVars, false)
			,	$y := StrJoin(EvalResult,, true, false)
			,	ObjName := RegExReplace(_Match3, "\W", "_")
				If (IsObject($y))
					_Objects[ObjName] := $y
				$z[$i] := StrReplace($z[$i], _Match, IsObject($y) ? """<~#" ObjName "#~>""" : $y)
			}
		}
		
		_Pos := 1
		; Check for Object calls
		While (RegExMatch($z[$i], "([\w%]+)(\.|&_Bracket|&_Parent\d+_&)[\w\.&%]+(.*)", _Match, _Pos))
		{
			AssignParse(_Match, VarName, Oper, VarValue)
			If (Oper != "")
			{
				VarValue := RestoreElements(VarValue, _Elements)
			,	EvalResult := Eval(VarValue, _CustomVars, false)
			,	VarValue := StrJoin(EvalResult)
				If (!IsObject(VarValue))
					VarValue := RegExReplace(VarValue, """{2,2}", """")
			}
			Else
				_Match := StrReplace(_Match, _Match3), VarName := _Match

			VarName := RestoreElements(VarName, _Elements)
			
			If _Match1 is Number
			{
				_Pos += StrLen(_Match1)
				continue
			}
			
			$y := ParseObjects(VarName, _CustomVars, Oper, VarValue)
		,	ObjName := RegExReplace(_Match, "\W", "_")
			
			If (IsObject($y))
				_Objects[ObjName] := $y
			Else If $y is not Number
			{
				$y := """" StrReplace($y, """", $Quote) """"
			,	HidString := "&_String" (ObjCount(_Elements) + 1) "_&"
			,	_Elements[HidString] := $y
			,	$y := HidString
			}
			$z[$i] := StrReplace($z[$i], _Match, IsObject($y) ? """<~#" ObjName "#~>""" : $y,, 1)
		}
		
		; Assign Arrays
		While (RegExMatch($z[$i], "&_Bracket\d+_&", $pd))
		{
			$z[$i] := StrReplace($z[$i], $pd, _Elements[$pd],, 1)
		,	RegExMatch($z[$i], "\[(.*)\]", _Match)
		,	_Match1 := RestoreElements(_Match1, _Elements)
		,	$y := Eval(_Match1, _CustomVars, false)
		,	ObjName := RegExReplace(_Match, "\W", "_")
		,	_Objects[ObjName] := $y
		,	$z[$i] := StrReplace($z[$i], _Match, """<~#" ObjName "#~>""")
		}
		
		; Assign Associative Arrays
		While (RegExMatch($z[$i], "&_Brace\d+_&", $pd))
		{
			$y := {}, o_Elements := {}
		,	$o := _Elements[$pd]
		,	$o := RestoreElements($o, _Elements)
		,	$o := SubStr($o, 2, -1)
			While (RegExMatch($o, "sU)"".*""", _String%A_Index%))
				o_Elements["&_String" A_Index "_&"] := _String%A_Index%
			,	$o := RegExReplace($o, "sU)"".*""", "&_String" A_Index "_&", "", 1)
			While (RegExMatch($o, "\[([^\[\]]++|(?R))*\]", _Bracket))
				o_Elements["&_Bracket" A_Index "_&"] := _Bracket
			,	$o := RegExReplace($o, "\[([^\[\]]++|(?R))*\]", "&_Bracket" A_Index "_&",, 1)
			While (RegExMatch($o, "\{[^\{\}]++\}", _Brace))
				o_Elements["&_Brace" A_Index "_&"] := _Brace
			,	$o := RegExReplace($o, "\{[^\{\}]++\}", "&_Brace" A_Index "_&",, 1)
			While (RegExMatch($o, "\(([^()]++|(?R))*\)", _Parent))
				o_Elements["&_Parent" A_Index "_&"] := _Parent
			,	$o := RegExReplace($o, "\(([^()]++|(?R))*\)", "&_Parent" A_Index "_&",, 1)
			Loop, Parse, $o, `,, %A_Space%%A_Tab%
			{
				$o := StrSplit(A_LoopField, ":", " `t")
			,	$o.1 := RestoreElements($o.1, o_Elements)
			,	$o.2 := RestoreElements($o.2, o_Elements)
			,	EvalResult := Eval($o.2, _CustomVars, false)
			,	$o.1 := Trim($o.1, """")
			,	$y[$o.1] := EvalResult[1]
			}
			ObjName := RegExReplace(_Match, "\W", "_")
		,	_Objects[ObjName] := $y
		,	$z[$i] := StrReplace($z[$i], $pd, """<~#" ObjName "#~>""")
		}
		
		; Restore and evaluate any remaining parenthesis
		While (RegExMatch($z[$i], "&_Parent\d+_&", $pd))
		{
			_oMatch := StrSplit(_Elements[$pd], ",", " `t()")
		,	_Match := RegExReplace(_Elements[$pd], "\((.*)\)", "$1")
		,	_Match := RestoreElements(_Match, _Elements)
		,	EvalResult := Eval(_Match, _CustomVars, false)
		,	RepString := "("
			For _i, _v in EvalResult
			{
				ObjName := RegExReplace($pd . _i, "\W", "_")
				If (IsObject(_v))
					_Objects[ObjName] := _v
				Else If _v is not Number
				{
					If (_oMatch[_i] != "")
					{
						_v := """" StrReplace(_v, """", $Quote) """"
					,	HidString := "&_String" (ObjCount(_Elements) + 1) "_&"
					,	_Elements[HidString] := _v
					,	_v := HidString
					}
				}
				RepString .= (IsObject(_v) ? """<~#" ObjName "#~>""" : _v) ", "
			}
			RepString := RTrim(RepString, ", ") ")"
		,	$z[$i] := StrReplace($z[$i], $pd, RepString,, 1)
		}
		
		; Check whether the whole string is an object
		$y := $z[$i]
		Try
		{
			If (_CustomVars.HasKey($y))
			{
				If (IsObject(_CustomVars[$y]))
				{
					ObjName := RegExReplace($y, "\W", "_")
				,	_Objects[ObjName] := _CustomVars[$y].Clone()
				,	$z[$i] := """<~#" ObjName "#~>"""
				}
			}
			Else If (IsObject(%$y%))
			{
				ObjName := RegExReplace($y, "\W", "_")
			,	_Objects[ObjName] := %$y%.Clone()
			,	$z[$i] := """<~#" ObjName "#~>"""
			}
		}

		; Check for {} object assignment
		If (RegExMatch($z[$i], "\{\s*\}", _Match))
		{
			$y := Object()
		,	ObjName := "_emptyObj"
		,	_Objects[ObjName] := $y
		,	$z[$i] := StrReplace($z[$i], _Match, """<~#" ObjName "#~>""")
		}
		
		; Check for Functions
		While (RegExMatch($z[$i], "s)([\w%]+)\((.*?)\)", _Match))
		{
			_Match1 := (RegExMatch(_Match1, "^%(\S+)%$", $pd)) ? %$pd1% : _Match1
		,	_Match2 := RestoreElements(_Match2, _Elements)
		,	_Params := Eval(_Match2, _CustomVars)
		,	$y := %_Match1%(_Params*)
		,	ObjName := RegExReplace(_Match, "\W", "_")
			If (IsObject($y))
				_Objects[ObjName] := $y
			Else If $y is not Number
			{
				$y := """" StrReplace($y, """", $Quote) """"
			,	HidString := "&_String" (ObjCount(_Elements) + 1) "_&"
			,	_Elements[HidString] := $y
			,	$y := HidString
			}
			$z[$i] := StrReplace($z[$i], _Match, IsObject($y) ? """<~#" ObjName "#~>""" : $y,, 1)
		}
		
		; Dereference variables in percent signs
		While (RegExMatch($z[$i], "U)%(\S+)%", _Match))
			EvalResult := Eval(_Match1, _CustomVars, false)
		,	$z[$i] := StrReplace($z[$i], _Match, EvalResult[1])
		
		; ExprEval() cannot parse Unicode strings, so the "real" strings are "hidden" from ExprCompile() and restored later
		$z[$i] := RestoreElements($z[$i], _Elements)
	,	__Elements := {}, _Pos := 1
		While (RegExMatch($z[$i], "sU)""(.*)""", _String, _Pos))
		{
			If (RegExMatch($z[$i], "sU)^""({.*})""$", _Brace))
				__Elements["&_String" A_Index "_&"] := _Brace1
			,	$z[$i] := RegExReplace($z[$i], "sU)^""{.*}""$", "&_String" A_Index "_&",, 1)
			Else If (RegExMatch($z[$i], "sU)^""([.*])""$", _Bracket))
				__Elements["&_String" A_Index "_&"] := _Bracket1
			,	$z[$i] := RegExReplace($z[$i], "sU)^""[.*]""$", "&_String" A_Index "_&",, 1)
			Else If (!RegExMatch(_String1, "^<~#.*#~>$"))
				__Elements["&_String" A_Index "_&"] := _String1
			,	$z[$i] := RegExReplace($z[$i], "sU)"".*""", "&_String" A_Index "_&",, 1)
			_Pos++
		}
		$z[$i] := RegExReplace($z[$i], "&_String\d+_&", """$0""")
		
		; Add concatenate operator after strings where necessary
		While (RegExMatch($z[$i], "(""&_String\d+_&""\s+)([^\d\.,\s:\+-=*/&|^><\?])"))
			$z[$i] := RegExReplace($z[$i], "(""&_String\d+_&""\s+)([^\d\.,\s:\+-=*/&|^><\?])", "$1. $2")
		
		; Remove remaining parenthesis to allow math operations
		While (RegExMatch($z[$i], "\(([^()]++|(?R))*\)"))
			$z[$i] := RegExReplace($z[$i], "\(([^()]++|(?R))*\)", "$1")
		
		; Evaluate right hand of assignments
		AssignParse($z[$i], _InVar, _OnOper, _OutValue)
		If ((!InStr(_OutValue, "&_String")) && (!RegExMatch(_OutValue, "^""<~#.*#~>""$")) && (_InVar && _OnOper && _OutValue))
			$z[$i] := _InVar . _OnOper . Eval(_OutValue, _CustomVars, false)[1]

		; Evaluate parsed expression with ExprEval()
		ExprInit()
	,	CompiledExpression := ExprCompile($z[$i])
	,	$Result := ExprEval(CompiledExpression, _CustomVars, _Objects, __Elements)
	,	$Result := StrSplit($Result, Chr(1))
		
		; Restore object references
		For _i, _v in $Result
		{
			If (RegExMatch(_v, "^<~#(.*)#~>$", $pd))
				$Result[_i] := _Objects[$pd1]
		}
		
		$z[$i] := StrJoin($Result,, false, _Init, _Init)
	}
	
	; If returning to the original call, remove missing expressions from the array
	If (_Init)
	{
		$x := StrSplit($x, ",", " `t")
		For _i, _v in $x
		{
			If (_v = "")
				$z.Delete(_i)
		}
	}

	return $z
}

ParseObjects(v_String, _CustomVars := "", o_Oper := "", o_Value := "")
{
	Static _needle := "([\w%]+\.?|\(([^()]++|(?R))*\)\.?|\[([^\[\]]++|(?R))*\]\.?)"
	
	l_Matches := [], _Pos := 1
	While (_Pos := RegExMatch(v_String, _needle, l_Found, _Pos))
		l_Matches.Push(RegExMatch(RTrim(l_Found, "."), "^%(\S+)%$", $pd) ? %$pd1% : RTrim(l_Found, "."))
	,	_Pos += StrLen(l_Found)
	v_Obj := l_Matches[1]
	If (_CustomVars.HasKey(v_Obj))
		_ArrayObject := _CustomVars[v_Obj]
	Else
		Try _ArrayObject := %v_Obj%
	For $i, $v in l_Matches
	{
		If (RegExMatch($v, "^\((.*)\)$"))
			continue
		If (RegExMatch($v, "^\[(.*)\]$", l_Found))
			_Key := Eval(l_Found1, _CustomVars, false)
		Else
			_Key := [$v]
		$n := l_Matches[$i + 1]
		If (RegExMatch($n, "^\((.*)\)$", l_Found))
		{
			_Key := _Key[1]
		,	_Params := Eval(l_Found1, _CustomVars, false)
			
			Try
			{
				If ($i = 1)
					_ArrayObject := %_Key%(_Params*)
				Else
					_ArrayObject := _ArrayObject[_Key](_Params*)
			}
			Catch e
			{
				If (InStr(e.Message, "0x800A03EC"))
				{
					; Workaround for strange bug in some Excel methods
					For _i, _v in _Params
						_Params[_i] := " " _v
				
					If ($i = 1)
						_ArrayObject := %_Key%(_Params*)
					Else
						_ArrayObject := _ArrayObject[_Key](_Params*)
				}
				Else
					Throw e
			}
		}
		Else If (($i = l_Matches.Length()) && (o_Value != ""))
		{
			Try
			{
				If (o_Oper = ":=")
					_ArrayObject := _ArrayObject[_Key*] := o_Value ? o_Value : false
				Else If (o_Oper = "+=")
					_ArrayObject := _ArrayObject[_Key*] += o_Value ? o_Value : false
				Else If (o_Oper = "-=")
					_ArrayObject := _ArrayObject[_Key*] -= o_Value ? o_Value : false
				Else If (o_Oper = "*=")
					_ArrayObject := _ArrayObject[_Key*] *= o_Value ? o_Value : false
				Else If (o_Oper = "/=")
					_ArrayObject := _ArrayObject[_Key*] /= o_Value ? o_Value : false
				Else If (o_Oper = "//=")
					_ArrayObject := _ArrayObject[_Key*] //= o_Value ? o_Value : false
				Else If (o_Oper = ".=")
					_ArrayObject := _ArrayObject[_Key*] .= o_Value ? o_Value : false
				Else If (o_Oper = "|=")
					_ArrayObject := _ArrayObject[_Key*] |= o_Value ? o_Value : false
				Else If (o_Oper = "&=")
					_ArrayObject := _ArrayObject[_Key*] &= o_Value ? o_Value : false
				Else If (o_Oper = "^=")
					_ArrayObject := _ArrayObject[_Key*] ^= o_Value ? o_Value : false
				Else If (o_Oper = ">>=")
					_ArrayObject := _ArrayObject[_Key*] >>= o_Value ? o_Value : false
				Else If (o_Oper = "<<=")
					_ArrayObject := _ArrayObject[_Key*] <<= o_Value ? o_Value : false
			}
		}
		Else If ($i > 1)
			_ArrayObject := _ArrayObject[_Key*]
	}
	return _ArrayObject
}

RestoreElements(_String, _Elements)
{
	While (RegExMatch(_String, "&_\w+_&", $pd))
		_String := StrReplace(_String, $pd, _Elements[$pd])
	return _String
}

AssignParse(String, ByRef VarName, ByRef Oper, ByRef VarValue)
{
	RegExMatch(String, "(.*?)(:=|\+=|-=|\*=|/=|//=|\.=|\|=|&=|\^=|>>=|<<=)(?=([^""]*""[^""]*"")*[^""]*$)(.*)", Out)
,	VarName := Trim(Out1), Oper := Out2, VarValue := Trim(Out4)
}

StrJoin(InputArray, JChr := "", Quote := false, Init := true, Unquote := false)
{
	static $Quote := Chr(2)
	For i, v in InputArray
	{
		If (IsObject(v))
			return v
		If v is not Number
		{
			If (!Init)
				v := RegExReplace(v, """{1,2}", """""")
			If (Quote)
				v := """" v """"
			If (Unquote)
				While (RegExMatch(v, """{2}"))
					v := RegExReplace(v, """{2}", """")
			v := StrReplace(v, $Quote, """")
		}
		JoinedStr .= v . JChr
	}
	If (JChr != "")
		JoinedStr := SubStr(JoinedStr, 1, -(StrLen(JChr)))
	return JoinedStr
}

ObjCount(Obj)
{
	return NumGet(&Obj + 4 * A_PtrSize)
}

;##################################################
; Author: Uberi
; Modified by: Pulover
; http://autohotkey.com/board/topic/64167-expreval-evaluate-expressions/
;##################################################
ExprInit()
{
	global
	Exprot:="`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)
	Sort,Exprol,FExprols
}

ExprCompile(e)
{
	e:=Exprt(e)
	Loop,Parse,e,% Chr(1)
	{
		lf:=A_LoopField,tt:=SubStr(lf,1,1),to:=SubStr(lf,2)
		If tt=f
		Exprp1(s,lf)
		Else If lf=,
		{
			While,s<>""&&Exprp3(s)<>"("
			Exprp1(ou,Exprp2(s))
		}
		Else If tt=o
		{
			While,SubStr(so:=Exprp3(s),1,1)="o"
			{
				ta:=Expras(to),tp:=Exprpr(to),sop:=Exprpr(SubStr(so,2))
				If ((ta="L"&&tp>sop)||(ta="R"&&tp>=sop))
				Break
				Exprp1(ou,Exprp2(s))
			}
			Exprp1(s,lf)
		}
		Else If lf=(
		Exprp1(s,"(")
		Else If lf=)
		{
			While,Exprp3(s)<>"("
			{
				If s=
				Return
				Exprp1(ou,Exprp2(s))
			}
			Exprp2(s)
			If (SubStr(Exprp3(s),1,1)="f")
			Exprp1(ou,Exprp2(s))
		}
		Else Exprp1(ou,lf)
	}
	While,s<>""
	{
		t1:=Exprp2(s)
		If t1 In (,)
		Return
		Exprp1(ou,t1)
	}
	Return,ou
}

ExprEval(e,lp,eo,el)
{
	c1:=Chr(1)
	Loop,Parse,e,%c1%
	{
		lf:=A_LoopField,tt:=SubStr(lf,1,1),t:=SubStr(lf,2)
		While (RegExMatch(lf,"&_String\d+_&",rm))
		lf:=StrReplace(lf,rm,el[rm])
		If tt In l,v
		lf:=Exprp1(s,lf)
		Else{
			If tt=f
			t1:=InStr(t," "),a:=SubStr(t,1,t1-1),t:=SubStr(t,t1+1)
			Else a:=Exprac(t)
			Exprp1(s,Exprap(t,s,a,lp,eo))
		}
	}
	
	Loop,Parse,s,%c1%
	{
		lf:=A_LoopField
		If (SubStr(lf,1,1)="v")
		t1:=SubStr(lf,2),r.=(lp.HasKey(t1) ? lp[t1] : %t1%) . c1
		Else r.=SubStr(lf,2) . c1
	}
	Return,SubStr(r,1,-1)
}

Exprap(o,ByRef s,ac,lp,eo)
{
	local i,t1,a1,a2,a3,a4,a5,a6,a1v,a2v,a3v,a4v,a5v,a6v,a7v,a8v,a9v
	Loop,%ac%
	i:=ac-(A_Index-1),t1:=Exprp2(s),a%i%:=SubStr(t1,2),(SubStr(t1,1,1)="v")?(a%i%v:=1)
	Loop, 10
	{
		If (RegExMatch(a%A_Index%,"^<~#(.*)#~>$",rm))
		a%A_Index%:=eo[rm1],a%A_Index%v:=0
		Else If (lp.HasKey(a%A_Index%))
		a%A_Index%:=lp[a%A_Index%],a%A_Index%v:=0
	}
	If o=++
	Return,"l" . %a1%++
	If o=--
	Return,"l" . %a1%--
	If o=\++
	Return,"l" . ++%a1%
	If o=\--
	Return,"l" . --%a1%
	If o=`%
	Return,"v" . %a1%
	If o=!
	Return,"l" . !(a1v ? %a1%:a1)
	If o=\!
	Return,"l" . (a1v ? %a1%:a1)
	If o=~
	Return,"l" . ~(a1v ? %a1%:a1)
	If o=**
	Return,"l" . ((a1v ? %a1%:a1)**(a2v ? %a2%:a2))
	If o=*
	Return,"l" . ((a1v ? %a1%:a1)*(a2v ? %a2%:a2))
	If o=\*
	Return,"l" . *(a1v ? %a1%:a1)
	If o=/
	Return,"l" . ((a1v ? %a1%:a1)/(a2v ? %a2%:a2))
	If o=//
	Return,"l" . ((a1v ? %a1%:a1)//(a2v ? %a2%:a2))
	If o=+
	Return,"l" . ((a1v ? %a1%:a1)+(a2v ? %a2%:a2))
	If o=-
	Return,"l" . ((a1v ? %a1%:a1)-(a2v ? %a2%:a2))
	If o=\-
	Return,"l" . -(a1v ? %a1%:a1)
	If o=<<
	Return,"l" . ((a1v ? %a1%:a1)<<(a2v ? %a2%:a2))
	If o=>>
	Return,"l" . ((a1v ? %a1%:a1)>>(a2v ? %a2%:a2))
	If o=&
	Return,"l" . ((a1v ? %a1%:a1)&(a2v ? %a2%:a2))
	If o=\&
	Return,"l" . &(a1v ? %a1%:a1)
	If o=^
	Return,"l" . ((a1v ? %a1%:a1)^(a2v ? %a2%:a2))
	If o=|
	Return,"l" . ((a1v ? %a1%:a1)|(a2v ? %a2%:a2))
	If o=\.
	Return,"l" . ((a1v ? %a1%:a1) . (a2v ? %a2%:a2))
	If o=.
	Return,"v" . a1
	If o=<
	Return,"l" . ((a1v ? %a1%:a1)<(a2v ? %a2%:a2))
	If o=>
	Return,"l" . ((a1v ? %a1%:a1)>(a2v ? %a2%:a2))
	If o==
	Return,"l" . ((a1v ? %a1%:a1)=(a2v ? %a2%:a2))
	If o===
	Return,"l" . ((a1v ? %a1%:a1)==(a2v ? %a2%:a2))
	If o=<>
	Return,"l" . ((a1v ? %a1%:a1)<>(a2v ? %a2%:a2))
	If o=!=
	Return,"l" . ((a1v ? %a1%:a1)!=(a2v ? %a2%:a2))
	If o=>=
	Return,"l" . ((a1v ? %a1%:a1)>=(a2v ? %a2%:a2))
	If o=<=
	Return,"l" . ((a1v ? %a1%:a1)<=(a2v ? %a2%:a2))
	If o=&&
	Return,"l" . ((a1v ? %a1%:a1)&&(a2v ? %a2%:a2))
	If o=||
	Return,"l" . ((a1v ? %a1%:a1)||(a2v ? %a2%:a2))
	If o=:=
	{
		%a1%:=(a2v ? %a2%:a2)
		Return,"v" . a1
	}
	If o=+=
	{
		%a1%+=(a2v ? %a2%:a2)
		Return,"v" . a1
	}
	If o=-=
	{
		%a1%-=(a2v ? %a2%:a2)
		Return,"v" . a1
	}
	If o=*=
	{
		%a1%*=(a2v ? %a2%:a2)
		Return,"v" . a1
	}
	If o=/=
	{
		%a1%/=(a2v ? %a2%:a2)
		Return,"v" . a1
	}
	If o=//=
	{
		%a1%//=(a2v ? %a2%:a2)
		Return,"v" . a1
	}
	If o=.=
	{
		%a1%.=(a2v ? %a2%:a2)
		Return,"v" . a1
	}
	If o=|=
	{
		%a1%|=(a2v ? %a2%:a2)
		Return,"v" . a1
	}
	If o=&=
	{
		%a1%&=(a2v ? %a2%:a2)
		Return,"v" . a1
	}
	If o=^=
	{
		%a1%^=(a2v ? %a2%:a2)
		Return,"v" . a1
	}
	If o=>>=
	{
		%a1%>>=(a2v ? %a2%:a2)
		Return,"v" . a1
	}
	If o=<<=
	{
		%a1%<<=(a2v ? %a2%:a2)
		Return,"v" . a1
	}
	If ac=0
	Return,"l" . %o%()
	If ac=1
	Return,"l" . %o%(a1v ? %a1%:a1)
	If ac=2
	Return,"l" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2))
	If ac=3
	Return,"l" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2),(a3v ? %a3%:a3))
	If ac=4
	Return,"l" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2),(a3v ? %a3%:a3),(a4v ? %a4%:a4))
	If ac=5
	Return,"l" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2),(a3v ? %a3%:a3),(a4v ? %a4%:a4),(a5v ? %a5%:a5))
	If ac=6
	Return,"l" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2),(a3v ? %a3%:a3),(a4v ? %a4%:a4),(a5v ? %a5%:a5),(a6v ? %a6%:a6))
	If ac=7
	Return,"l" . %o%((a1v ? %a1%:a1),(a2v ? %a2%:a2),(a3v ? %a3%:a3),(a4v ? %a4%:a4),(a5v ? %a5%:a5),(a6v ? %a6%:a6),(a7v ? %a7%:a7))
	If ac=8
	Return,"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))
	If ac=9
	Return,"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))
	If ac=10
	Return,"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))
}

Exprt(e)
{
	global Exprol
	c1:=Chr(1),f:=1,f1:=1
	While,(f:=RegExMatch(e,"S)""(?:[^""]|"""")*""",m,f))
	{
		t1:=SubStr(m,2,-1)
	,	t1:=StrReplace(t1,"""""","""")
	,	t1:=StrReplace(t1,"'","'27")
	,	t1:=StrReplace(t1,"````",c1)
	,	t1:=StrReplace(t1,"``n","`n")
	,	t1:=StrReplace(t1,"``r","`r")
	,	t1:=StrReplace(t1,"``b","`b")
	,	t1:=StrReplace(t1,"``t","`t")
	,	t1:=StrReplace(t1,"``v","`v")
	,	t1:=StrReplace(t1,"``a","`a")
	,	t1:=StrReplace(t1,"``f","`f")
	,	t1:=StrReplace(t1,c1,"``")
		SetFormat,IntegerFast,Hex
		While,RegExMatch(t1,"iS)[^\w']",c)
		t1:=StrReplace(t1,c,"'" . SubStr("0" . SubStr(Asc(c),3),-1))
		SetFormat,IntegerFast,D
		e1.=SubStr(e,f1,f-f1) . c1 . "l" . t1 . c1,f+=StrLen(m),f1:=f
	}
	e1.=SubStr(e,f1),e:=InStr(e1,"""")? "":e1,e1:="",e:=RegExReplace(e,"S)/\*.*?\*/|[ \t]`;.*?(?=\r|\n|$)")
,	e:=StrReplace(e,"`t"," ")
,	e:=RegExReplace(e,"S)([\w#@\$] +|\) *)(?=" . Chr(1) . "*[\w#@\$\(])","$1 . ")
,	e:=StrReplace(e," . ","\.")
,	e:=StrReplace(e," ")
,	f:=1,f1:=1
	While,(f:=RegExMatch(e,"iS)(^|[^\w#@\$\.'])(0x[0-9a-fA-F]+|\d+(?:\.\d+)?|\.\d+)(?=[^\d\.]|$)",m,f))
	{
		If ((m1="\") && (RegExMatch(m2,"\.\d+")))
		m1:="",m2:=SubStr(m2,2)
		m2+=0
		m2:=StrReplace(m2,".","'2E",,1)
		e1.=SubStr(e,f1,f-f1) . m1 . c1 . "n" . m2 . c1,f+=StrLen(m),f1:=f
	}
	e:=e1 . SubStr(e,f1),e1:="" ; ,e:=RegExReplace(e,"S)(^|\(|[^" . c1 . "-])-" . c1 . "n","$1" . c1 . "n'2D")
,	e:=StrReplace(e,c1 "n",c1 "l")
,	e:=RegExReplace(e,"\\\.(\d+)\.(\d+)",c1 . "l$1'2E$2" . c1)
,	e:=RegExReplace(RegExReplace(e,"S)(%[\w#@\$]{1,253})%","$1"),"S)(?:^|[^\w#@\$'" . c1 . "])\K[\w#@\$]{1,253}(?=[^\(\w#@\$]|$)",c1 . "v$0" . c1),f:=1,f1:=1
	While,(f:=RegExMatch(e,"S)(^|[^\w#@\$'])([\w#@\$]{1,253})(?=\()",m,f))
	{
		t1:=f+StrLen(m)
		If (SubStr(e,t1+1,1)=")")
		ac=0
		Else
		{
			If !Exprmlb(e,t1,fa)
			Return
			fa:=StrReplace(fa,"`,","`,",c)
			ac:=c+1
		}
		e1.=SubStr(e,f1,f-f1) . m1 . c1 . "f" . ac . "'20" . m2 . c1,f+=StrLen(m),f1:=f
	}
	e:=e1 . SubStr(e,f1),e1:=""
,	e:=StrReplace(e,"\." c1 "vNot" c1 "\.","!")
,	e:=StrReplace(e,"\." c1 "vAnd" c1 "\.","&&")
,	e:=StrReplace(e,"\." c1 "vOr" c1 "\.","||")
,	e:=StrReplace(e,c1 "vNot" c1 "\.","!")
,	e:=StrReplace(e,c1 "vAnd" c1 "\.","&&")
,	e:=StrReplace(e,c1 "vOr" c1 "\.","||")
,	e:=StrReplace(e,"\." c1 "vNot" c1 . c1,"!")
,	e:=StrReplace(e,"\." c1 "vAnd" c1 . c1,"&&")
,	e:=StrReplace(e,"\." c1 "vOr" c1 . c1,"||")
,	e:=StrReplace(e,c1 "vNot" c1 . c1,"!")
,	e:=StrReplace(e,c1 "vAnd" c1 . c1,"&&")
,	e:=StrReplace(e,c1 "vOr" c1 . c1,"||")
,	e:=RegExReplace(e,"S)(^|[^" . c1 . "\)-])-" . c1 . "(?=[lvf])","$1\-" . c1)
,	e:=RegExReplace(e,"S)(^|[^" . c1 . "\)&])&" . c1 . "(?=[lvf])","$1\&" . c1)
,	e:=RegExReplace(e,"S)(^|[^" . c1 . "\)\*])\*" . c1 . "(?=[lvf])","$1\*" . c1)
,	e:=RegExReplace(e,"S)(^|[^" . c1 . "\)])(\+\+|--)" . c1 . "(?=[lvf])","$1\$2" . c1)
,	t1:=RegExReplace(Exprol,"S)[\\\.\*\?\+\[\{\|\(\)\^\$]","\$0")
,	t1:=StrReplace(t1,"`n","|")
,	e:=RegExReplace(e,"S)" . t1,c1 . "o$0" . c1)
,	e:=StrReplace(e,"`,",c1 "`," c1)
,	e:=StrReplace(e,"(",c1 "(" c1)
,	e:=StrReplace(e,")",c1 ")" c1)
,	e:=StrReplace(e,c1 . c1,c1)
	If RegExMatch(e,"S)" . c1 . "[^lvfo\(\),\n]")
	Return
	e:=SubStr(e,2,-1),f:=0
	While,(f:=InStr(e,"'",False,f + 1))
	{
		If ((t1:=SubStr(e,f+1,2))<>27)
		e:=StrReplace(e,"'" t1,Chr("0x" . t1))
	}
	e:=StrReplace(e,"'27","'")
	Return,e
}

Exprols(o1,o2)
{
	Return,StrLen(o2)-StrLen(o1)
}

Exprpr(o)
{
	global Exprot
	t:=InStr(Exprot,"`n" . o . " ")+StrLen(o)+2
	Return,SubStr(Exprot,t,InStr(Exprot," ",0,t)-t)
}

Expras(o)
{
	global Exprot
	Return,SubStr(Exprot,InStr(Exprot," ",0,InStr(Exprot,"`n" . o . " ")+StrLen(o)+2)+1,1)
}

Exprac(o)
{
	global Exprot
	Return,SubStr(Exprot,InStr(Exprot,"`n",0,InStr(Exprot,"`n" . o . " ")+1)-1,1)
}

Exprmlb(ByRef s,p,ByRef o="",b="(",e=")")
{
	t:=SubStr(s,p),bc:=0,VarSetCapacity(o,StrLen(t))
	If (SubStr(t,1,1)<>b)
	Return,0
	Loop,Parse,t
	{
		lf:=A_LoopField
		If lf=%b%
		bc++
		Else If lf=%e%
		{
			bc--
			If bc=0
			Return,p
		}
		Else If bc=1
		o.=lf
		p++
	}
	Return,0
}

Exprp1(ByRef dl,d)
{
	dl.=((dl="")? "":Chr(1)) . d
}

Exprp2(ByRef dl)
{
	t:=InStr(dl,Chr(1),0,0),t ?(t1:=SubStr(dl,t+1),dl:=SubStr(dl,1,t-1)):(t1:=dl,dl:="")
	Return,t1
}

Exprp3(ByRef dl)
{
	Return,SubStr(dl,InStr(dl,Chr(1),0,0)+1)
}


================================================
FILE: Install.ahk
================================================
#Requires AutoHotkey v1.1
#SingleInstance, Force
SetBatchLines, -1
SetWorkingDir, % A_ScriptDir

FileInstall, __Release\CH-Install.zip, CH-Install.zip, 1
FileInstall, Install.png, Install.png, 1

Gui, -MinimizeBox
Gui, Font, s20 Bold, Calibri
Gui, Color, White
Gui, Add, Text, Center BackgroundTrans w400, Cash Helper
Gui, Add, Pic, xm yp-10 w64 h64 BackgroundTrans, Install.png
Gui, Font, Norm
Gui, Font, s10 Bold
Gui, Add, Edit, ReadOnly w290 vLoc, %A_ProgramFiles%\Cash Helper
IS := InstallState()
Gui, Font, s8
Gui, Add, Button, xp+300 yp w100 vCG, Change
Gui, Font, s10
Gui, Add, Checkbox, xp-300 yp+30 Checked gInstallWay vIAU, Install for all users
Gui, Add, Checkbox, yp+20 vPort, Portable
Gui, Add, Button, w100 vIB gButtonInstall, % IS[1]
Gui, Add, Progress, w400 vPB -Smooth h15 Hidden
Gui, Font, s8
Gui, Add, Text, xp yp+17 wp Center vPercent BackgroundTrans

FileInstall, __Release\Version.txt, Version.txt, 1

FileRead, Version, Version.txt
Gui, Show,, Install Setup %Version%
GuiControl, Focus, IB
Return
InstallWay:
    GuiControlGet, IAU
    If (IAU) {
        GuiControl,, Loc, %A_ProgramFiles%\Cash Helper
    } Else {
        GuiControl,, Loc, %A_AppData%\Cash Helper
    }
    IS := InstallState()
Return

GuiClose:
ExitApp

ButtonInstall:
    If !FileExist("CH-Install.zip") {
        MsgBox, 16, Error, Install package not found.
        Return
    }
    GuiControl, Disabled, IB
    GuiControl, Disabled, IAU
    GuiControl, Disabled, Port
    GuiControl, Disabled, Loc
    GuiControl, Disabled, CG
    GuiControl,, IB, % IS[2]
    GuiControlGet, Loc
    GuiControl, Show, PB
    GuiControl,, PB, + 20
    GuiControl,, Percent, 20 `%
    FileCopyDir, CH-Install.zip, % Loc, 1
    FileDelete, CH-Install.zip
    GuiControl,, PB, + 30
    GuiControl,, Percent, 50 `%
    FileCopyDir, % Loc "\HighChart.zip", % Loc "\", 1
    FileDelete, % Loc "\HighChart.zip"
    GuiControl,, PB, + 40
    GuiControl,, Percent, 90 `%
    FileCopy, Version.txt, % Loc, 1
    FileDelete, Version.txt
    GuiControl,, PB, + 10
    GuiControl,, Percent, 100 `%
    GuiControlGet, Port
    
    If (!Port) {
        RegPath := "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cash Helper"
        RegWrite, REG_SZ, %RegPath%, DisplayName, Cash Helper
        RegWrite, REG_SZ, %RegPath%, DisplayVersion, %Version%
        RegWrite, REG_SZ, %RegPath%, DisplayIcon, %Loc%\StartUp.exe
        RegWrite, REG_SZ, %RegPath%, InstallLocation, %Loc%\
        RegWrite, REG_SZ, %RegPath%, UninstallString, %Loc%\Uninstall.exe
        RegWrite, REG_DWORD, %RegPath%, NoModify, 1
        RegWrite, REG_DWORD, %RegPath%, NoRepair, 1
        RegWrite, REG_SZ, %RegPath%, Publisher, Chandoul Mohamed
        GuiControl,, Log, Creating a shortcut...
        FileCreateShortcut, %Loc%\StartUp.exe, %A_Desktop%\Cash Helper.lnk
    }
    
    GuiControl,, IB, COMPLETE!
    
    MsgBox, 4, Launch, Run Cash Helper now?
    IfMsgBox, Yes
    {
        Run, % Loc "\StartUp.exe"
    }
ExitApp

ButtonChange:
    If (Dir := SelectFolderEx(StartingFolder := "", Prompt := "Select Program Location",, OkBtnLabel := "OK!")) {
        GuiControl,, Loc, % Dir "\Cash Helper"
        InstallState()
    }
Return

SelectFolderEx(StartingFolder := "", Prompt := "", OwnerHwnd := 0, OkBtnLabel := "") {
    Static OsVersion := DllCall("GetVersion", "UChar")
    , IID_IShellItem := 0
    , InitIID := VarSetCapacity(IID_IShellItem, 16, 0)
    & DllCall("Ole32.dll\IIDFromString", "WStr", "{43826d1e-e718-42ee-bc55-a1e261c37bfe}", "Ptr", &IID_IShellItem)
    , Show              := A_PtrSize * 3
    , SetOptions        := A_PtrSize * 9
    , SetFolder         := A_PtrSize * 12
    , SetTitle          := A_PtrSize * 17
    , SetOkButtonLabel  := A_PtrSize * 18
    , GetResult         := A_PtrSize * 20
    SelectedFolder      := ""
    
    If (OsVersion < 6) {
        FileSelectFolder, SelectedFolder, *%StartingFolder%, 3, %Prompt%
        Return SelectedFolder
    }
    
    OwnerHwnd := DllCall("IsWindow", "Ptr", OwnerHwnd, "UInt") ? OwnerHwnd : 0
    If !(FileDialog := ComObjCreate("{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}", "{42f85136-db7e-439c-85f1-e4075d135fc8}"))
        Return ""
    VTBL := NumGet(FileDialog + 0, "UPtr")
    DllCall(NumGet(VTBL + SetOptions, "UPtr"), "Ptr", FileDialog, "UInt", 0x00002028, "UInt")
    
    If (StartingFolder <> "")
        If !DllCall("Shell32.dll\SHCreateItemFromParsingName", "WStr", StartingFolder, "Ptr", 0, "Ptr", &IID_IShellItem, "PtrP", FolderItem)
            DllCall(NumGet(VTBL + SetFolder, "UPtr"), "Ptr", FileDialog, "Ptr", FolderItem, "UInt")
    
    If (Prompt <> "")
        DllCall(NumGet(VTBL + SetTitle, "UPtr"), "Ptr", FileDialog, "WStr", Prompt, "UInt")
    
    If (OkBtnLabel <> "")
        DllCall(NumGet(VTBL + SetOkButtonLabel, "UPtr"), "Ptr", FileDialog, "WStr", OkBtnLabel, "UInt")
    
    If !DllCall(NumGet(VTBL + Show, "UPtr"), "Ptr", FileDialog, "Ptr", OwnerHwnd, "UInt") {
        If !DllCall(NumGet(VTBL + GetResult, "UPtr"), "Ptr", FileDialog, "PtrP", ShellItem, "UInt") {
            GetDisplayName := NumGet(NumGet(ShellItem + 0, "UPtr"), A_PtrSize * 5, "UPtr")
            If !DllCall(GetDisplayName, "Ptr", ShellItem, "UInt", 0x80028000, "PtrP", StrPtr)
            SelectedFolder := StrGet(StrPtr, "UTF-16"), DllCall("Ole32.dll\CoTaskMemFree", "Ptr", StrPtr)
            ObjRelease(ShellItem)
        }
    }
    
    If (FolderItem)
        ObjRelease(FolderItem)
        
    ObjRelease(FileDialog)
    Return SelectedFolder
}

InstallState() {
    RegRead, IC, HKLM, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cash Helper, InstallLocation
    GuiControlGet, Loc
    IS := (IC = Loc "\") ? ["Update", "Updating..."] : ["Install", "Installing..."]
    GuiControl,, IB, % IS[1]
    Return, IS
}

================================================
FILE: Lib/Classes/Class_CtlColors.ahk
================================================
; ======================================================================================================================
; AHK 1.1+
; ======================================================================================================================
; Function:          Auxiliary object to color controls on WM_CTLCOLOR... notifications.
;                    Supported controls are: Checkbox, ComboBox, DropDownList, Edit, ListBox, Radio, Text.
;                    Checkboxes and Radios accept only background colors due to design.
; Namespace:         CtlColors
; Tested with:       1.1.25.02
; Tested on:         Win 10 (x64)
; Change log:        1.0.04.00/2017-10-30/just me  -  added transparent background (BkColor = "Trans").
;                    1.0.03.00/2015-07-06/just me  -  fixed Change() to run properly for ComboBoxes.
;                    1.0.02.00/2014-06-07/just me  -  fixed __New() to run properly with compiled scripts.
;                    1.0.01.00/2014-02-15/just me  -  changed class initialization.
;                    1.0.00.00/2014-02-14/just me  -  initial release.
; ======================================================================================================================
; This software is provided 'as-is', without any express or implied warranty.
; In no event will the authors be held liable for any damages arising from the use of this software.
; ======================================================================================================================
Class CtlColors {
   ; ===================================================================================================================
   ; Class variables
   ; ===================================================================================================================
   ; Registered Controls
   Static Attached := {}
   ; OnMessage Handlers
   Static HandledMessages := {Edit: 0, ListBox: 0, Static: 0}
   ; Message Handler Function
   Static MessageHandler := "CtlColors_OnMessage"
   ; Windows Messages
   Static WM_CTLCOLOR := {Edit: 0x0133, ListBox: 0x134, Static: 0x0138}
   ; HTML Colors (BGR)
   Static HTML := {AQUA: 0xFFFF00, BLACK: 0x000000, BLUE: 0xFF0000, FUCHSIA: 0xFF00FF, GRAY: 0x808080, GREEN: 0x008000
                 , LIME: 0x00FF00, MAROON: 0x000080, NAVY: 0x800000, OLIVE: 0x008080, PURPLE: 0x800080, RED: 0x0000FF
                 , SILVER: 0xC0C0C0, TEAL: 0x808000, WHITE: 0xFFFFFF, YELLOW: 0x00FFFF}
   ; Transparent Brush
   Static NullBrush := DllCall("GetStockObject", "Int", 5, "UPtr")
   ; System Colors
   Static SYSCOLORS := {Edit: "", ListBox: "", Static: ""}
   ; Error message in case of errors
   Static ErrorMsg := ""
   ; Class initialization
   Static InitClass := CtlColors.ClassInit()
   ; ===================================================================================================================
   ; Constructor / Destructor
   ; ===================================================================================================================
   __New() { ; You must not instantiate this class!
      If (This.InitClass == "!DONE!") { ; external call after class initialization
         This["!Access_Denied!"] := True
         Return False
      }
   }
   ; ----------------------------------------------------------------------------------------------------------------
   __Delete() {
      If This["!Access_Denied!"]
         Return
      This.Free() ; free GDI resources
   }
   ; ===================================================================================================================
   ; ClassInit       Internal creation of a new instance to ensure that __Delete() will be called.
   ; ===================================================================================================================
   ClassInit() {
      CtlColors := New CtlColors
      Return "!DONE!"
   }
   ; ===================================================================================================================
   ; CheckBkColor    Internal check for parameter BkColor.
   ; ===================================================================================================================
   CheckBkColor(ByRef BkColor, Class) {
      This.ErrorMsg := ""
      If (BkColor != "") && !This.HTML.HasKey(BkColor) && !RegExMatch(BkColor, "^[[:xdigit:]]{6}$") {
         This.ErrorMsg := "Invalid parameter BkColor: " . BkColor
         Return False
      }
      BkColor := BkColor = "" ? This.SYSCOLORS[Class]
              :  This.HTML.HasKey(BkColor) ? This.HTML[BkColor]
              :  "0x" . SubStr(BkColor, 5, 2) . SubStr(BkColor, 3, 2) . SubStr(BkColor, 1, 2)
      Return True
   }
   ; ===================================================================================================================
   ; CheckTxColor    Internal check for parameter TxColor.
   ; ===================================================================================================================
   CheckTxColor(ByRef TxColor) {
      This.ErrorMsg := ""
      If (TxColor != "") && !This.HTML.HasKey(TxColor) && !RegExMatch(TxColor, "i)^[[:xdigit:]]{6}$") {
         This.ErrorMsg := "Invalid parameter TextColor: " . TxColor
         Return False
      }
      TxColor := TxColor = "" ? ""
              :  This.HTML.HasKey(TxColor) ? This.HTML[TxColor]
              :  "0x" . SubStr(TxColor, 5, 2) . SubStr(TxColor, 3, 2) . SubStr(TxColor, 1, 2)
      Return True
   }
   ; ===================================================================================================================
   ; Attach          Registers a control for coloring.
   ; Parameters:     HWND        - HWND of the GUI control                                   
   ;                 BkColor     - HTML color name, 6-digit hexadecimal RGB value, or "" for default color
   ;                 ----------- Optional 
   ;                 TxColor     - HTML color name, 6-digit hexadecimal RGB value, or "" for default color
   ; Return values:  On success  - True
   ;                 On failure  - False, CtlColors.ErrorMsg contains additional informations
   ; ===================================================================================================================
   Attach(HWND, BkColor, TxColor := "") {
      ; Names of supported classes
      Static ClassNames := {Button: "", ComboBox: "", Edit: "", ListBox: "", Static: ""}
      ; Button styles
      Static BS_CHECKBOX := 0x2, BS_RADIOBUTTON := 0x8
      ; Editstyles
      Static ES_READONLY := 0x800
      ; Default class background colors
      Static COLOR_3DFACE := 15, COLOR_WINDOW := 5
      ; Initialize default background colors on first call -------------------------------------------------------------
      If (This.SYSCOLORS.Edit = "") {
         This.SYSCOLORS.Static := DllCall("User32.dll\GetSysColor", "Int", COLOR_3DFACE, "UInt")
         This.SYSCOLORS.Edit := DllCall("User32.dll\GetSysColor", "Int", COLOR_WINDOW, "UInt")
         This.SYSCOLORS.ListBox := This.SYSCOLORS.Edit
      }
      This.ErrorMsg := ""
      ; Check colors ---------------------------------------------------------------------------------------------------
      If (BkColor = "") && (TxColor = "") {
         This.ErrorMsg := "Both parameters BkColor and TxColor are empty!"
         Return False
      }
      ; Check HWND -----------------------------------------------------------------------------------------------------
      If !(CtrlHwnd := HWND + 0) || !DllCall("User32.dll\IsWindow", "UPtr", HWND, "UInt") {
         This.ErrorMsg := "Invalid parameter HWND: " . HWND
         Return False
      }
      If This.Attached.HasKey(HWND) {
         This.ErrorMsg := "Control " . HWND . " is already registered!"
         Return False
      }
      Hwnds := [CtrlHwnd]
      ; Check control's class ------------------------------------------------------------------------------------------
      Classes := ""
      WinGetClass, CtrlClass, ahk_id %CtrlHwnd%
      This.ErrorMsg := "Unsupported control class: " . CtrlClass
      If !ClassNames.HasKey(CtrlClass)
         Return False
      ControlGet, CtrlStyle, Style, , , ahk_id %CtrlHwnd%
      If (CtrlClass = "Edit")
         Classes := ["Edit", "Static"]
      Else If (CtrlClass = "Button") {
         IF (CtrlStyle & BS_RADIOBUTTON) || (CtrlStyle & BS_CHECKBOX)
            Classes := ["Static"]
         Else
            Return False
      }
      Else If (CtrlClass = "ComboBox") {
         VarSetCapacity(CBBI, 40 + (A_PtrSize * 3), 0)
         NumPut(40 + (A_PtrSize * 3), CBBI, 0, "UInt")
         DllCall("User32.dll\GetComboBoxInfo", "Ptr", CtrlHwnd, "Ptr", &CBBI)
         Hwnds.Insert(NumGet(CBBI, 40 + (A_PtrSize * 2, "UPtr")) + 0)
         Hwnds.Insert(Numget(CBBI, 40 + A_PtrSize, "UPtr") + 0)
         Classes := ["Edit", "Static", "ListBox"]
      }
      If !IsObject(Classes)
         Classes := [CtrlClass]
      ; Check background color -----------------------------------------------------------------------------------------
      If (BkColor <> "Trans")
         If !This.CheckBkColor(BkColor, Classes[1])
            Return False
      ; Check text color -----------------------------------------------------------------------------------------------
      If !This.CheckTxColor(TxColor)
         Return False
      ; Activate message handling on the first call for a class --------------------------------------------------------
      For I, V In Classes {
         If (This.HandledMessages[V] = 0)
            OnMessage(This.WM_CTLCOLOR[V], This.MessageHandler)
         This.HandledMessages[V] += 1
      }
      ; Store values for HWND ------------------------------------------------------------------------------------------
      If (BkColor = "Trans")
         Brush := This.NullBrush
      Else
         Brush := DllCall("Gdi32.dll\CreateSolidBrush", "UInt", BkColor, "UPtr")
      For I, V In Hwnds
         This.Attached[V] := {Brush: Brush, TxColor: TxColor, BkColor: BkColor, Classes: Classes, Hwnds: Hwnds}
      ; Redraw control -------------------------------------------------------------------------------------------------
      DllCall("User32.dll\InvalidateRect", "Ptr", HWND, "Ptr", 0, "Int", 1)
      This.ErrorMsg := ""
      Return True
   }
   ; ===================================================================================================================
   ; Change          Change control colors.
   ; Parameters:     HWND        - HWND of the GUI control
   ;                 BkColor     - HTML color name, 6-digit hexadecimal RGB value, or "" for default color
   ;                 ----------- Optional 
   ;                 TxColor     - HTML color name, 6-digit hexadecimal RGB value, or "" for default color
   ; Return values:  On success  - True
   ;                 On failure  - False, CtlColors.ErrorMsg contains additional informations
   ; Remarks:        If the control isn't registered yet, Add() is called instead internally.
   ; ===================================================================================================================
   Change(HWND, BkColor, TxColor := "") {
      ; Check HWND -----------------------------------------------------------------------------------------------------
      This.ErrorMsg := ""
      HWND += 0
      If !This.Attached.HasKey(HWND)
         Return This.Attach(HWND, BkColor, TxColor)
      CTL := This.Attached[HWND]
      ; Check BkColor --------------------------------------------------------------------------------------------------
      If (BkColor <> "Trans")
         If !This.CheckBkColor(BkColor, CTL.Classes[1])
            Return False
      ; Check TxColor ------------------------------------------------------------------------------------------------
      If !This.CheckTxColor(TxColor)
         Return False
      ; Store Colors ---------------------------------------------------------------------------------------------------
      If (BkColor <> CTL.BkColor) {
         If (CTL.Brush) {
            If (Ctl.Brush <> This.NullBrush)
               DllCall("Gdi32.dll\DeleteObject", "Prt", CTL.Brush)
            This.Attached[HWND].Brush := 0
         }
         If (BkColor = "Trans")
            Brush := This.NullBrush
         Else
            Brush := DllCall("Gdi32.dll\CreateSolidBrush", "UInt", BkColor, "UPtr")
         For I, V In CTL.Hwnds {
            This.Attached[V].Brush := Brush
            This.Attached[V].BkColor := BkColor
         }
      }
      For I, V In Ctl.Hwnds
         This.Attached[V].TxColor := TxColor
      This.ErrorMsg := ""
      DllCall("User32.dll\InvalidateRect", "Ptr", HWND, "Ptr", 0, "Int", 1)
      Return True
   }
   ; ===================================================================================================================
   ; Detach          Stop control coloring.
   ; Parameters:     HWND        - HWND of the GUI control
   ; Return values:  On success  - True
   ;                 On failure  - False, CtlColors.ErrorMsg contains additional informations
   ; ===================================================================================================================
   Detach(HWND) {
      This.ErrorMsg := ""
      HWND += 0
      If This.Attached.HasKey(HWND) {
         CTL := This.Attached[HWND].Clone()
         If (CTL.Brush) && (CTL.Brush <> This.NullBrush)
            DllCall("Gdi32.dll\DeleteObject", "Prt", CTL.Brush)
         For I, V In CTL.Classes {
            If This.HandledMessages[V] > 0 {
               This.HandledMessages[V] -= 1
               If This.HandledMessages[V] = 0
                  OnMessage(This.WM_CTLCOLOR[V], "")
         }  }
         For I, V In CTL.Hwnds
            This.Attached.Remove(V, "")
         DllCall("User32.dll\InvalidateRect", "Ptr", HWND, "Ptr", 0, "Int", 1)
         CTL := ""
         Return True
      }
      This.ErrorMsg := "Control " . HWND . " is not registered!"
      Return False
   }
   ; ===================================================================================================================
   ; Free            Stop coloring for all controls and free resources.
   ; Return values:  Always True.
   ; ===================================================================================================================
   Free() {
      For K, V In This.Attached
         If (V.Brush) && (V.Brush <> This.NullBrush)
            DllCall("Gdi32.dll\DeleteObject", "Ptr", V.Brush)
      For K, V In This.HandledMessages
         If (V > 0) {
            OnMessage(This.WM_CTLCOLOR[K], "")
            This.HandledMessages[K] := 0
         }
      This.Attached := {}
      Return True
   }
   ; ===================================================================================================================
   ; IsAttached      Check if the control is registered for coloring.
   ; Parameters:     HWND        - HWND of the GUI control
   ; Return values:  On success  - True
   ;                 On failure  - False
   ; ===================================================================================================================
   IsAttached(HWND) {
      Return This.Attached.HasKey(HWND)
   }
}

; ======================================================================================================================
; CtlColors_OnMessage
; This function handles CTLCOLOR messages. There's no reason to call it manually!
; ======================================================================================================================
CtlColors_OnMessage(HDC, HWND) {
   Critical
   If CtlColors.IsAttached(HWND) {
      CTL := CtlColors.Attached[HWND]
      If (CTL.TxColor != "")
         DllCall("Gdi32.dll\SetTextColor", "Ptr", HDC, "UInt", CTL.TxColor)
      If (CTL.BkColor = "Trans")
         DllCall("Gdi32.dll\SetBkMode", "Ptr", HDC, "UInt", 1) ; TRANSPARENT = 1
      Else
         DllCall("Gdi32.dll\SetBkColor", "Ptr", HDC, "UInt", CTL.BkColor)
      Return CTL.Brush
   }
}


================================================
FILE: Lib/Classes/Class_GDIplus.ahk
================================================
class GDIplus {
    __New() {
        if !DllCall("GetModuleHandle", "Str", "gdiplus", "Ptr")
            DllCall("LoadLibrary", "Str", "gdiplus")
        VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
        DllCall("gdiplus\GdiplusStartup", "UPtrP", pToken, "Ptr", &si, "Ptr", 0)
        this.token := pToken
    }
    __Delete() {
        DllCall("gdiplus\GdiplusShutdown", "Ptr", this.token)
        if hModule := DllCall("GetModuleHandle", "Str", "gdiplus", "Ptr")
            DllCall("FreeLibrary", "Ptr", hModule)
    }
    CreateBitmapFromStream(pStream) {
        DllCall("gdiplus\GdipCreateBitmapFromStream", "Ptr", pStream, "PtrP", pBitmap)
        Return pBitmap
    }
    CreateHBITMAPFromBitmap(pBitmap, background := 0xffffffff) {
        DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Ptr", pBitmap, "PtrP", hbm, "UInt", background)
        return hbm
    }
    DisposeImage(pBitmap) {
        return DllCall("gdiplus\GdipDisposeImage", "Ptr", pBitmap)
    }
}

================================================
FILE: Lib/Classes/Class_ImageButton.ahk
================================================
; ======================================================================================================================
; Namespace:         ImageButton
; Function:          Create images and assign them to pushbuttons.
; Tested with:       AHK 1.1.33.02 (A32/U32/U64)
; Tested on:         Win 10 (x64)
; Change history:    1.5.00.00/2020-12-16/just me - increased script performance, added support for icons (HICON)
;                    1.4.00.00/2014-06-07/just me - fixed bug for button caption = "0", "000", etc.
;                    1.3.00.00/2014-02-28/just me - added support for ARGB colors
;                    1.2.00.00/2014-02-23/just me - added borders
;                    1.1.00.00/2013-12-26/just me - added rounded and bicolored buttons       
;                    1.0.00.00/2013-12-21/just me - initial release
; How to use:
;     1. Create a push button (e.g. "Gui, Add, Button, vMyButton hwndHwndButton, Caption") using the 'Hwnd' option
;        to get its HWND.
;     2. Call ImageButton.Create() passing two parameters:
;        HWND        -  Button's HWND.
;        Options*    -  variadic array containing up to 6 option arrays (see below).
;        ---------------------------------------------------------------------------------------------------------------
;        The index of each option object determines the corresponding button state on which the bitmap will be shown.
;        MSDN defines 6 states (http://msdn.microsoft.com/en-us/windows/bb775975):
;           PBS_NORMAL    = 1
;	         PBS_HOT       = 2
;	         PBS_PRESSED   = 3
;	         PBS_DISABLED  = 4
;	         PBS_DEFAULTED = 5
;	         PBS_STYLUSHOT = 6 <- used only on tablet computers (that's false for Windows Vista and 7, see below)
;        If you don't want the button to be 'animated' on themed GUIs, just pass one option object with index 1.
;        On Windows Vista and 7 themed bottons are 'animated' using the images of states 5 and 6 after clicked.
;        ---------------------------------------------------------------------------------------------------------------
;        Each option array may contain the following values:
;           Index Value
;           1     Mode        mandatory:
;                             0  -  unicolored or bitmap
;                             1  -  vertical bicolored
;                             2  -  horizontal bicolored
;                             3  -  vertical gradient
;                             4  -  horizontal gradient
;                             5  -  vertical gradient using StartColor at both borders and TargetColor at the center
;                             6  -  horizontal gradient using StartColor at both borders and TargetColor at the center
;                             7  -  'raised' style
;           2     StartColor  mandatory for Option[1], higher indices will inherit the value of Option[1], if omitted:
;                             -  ARGB integer value (0xAARRGGBB) or HTML color name ("Red").
;                             -  Path of an image file or HBITMAP handle for mode 0.
;           3     TargetColor mandatory for Option[1] if Mode > 0. Higher indcices will inherit the color of Option[1],
;                             if omitted:
;                             -  ARGB integer value (0xAARRGGBB) or HTML color name ("Red").
;                             -  String "HICON" if StartColor contains a HICON handle.
;           4     TextColor   optional, if omitted, the default text color will be used for Option[1], higher indices 
;                             will inherit the color of Option[1]:
;                             -  ARGB integer value (0xAARRGGBB) or HTML color name ("Red").
;                                Default: 0xFF000000 (black)
;           5     Rounded     optional:
;                             -  Radius of the rounded corners in pixel; the letters 'H' and 'W' may be specified
;                                also to use the half of the button's height or width respectively.
;                                Default: 0 - not rounded
;           6     GuiColor    optional, needed for rounded buttons if you've changed the GUI background color:
;                             -  RGB integer value (0xRRGGBB) or HTML color name ("Red").
;                                Default: AHK default GUI background color
;           7     BorderColor optional, ignored for modes 0 (bitmap) and 7, color of the border:
;                             -  RGB integer value (0xRRGGBB) or HTML color name ("Red").
;           8     BorderWidth optional, ignored for modes 0 (bitmap) and 7, width of the border in pixels:
;                             -  Default: 1
;        ---------------------------------------------------------------------------------------------------------------
;        If the the button has a caption it will be drawn above the bitmap.
; Credits:           THX tic     for GDIP.AHK     : http://www.autohotkey.com/forum/post-198949.html
;                    THX tkoi    for ILBUTTON.AHK : http://www.autohotkey.com/forum/topic40468.html
; ======================================================================================================================
; This software is provided 'as-is', without any express or implied warranty.
; In no event will the authors be held liable for any damages arising from the use of this software.
; ======================================================================================================================
; ======================================================================================================================
; CLASS ImageButton()
; ======================================================================================================================
Class ImageButton {
   ; ===================================================================================================================
   ; PUBLIC PROPERTIES =================================================================================================
   ; ===================================================================================================================
   Static DefGuiColor  := ""        ; default GUI color                             (read/write)
   Static DefTxtColor := "Black"    ; default caption color                         (read/write)
   Static LastError := ""           ; will contain the last error message, if any   (readonly)
   ; ===================================================================================================================
   ; PRIVATE PROPERTIES ================================================================================================
   ; ===================================================================================================================
   Static BitMaps := []
   Static GDIPDll := 0
   Static GDIPToken := 0
   Static MaxOptions := 8
   ; HTML colors
   Static HTML := {BLACK: 0x000000, GRAY: 0x808080, SILVER: 0xC0C0C0, WHITE: 0xFFFFFF, MAROON: 0x800000
                 , PURPLE: 0x800080, FUCHSIA: 0xFF00FF, RED: 0xFF0000, GREEN: 0x008000, OLIVE: 0x808000
                 , YELLOW: 0xFFFF00, LIME: 0x00FF00, NAVY: 0x000080, TEAL: 0x008080, AQUA: 0x00FFFF, BLUE: 0x0000FF}
   ; Initialize
   Static ClassInit := ImageButton.InitClass()
   ; ===================================================================================================================
   ; PRIVATE METHODS ===================================================================================================
   ; ===================================================================================================================
   __New(P*) {
      Return False
   }
   ; ===================================================================================================================
   InitClass() {
      ; ----------------------------------------------------------------------------------------------------------------
      ; Get AHK's default GUI background color
      GuiColor := DllCall("User32.dll\GetSysColor", "Int", 15, "UInt") ; COLOR_3DFACE is used by AHK as default
      This.DefGuiColor := ((GuiColor >> 16) & 0xFF) | (GuiColor & 0x00FF00) | ((GuiColor & 0xFF) << 16)
      Return True
   }
   ; ===================================================================================================================
   BitmapOrIcon(O2, O3) {
      ; OBJ_BITMAP = 7
      Return (This.IsInt(O2) && (O3 = "HICON")) || (DllCall("GetObjectType", "Ptr", O2, "UInt") = 7) || FileExist(O2)
   }
   ; ===================================================================================================================
   FreeBitmaps() {
      For I, HBITMAP In This.BitMaps
         DllCall("Gdi32.dll\DeleteObject", "Ptr", HBITMAP)
      This.BitMaps := []
   }
   ; ===================================================================================================================
   GetARGB(RGB) {
      ARGB := This.HTML.HasKey(RGB) ? This.HTML[RGB] : RGB
      Return (ARGB & 0xFF000000) = 0 ? 0xFF000000 | ARGB : ARGB
   }
   ; ===================================================================================================================
   IsInt(Val) {
      If Val Is Integer
         Return True
      Return False
   }
   ; ===================================================================================================================
   PathAddRectangle(Path, X, Y, W, H) {
      Return DllCall("Gdiplus.dll\GdipAddPathRectangle", "Ptr", Path, "Float", X, "Float", Y, "Float", W, "Float", H)
   }
   ; ===================================================================================================================
   PathAddRoundedRect(Path, X1, Y1, X2, Y2, R) {
      D := (R * 2), X2 -= D, Y2 -= D
      DllCall("Gdiplus.dll\GdipAddPathArc"
            , "Ptr", Path, "Float", X1, "Float", Y1, "Float", D, "Float", D, "Float", 180, "Float", 90)
      DllCall("Gdiplus.dll\GdipAddPathArc"
            , "Ptr", Path, "Float", X2, "Float", Y1, "Float", D, "Float", D, "Float", 270, "Float", 90)
      DllCall("Gdiplus.dll\GdipAddPathArc"
            , "Ptr", Path, "Float", X2, "Float", Y2, "Float", D, "Float", D, "Float", 0, "Float", 90)
      DllCall("Gdiplus.dll\GdipAddPathArc"
            , "Ptr", Path, "Float", X1, "Float", Y2, "Float", D, "Float", D, "Float", 90, "Float", 90)
      Return DllCall("Gdiplus.dll\GdipClosePathFigure", "Ptr", Path)
   }
   ; ===================================================================================================================
   SetRect(ByRef Rect, X1, Y1, X2, Y2) {
      VarSetCapacity(Rect, 16, 0)
      NumPut(X1, Rect, 0, "Int"), NumPut(Y1, Rect, 4, "Int")
      NumPut(X2, Rect, 8, "Int"), NumPut(Y2, Rect, 12, "Int")
      Return True
   }
   ; ===================================================================================================================
   SetRectF(ByRef Rect, X, Y, W, H) {
      VarSetCapacity(Rect, 16, 0)
      NumPut(X, Rect, 0, "Float"), NumPut(Y, Rect, 4, "Float")
      NumPut(W, Rect, 8, "Float"), NumPut(H, Rect, 12, "Float")
      Return True
   }
   ; ===================================================================================================================
   SetError(Msg) {
      If (This.Bitmap)
         DllCall("Gdiplus.dll\GdipDisposeImage", "Ptr", This.Bitmap)
      If (This.Graphics)
         DllCall("Gdiplus.dll\GdipDeleteGraphics", "Ptr", This.Graphics)
      If (This.Font)
         DllCall("Gdiplus.dll\GdipDeleteFont", "Ptr", This.Font)
      This.Delete("Bitmap")
      This.Delete("Graphics")
      This.Delete("Font")
      This.FreeBitmaps()
      ; This.GdiplusShutdown()
      This.LastError := Msg
      Return False
   }
   ; ===================================================================================================================
   ; PUBLIC METHODS ====================================================================================================
   ; ===================================================================================================================
   Create(HWND, Options*) {
      ; Windows constants
      Static BCM_GETIMAGELIST := 0x1603, BCM_SETIMAGELIST := 0x1602
           , BS_CHECKBOX := 0x02, BS_RADIOBUTTON := 0x04, BS_GROUPBOX := 0x07, BS_AUTORADIOBUTTON := 0x09
           , BS_LEFT := 0x0100, BS_RIGHT := 0x0200, BS_CENTER := 0x0300, BS_TOP := 0x0400, BS_BOTTOM := 0x0800
           , BS_VCENTER := 0x0C00, BS_BITMAP := 0x0080
           , BUTTON_IMAGELIST_ALIGN_LEFT := 0, BUTTON_IMAGELIST_ALIGN_RIGHT := 1, BUTTON_IMAGELIST_ALIGN_CENTER := 4
           , ILC_COLOR32 := 0x20
           , OBJ_BITMAP := 7
           , RCBUTTONS := BS_CHECKBOX | BS_RADIOBUTTON | BS_AUTORADIOBUTTON
           , SA_LEFT := 0x00, SA_CENTER := 0x01, SA_RIGHT := 0x02
           , WM_GETFONT := 0x31
      ; ----------------------------------------------------------------------------------------------------------------
      This.LastError := ""
      HBITMAP := HFORMAT := PBITMAP := PBRUSH := PFONT := PPATH := 0
      ; ----------------------------------------------------------------------------------------------------------------
      ; Check HWND
      If !DllCall("User32.dll\IsWindow", "Ptr", HWND)
         Return This.SetError("Invalid parameter HWND!")
      ; ----------------------------------------------------------------------------------------------------------------
      ; Check Options
      If !(IsObject(Options)) || (Options.MinIndex() <> 1) || (Options.MaxIndex() > This.MaxOptions)
         Return This.SetError("Invalid parameter Options!")
      ; ----------------------------------------------------------------------------------------------------------------
      ; Get and check control's class and styles
      WinGetClass, BtnClass, ahk_id %HWND%
      ControlGet, BtnStyle, Style, , , ahk_id %HWND%
      If (BtnClass != "Button") || ((BtnStyle & 0xF ^ BS_GROUPBOX) = 0) || ((BtnStyle & RCBUTTONS) > 1)
         Return This.SetError("The control must be a pushbutton!")
      ; ----------------------------------------------------------------------------------------------------------------
      ; Get the button's font
      HFONT := DllCall("User32.dll\SendMessage", "Ptr", HWND, "UInt", WM_GETFONT, "Ptr", 0, "Ptr", 0, "Ptr")
      DC := DllCall("User32.dll\GetDC", "Ptr", HWND, "Ptr")
      DllCall("Gdi32.dll\SelectObject", "Ptr", DC, "Ptr", HFONT)
      DllCall("Gdiplus.dll\GdipCreateFontFromDC", "Ptr", DC, "PtrP", PFONT)
      DllCall("User32.dll\ReleaseDC", "Ptr", HWND, "Ptr", DC)
      If !(This.Font := PFONT)
         Return This.SetError("Couldn't get button's font!")
      ; ----------------------------------------------------------------------------------------------------------------
      ; Get the button's rectangle
      VarSetCapacity(RECT, 16, 0)
      If !DllCall("User32.dll\GetWindowRect", "Ptr", HWND, "Ptr", &RECT)
         Return This.SetError("Couldn't get button's rectangle!")
      BtnW := NumGet(RECT,  8, "Int") - NumGet(RECT, 0, "Int")
      BtnH := NumGet(RECT, 12, "Int") - NumGet(RECT, 4, "Int")
      ; ----------------------------------------------------------------------------------------------------------------
      ; Get the button's caption
      ControlGetText, BtnCaption, , ahk_id %HWND%
      If (ErrorLevel)
         Return This.SetError("Couldn't get button's caption!")
      ; ----------------------------------------------------------------------------------------------------------------
      ; Create a GDI+ bitmap
      DllCall("Gdiplus.dll\GdipCreateBitmapFromScan0", "Int", BtnW, "Int", BtnH, "Int", 0
            , "UInt", 0x26200A, "Ptr", 0, "PtrP", PBITMAP)
      If !(This.Bitmap := PBITMAP)
         Return This.SetError("Couldn't create the GDI+ bitmap!")
      ; Get the pointer to its graphics
      PGRAPHICS := 0
      DllCall("Gdiplus.dll\GdipGetImageGraphicsContext", "Ptr", PBITMAP, "PtrP", PGRAPHICS)
      If !(This.Graphics := PGRAPHICS)
         Return This.SetError("Couldn't get the the GDI+ bitmap's graphics!")
      ; Quality settings
      DllCall("Gdiplus.dll\GdipSetSmoothingMode", "Ptr", PGRAPHICS, "UInt", 4)
      DllCall("Gdiplus.dll\GdipSetInterpolationMode", "Ptr", PGRAPHICS, "Int", 7)
      DllCall("Gdiplus.dll\GdipSetCompositingQuality", "Ptr", PGRAPHICS, "UInt", 4)
      DllCall("Gdiplus.dll\GdipSetRenderingOrigin", "Ptr", PGRAPHICS, "Int", 0, "Int", 0)
      DllCall("Gdiplus.dll\GdipSetPixelOffsetMode", "Ptr", PGRAPHICS, "UInt", 4)
      ; ----------------------------------------------------------------------------------------------------------------
      ; Create the bitmap(s)
      This.BitMaps := []
      For Idx, Opt In Options {
         If !IsObject(Opt)
            Continue
         BkgColor1 := BkgColor2 := TxtColor := Mode := Rounded := GuiColor := Image := ""
         ; Replace omitted options with the values of Options.1
         Loop, % This.MaxOptions {
            If (Opt[A_Index] = "")
               Opt[A_Index] := Options[1, A_Index]
         }
         ; -------------------------------------------------------------------------------------------------------------
         ; Check option values
         ; Mode
         Mode := SubStr(Opt[1], 1 ,1)
         If !InStr("0123456789", Mode)
            Return This.SetError("Invalid value for Mode in Options[" . Idx . "]!")
         ; StartColor & TargetColor
         If (Mode = 0) && This.BitmapOrIcon(Opt[2], Opt[3])
            Image := Opt[2]
         Else {
            If !This.IsInt(Opt[2]) && !This.HTML.HasKey(Opt[2])
               Return This.SetError("Invalid value for StartColor in Options[" . Idx . "]!")
            BkgColor1 := This.GetARGB(Opt[2])
            If (Opt[3] = "")
               Opt[3] := Opt[2]
            If !This.IsInt(Opt[3]) && !This.HTML.HasKey(Opt[3])
               Return This.SetError("Invalid value for TargetColor in Options[" . Idx . "]!")
            BkgColor2 := This.GetARGB(Opt[3])
         }
         ; TextColor
         If (Opt[4] = "")
            Opt[4] := This.DefTxtColor
         If !This.IsInt(Opt[4]) && !This.HTML.HasKey(Opt[4])
            Return This.SetError("Invalid value for TxtColor in Options[" . Idx . "]!")
         TxtColor := This.GetARGB(Opt[4])
         ; Rounded
         Rounded := Opt[5]
         If (Rounded = "H")
            Rounded := BtnH * 0.5
         If (Rounded = "W")
            Rounded := BtnW * 0.5
         If ((Rounded + 0) = "")
            Rounded := 0
         ; GuiColor
         If (Opt[6] = "")
            Opt[6] := This.DefGuiColor
         If !This.IsInt(Opt[6]) && !This.HTML.HasKey(Opt[6])
            Return This.SetError("Invalid value for GuiColor in Options[" . Idx . "]!")
         GuiColor := This.GetARGB(Opt[6])
         ; BorderColor
         BorderColor := ""
         If (Opt[7] <> "") {
            If !This.IsInt(Opt[7]) && !This.HTML.HasKey(Opt[7])
               Return This.SetError("Invalid value for BorderColor in Options[" . Idx . "]!")
            BorderColor := 0xFF000000 | This.GetARGB(Opt[7]) ; BorderColor must be always opaque
         }
         ; BorderWidth
         BorderWidth := Opt[8] ? Opt[8] : 1
         ; -------------------------------------------------------------------------------------------------------------
         ; Clear the background
         DllCall("Gdiplus.dll\GdipGraphicsClear", "Ptr", PGRAPHICS, "UInt", GuiColor)
         ; Create the image
         If (Image = "") { ; Create a BitMap based on the specified colors
            PathX := PathY := 0, PathW := BtnW, PathH := BtnH
            ; Create a GraphicsPath
            DllCall("Gdiplus.dll\GdipCreatePath", "UInt", 0, "PtrP", PPATH)
            If (Rounded < 1) ; the path is a rectangular rectangle
               This.PathAddRectangle(PPATH, PathX, PathY, PathW, PathH)
            Else ; the path is a rounded rectangle
               This.PathAddRoundedRect(PPATH, PathX, PathY, PathW, PathH, Rounded)
            ; If BorderColor and BorderWidth are specified, 'draw' the border (not for Mode 7)
            If (BorderColor <> "") && (BorderWidth > 0) && (Mode <> 7) {
               ; Create a SolidBrush
               DllCall("Gdiplus.dll\GdipCreateSolidFill", "UInt", BorderColor, "PtrP", PBRUSH)
               ; Fill the path
               DllCall("Gdiplus.dll\GdipFillPath", "Ptr", PGRAPHICS, "Ptr", PBRUSH, "Ptr", PPATH)
               ; Free the brush
               DllCall("Gdiplus.dll\GdipDeleteBrush", "Ptr", PBRUSH)
               ; Reset the path
               DllCall("Gdiplus.dll\GdipResetPath", "Ptr", PPATH)
               ; Add a new 'inner' path
               PathX := PathY := BorderWidth, PathW -= BorderWidth, PathH -= BorderWidth, Rounded -= BorderWidth
               If (Rounded < 1) ; the path is a rectangular rectangle
                  This.PathAddRectangle(PPATH, PathX, PathY, PathW - PathX, PathH - PathY)
               Else ; the path is a rounded rectangle
                  This.PathAddRoundedRect(PPATH, PathX, PathY, PathW, PathH, Rounded)
               ; If a BorderColor has been drawn, BkgColors must be opaque
               BkgColor1 := 0xFF000000 | BkgColor1
               BkgColor2 := 0xFF000000 | BkgColor2               
            }
            PathW -= PathX
            PathH -= PathY
            PBRUSH := 0
            If (Mode = 0) { ; the background is unicolored
               ; Create a SolidBrush
               DllCall("Gdiplus.dll\GdipCreateSolidFill", "UInt", BkgColor1, "PtrP", PBRUSH)
               ; Fill the path
               DllCall("Gdiplus.dll\GdipFillPath", "Ptr", PGRAPHICS, "Ptr", PBRUSH, "Ptr", PPATH)
            }
            Else If (Mode = 1) || (Mode = 2) { ; the background is bicolored
               ; Create a LineGradientBrush
               This.SetRectF(RECTF, PathX, PathY, PathW, PathH)
               DllCall("Gdiplus.dll\GdipCreateLineBrushFromRect", "Ptr", &RECTF
                     , "UInt", BkgColor1, "UInt", BkgColor2, "Int", Mode & 1, "Int", 3, "PtrP", PBRUSH)
               DllCall("Gdiplus.dll\GdipSetLineGammaCorrection", "Ptr", PBRUSH, "Int", 1)
               ; Set up colors and positions
               This.SetRect(COLORS, BkgColor1, BkgColor1, BkgColor2, BkgColor2) ; sorry for function misuse
               This.SetRectF(POSITIONS, 0, 0.5, 0.5, 1) ; sorry for function misuse
               DllCall("Gdiplus.dll\GdipSetLinePresetBlend", "Ptr", PBRUSH
                     , "Ptr", &COLORS, "Ptr", &POSITIONS, "Int", 4)
               ; Fill the path
               DllCall("Gdiplus.dll\GdipFillPath", "Ptr", PGRAPHICS, "Ptr", PBRUSH, "Ptr", PPATH)
            }
            Else If (Mode >= 3) && (Mode <= 6) { ; the background is a gradient
               ; Determine the brush's width/height
               W := Mode = 6 ? PathW / 2 : PathW  ; horizontal
               H := Mode = 5 ? PathH / 2 : PathH  ; vertical
               ; Create a LineGradientBrush
               This.SetRectF(RECTF, PathX, PathY, W, H)
               DllCall("Gdiplus.dll\GdipCreateLineBrushFromRect", "Ptr", &RECTF
                     , "UInt", BkgColor1, "UInt", BkgColor2, "Int", Mode & 1, "Int", 3, "PtrP", PBRUSH)
               DllCall("Gdiplus.dll\GdipSetLineGammaCorrection", "Ptr", PBRUSH, "Int", 1)
               ; Fill the path
               DllCall("Gdiplus.dll\GdipFillPath", "Ptr", PGRAPHICS, "Ptr", PBRUSH, "Ptr", PPATH)
            }
            Else { ; raised mode
               DllCall("Gdiplus.dll\GdipCreatePathGradientFromPath", "Ptr", PPATH, "PtrP", PBRUSH)
               ; Set Gamma Correction
               DllCall("Gdiplus.dll\GdipSetPathGradientGammaCorrection", "Ptr", PBRUSH, "UInt", 1)
               ; Set surround and center colors
               VarSetCapacity(ColorArray, 4, 0)
               NumPut(BkgColor1, ColorArray, 0, "UInt")
               DllCall("Gdiplus.dll\GdipSetPathGradientSurroundColorsWithCount", "Ptr", PBRUSH, "Ptr", &ColorArray
                   , "IntP", 1)
               DllCall("Gdiplus.dll\GdipSetPathGradientCenterColor", "Ptr", PBRUSH, "UInt", BkgColor2)
               ; Set the FocusScales
               FS := (BtnH < BtnW ? BtnH : BtnW) / 3
               XScale := (BtnW - FS) / BtnW
               YScale := (BtnH - FS) / BtnH
               DllCall("Gdiplus.dll\GdipSetPathGradientFocusScales", "Ptr", PBRUSH, "Float", XScale, "Float", YScale)
               ; Fill the path
               DllCall("Gdiplus.dll\GdipFillPath", "Ptr", PGRAPHICS, "Ptr", PBRUSH, "Ptr", PPATH)
            }
            ; Free resources
            DllCall("Gdiplus.dll\GdipDeleteBrush", "Ptr", PBRUSH)
            DllCall("Gdiplus.dll\GdipDeletePath", "Ptr", PPATH)
         } Else { ; Create a bitmap from HBITMAP or file
            If This.IsInt(Image)
               If (Opt[3] = "HICON")
                  DllCall("Gdiplus.dll\GdipCreateBitmapFromHICON", "Ptr", Image, "PtrP", PBM)
               Else
                  DllCall("Gdiplus.dll\GdipCreateBitmapFromHBITMAP", "Ptr", Image, "Ptr", 0, "PtrP", PBM)
            Else
               DllCall("Gdiplus.dll\GdipCreateBitmapFromFile", "WStr", Image, "PtrP", PBM)
            ; Draw the bitmap
            DllCall("Gdiplus.dll\GdipDrawImageRectI", "Ptr", PGRAPHICS, "Ptr", PBM, "Int", 0, "Int", 0
                  , "Int", BtnW, "Int", BtnH)
            ; Free the bitmap
            DllCall("Gdiplus.dll\GdipDisposeImage", "Ptr", PBM)
         }
         ; -------------------------------------------------------------------------------------------------------------
         ; Draw the caption
         If (BtnCaption <> "") {
            ; Create a StringFormat object
            DllCall("Gdiplus.dll\GdipStringFormatGetGenericTypographic", "PtrP", HFORMAT)
            ; Text color
            DllCall("Gdiplus.dll\GdipCreateSolidFill", "UInt", TxtColor, "PtrP", PBRUSH)
            ; Horizontal alignment
            HALIGN := (BtnStyle & BS_CENTER) = BS_CENTER ? SA_CENTER
                    : (BtnStyle & BS_CENTER) = BS_RIGHT  ? SA_RIGHT
                    : (BtnStyle & BS_CENTER) = BS_Left   ? SA_LEFT
                    : SA_CENTER
            DllCall("Gdiplus.dll\GdipSetStringFormatAlign", "Ptr", HFORMAT, "Int", HALIGN)
            ; Vertical alignment
            VALIGN := (BtnStyle & BS_VCENTER) = BS_TOP ? 0
                    : (BtnStyle & BS_VCENTER) = BS_BOTTOM ? 2
                    : 1
            DllCall("Gdiplus.dll\GdipSetStringFormatLineAlign", "Ptr", HFORMAT, "Int", VALIGN)
            ; Set render quality to system default
            DllCall("Gdiplus.dll\GdipSetTextRenderingHint", "Ptr", PGRAPHICS, "Int", 0)
            ; Set the text's rectangle
            VarSetCapacity(RECT, 16, 0)
            NumPut(BtnW, RECT,  8, "Float")
            NumPut(BtnH, RECT, 12, "Float")
            ; Draw the text
            DllCall("Gdiplus.dll\GdipDrawString", "Ptr", PGRAPHICS, "WStr", BtnCaption, "Int", -1
                  , "Ptr", PFONT, "Ptr", &RECT, "Ptr", 
Download .txt
gitextract_bty5ohzv/

├── .gitignore
├── GUIDefine.ahk
├── GUIDefine_Functions.ahk
├── GUIDefine_Hotkeys.ahk
├── GUIDefine_Labels.ahk
├── GUIDetails.ahk
├── GUIDetails_Functions.ahk
├── GUIDetails_Labels.ahk
├── GUIKridi.ahk
├── GUIKridiM.ahk
├── GUIKridiM_Functions.ahk
├── GUIKridiM_Hotkeys.ahk
├── GUIKridiM_Labels.ahk
├── GUIKridi_Functions.ahk
├── GUIKridi_Hotkeys.ahk
├── GUIKridi_Labels.ahk
├── GUIReview.ahk
├── GUIReview_Functions.ahk
├── GUIReview_Hotkeys.ahk
├── GUIReview_Labels.ahk
├── GUISell.ahk
├── GUISell_Functions.ahk
├── GUISell_Hotkeys.ahk
├── GUISell_Labels.ahk
├── GUISubmit.ahk
├── GUISubmit_Functions.ahk
├── GUISubmit_Hotkeys.ahk
├── GUISubmit_Labels.ahk
├── GUIUpdate.ahk
├── GUIUser.ahk
├── GUIUser_Functions.ahk
├── GUIUser_Hotkeys.ahk
├── GUIUser_Labels.ahk
├── GenerateRelease.ahk
├── Import.ahk
├── Install.ahk
├── Lib/
│   ├── Classes/
│   │   ├── Class_CtlColors.ahk
│   │   ├── Class_GDIplus.ahk
│   │   ├── Class_ImageButton.ahk
│   │   └── Class_RichEdit.ahk
│   └── Language.ahk
├── README.md
├── StartUp.ahk
├── Template.css
├── Template.html
├── Template.js
├── Uninstall.ahk
└── Version.txt
Condensed preview — 48 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (325K chars).
[
  {
    "path": ".gitignore",
    "chars": 88,
    "preview": "__Compiler/\n__Release/\nCKr/\nCurr/\nDump/\nHighChart/\nHist/\nKr/\nSets/\nUnvalid/\nValid/\n*.ico"
  },
  {
    "path": "GUIDefine.ahk",
    "chars": 4687,
    "preview": "#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\"
  },
  {
    "path": "GUIDefine_Functions.ahk",
    "chars": 7138,
    "preview": "LoadGroups() {\n    Global _74\n    GuiControl,, Group, |\n    GuiControl,, Group, % _74\n    Loop, Files, Sets\\Def\\*, D\n   "
  },
  {
    "path": "GUIDefine_Hotkeys.ahk",
    "chars": 2808,
    "preview": "#If WinActive(\"ahk_id \" Main)\n    Enter::\n        If !VerifyInputs()\n            Return\n        If (!EditModOn) {\n      "
  },
  {
    "path": "GUIDefine_Labels.ahk",
    "chars": 3427,
    "preview": "DelGroup:\n    GuiControlGet, Group,, Group\n    If (Group != \"ALL\") {\n        Msgbox, 36,% _187, % _194 \" \" Group \" ?\"\n  "
  },
  {
    "path": "GUIDetails.ahk",
    "chars": 2185,
    "preview": "#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\C"
  },
  {
    "path": "GUIDetails_Functions.ahk",
    "chars": 652,
    "preview": "ConvertMillimsToDT(Value, Sign := \"\") {\n    If (Value = \"...\" || !Value)\n        Return\n    ValueArr := StrSplit(Value /"
  },
  {
    "path": "GUIDetails_Labels.ahk",
    "chars": 665,
    "preview": "GuiClose:\nExitApp\n\nDisplayDetails:\n    GuiControlGet, ReInLB,, ReInLB\n    If (ReInLB) {\n        GuiControl,, DInfo, % _2"
  },
  {
    "path": "GUIKridi.ahk",
    "chars": 1385,
    "preview": "#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\Class_CtlColors.ahk\n#Includ"
  },
  {
    "path": "GUIKridiM.ahk",
    "chars": 4360,
    "preview": "#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\Class_CtlColors.ahk\n#Includ"
  },
  {
    "path": "GUIKridiM_Functions.ahk",
    "chars": 4577,
    "preview": "FolderSet() {\n    Array := [ \"Curr\"\n             , \"Sets\"\n             , \"Sets\\Def\"\n             , \"Valid\"\n             "
  },
  {
    "path": "GUIKridiM_Hotkeys.ahk",
    "chars": 420,
    "preview": "#If WinActive(\"ahk_id \" Main)\n    Delete::\n        GuiControlGet, KLB,, KLB\n        If (KLB) {\n            MsgBox, 36, %"
  },
  {
    "path": "GUIKridiM_Labels.ahk",
    "chars": 2827,
    "preview": "ShowKridiInfo:\n    GuiControlGet, KLB,, KLB\n    If (KLB) {\n        DateRow := KridiDates(KLB)\n        PayVal := PayDates"
  },
  {
    "path": "GUIKridi_Functions.ahk",
    "chars": 1455,
    "preview": "LoadKridiUsers() {\n    GuiControl, , KLB, |\n    Loop, Files, % \"Kr\\*\", D\n        GuiControl,, KLB, % A_LoopFileName\n\n   "
  },
  {
    "path": "GUIKridi_Hotkeys.ahk",
    "chars": 338,
    "preview": "#If WinActive(\"ahk_id \" Kridi)\n    Enter::\n        GuiControlGet, KName,, KName\n        If (KName = \"\")\n            GuiC"
  },
  {
    "path": "GUIKridi_Labels.ahk",
    "chars": 521,
    "preview": "GuiClose:\n    FileDelete, % \"Dump\\Kridi.sell\"\nExitApp\n\nCheckKExist:\n    GuiControlGet, KName,, KName\n    GuiControl, Cho"
  },
  {
    "path": "GUIReview.ahk",
    "chars": 3349,
    "preview": "#SingleInstance, Force\nSetBatchLines, -1\n#NoEnv\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\Class_CtlColors.ahk"
  },
  {
    "path": "GUIReview_Functions.ahk",
    "chars": 6065,
    "preview": "FolderSet() {\n    Array := [ \"Curr\"\n             , \"Sets\"\n             , \"Sets\\Def\"\n             , \"Valid\"\n             "
  },
  {
    "path": "GUIReview_Hotkeys.ahk",
    "chars": 309,
    "preview": "#If WinActive(\"ahk_id \" Main)\nEnter::\n    GuiControlGet, Begin,, Begin\n    GuiControlGet, End,, End\n    GuiControl, Choo"
  },
  {
    "path": "GUIReview_Labels.ahk",
    "chars": 5439,
    "preview": "ShowDetails:\n    GuiControlGet, ProfByProduct,, ProfByProduct\n    If (!(Row := LV_GetNext()) || ProfByProduct = 2)\n     "
  },
  {
    "path": "GUISell.ahk",
    "chars": 6778,
    "preview": "#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\n#NoEnv\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\C"
  },
  {
    "path": "GUISell_Functions.ahk",
    "chars": 8031,
    "preview": "ConvertMillimsToDT(Value, Sign := \"\") {\n    If (Value = \"...\" || !Value)\n        Return\n    ValueArr := StrSplit(Value /"
  },
  {
    "path": "GUISell_Hotkeys.ahk",
    "chars": 11536,
    "preview": "#If WinActive(\"ahk_id \" Main)\n    Enter::\n        GuiControlGet, Bc, , Bc\n        GuiControl, Disabled, Bc\n        If (!"
  },
  {
    "path": "GUISell_Labels.ahk",
    "chars": 5003,
    "preview": "GuiClose:\n    IniDelete, Sets\\PID.ini, PID, GUISell\nExitApp\n\nLaunchKeyboard:\n    Run, osk.exe\nReturn\n\nSubKridi:\n    Obj "
  },
  {
    "path": "GUISubmit.ahk",
    "chars": 3229,
    "preview": "#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\"
  },
  {
    "path": "GUISubmit_Functions.ahk",
    "chars": 5353,
    "preview": "ThemeAdd() {\n    Loop, 5 {\n        Gui, Add, Text, % \"y0 x\" 208 + A_Index * 2 \" w1 h\" A_ScreenHeight \" HwndHCtrl\"\n      "
  },
  {
    "path": "GUISubmit_Hotkeys.ahk",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "GUISubmit_Labels.ahk",
    "chars": 5161,
    "preview": "Valid:\n    MsgBox, 33, % _174, % _175\n    IfMsgBox, OK\n    {\n        FileCreateDir, % \"Valid\\\" (Now := A_Now)\n        Lo"
  },
  {
    "path": "GUIUpdate.ahk",
    "chars": 653,
    "preview": "#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\n#NoEnv\nSetWorkingDir, % A_ScriptDir\n\nGui, Font, Bold"
  },
  {
    "path": "GUIUser.ahk",
    "chars": 3463,
    "preview": "#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\Classes\\"
  },
  {
    "path": "GUIUser_Functions.ahk",
    "chars": 3145,
    "preview": "FolderSet() {\n    Array := [ \"Curr\"\n             , \"Sets\"\n             , \"Sets\\Def\"\n             , \"Valid\"\n            "
  },
  {
    "path": "GUIUser_Hotkeys.ahk",
    "chars": 318,
    "preview": "#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.\n; #Warn  ; Enable warnings to "
  },
  {
    "path": "GUIUser_Labels.ahk",
    "chars": 1988,
    "preview": "ShowInfo:\n    If (R := LV_GetNext()) {\n        LV_GetText(Nm, R, 1)\n        LV_GetText(Pw, R, 2)\n        LV_GetText(Lv,"
  },
  {
    "path": "GenerateRelease.ahk",
    "chars": 6124,
    "preview": "#Requires AutoHotkey v1.1\n#NoEnv\nSendMode Input\nSetWorkingDir %A_ScriptDir%\nSetBatchLines, -1\n\n#Persistent\n#SingleInsta"
  },
  {
    "path": "Import.ahk",
    "chars": 31805,
    "preview": "#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\nGui, Font, Bold s10, Co"
  },
  {
    "path": "Install.ahk",
    "chars": 5792,
    "preview": "#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\nFileInstall, __Release"
  },
  {
    "path": "Lib/Classes/Class_CtlColors.ahk",
    "chars": 16021,
    "preview": "; ====================================================================================================================="
  },
  {
    "path": "Lib/Classes/Class_GDIplus.ahk",
    "chars": 993,
    "preview": "class GDIplus {\n    __New() {\n        if !DllCall(\"GetModuleHandle\", \"Str\", \"gdiplus\", \"Ptr\")\n            DllCall(\"Load"
  },
  {
    "path": "Lib/Classes/Class_ImageButton.ahk",
    "chars": 31638,
    "preview": "; ====================================================================================================================="
  },
  {
    "path": "Lib/Classes/Class_RichEdit.ahk",
    "chars": 82420,
    "preview": "; ====================================================================================================================="
  },
  {
    "path": "Lib/Language.ahk",
    "chars": 8174,
    "preview": ";////////////////////////////////////////////////////////////////////////////////////////////////////\n/*\n    GUI Interf"
  },
  {
    "path": "README.md",
    "chars": 1,
    "preview": "\n"
  },
  {
    "path": "StartUp.ahk",
    "chars": 9759,
    "preview": "#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\n#NoEnv\nSetWorkingDir, % A_ScriptDir\n\n#Include, Lib\\C"
  },
  {
    "path": "Template.css",
    "chars": 783,
    "preview": ".highcharts-figure,\n.highcharts-data-table table {\n    min-width: 360px;\n    max-width: 100%;\n    margin: 1em auto;\n}\n\n."
  },
  {
    "path": "Template.html",
    "chars": 554,
    "preview": "<script src=\"HighChart/highcharts.js\"></script>\n<script src=\"HighChart/modules/series-label.js\"></script>\n<script src=\"H"
  },
  {
    "path": "Template.js",
    "chars": 1213,
    "preview": "Highcharts.chart('container', {\n    chart: {\n        type: 'line',\n    },\n    \n    title: {\n        text: 'CASH HELPER C"
  },
  {
    "path": "Uninstall.ahk",
    "chars": 1417,
    "preview": "#Requires AutoHotkey v1.1\n#SingleInstance, Force\nSetBatchLines, -1\nSetWorkingDir, % A_ScriptDir\n\nFileInstall, Uninstall."
  },
  {
    "path": "Version.txt",
    "chars": 7,
    "preview": "2.0.2.0"
  }
]

About this extraction

This page contains the full source code of the FreeP4lestine/Lost-Crypto-Finder-Helper GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 48 files (296.9 KB), approximately 93.3k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!