; ENVIRONMENT
;------------------------------------------------
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
;#Warn  ; Enable warnings to assist with detecting common errors.
;DetectHiddenWindows, On
#SingleInstance, Force
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
;SetKeyDelay, 500
CoordMode, ToolTip, Screen
CoordMode, Mouse, Screen
;#NoTrayIcon

; Notes/Extra Info/#Includes
;------------------------------------------------
#Include C:\Users\%A_Username%\Syncthing\Scripts\AutoHotKey\RadialMenu\My codes\My Global Variables.ahk
Menu, Tray, Icon, %A_ICODir%\git.ico



; VARIABLES
;------------------------------------------------
InputBox, CommitMessage, Commit Message, Input Commit Message ; , Title, Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default]
if(ErrorLevel)
	ExitApp

IniRead, GUIVersion,%A_ScriptDir%\Installs\Misc\Toolbox-Settings.ini, General,Version, %A_Space% ; , Key [, Default]
GUIVersion += 1

IniWrite, %GUIVersion%, %A_ScriptDir%\Installs\Misc\Toolbox-Settings.ini, General,Version



; MAIN SCRIPT
;------------------------------------------------
runwait, "C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in "%A_ScriptDir%\Windows-Toolbox.ahk" /out "%A_ScriptDir%\Windows-Toolbox.exe" /icon "%A_ScriptDir%\Installs\Icons\Windows.ico"
; msgbox
sleep, 1000
; runwait, "C:\Users\ity\Syncthing\Scripts\AutoHotKey\Tools\CommandLineTools\CreateSynchronicity\CreateSynchronicity.exe" /quiet /run "ITToolboxToSMB"

CmdLine = git add . 

status := RunCMD(CmdLine, WorkingDir:=A_ScriptDir)
; Msgbox % "status: " status



CmdLine = git commit -m "%CommitMessage%"
status := RunCMD(CmdLine, WorkingDir:=A_ScriptDir)
; Msgbox % "status: " status


CmdLine = git push

status := RunCMD(CmdLine, WorkingDir:=A_ScriptDir)
Oldnotify(status)
; Msgbox % "status: " status

CenterTooltipOnScreen("Waiting 5 seconds before Pulling New changes on SMB Server")

; Tooltip, 
sleep, 5000


command = powershell %A_ScriptDir%\Installs\PowerShell\GitPullWMTToolboxOnSMBThroughOlivetin.ps1
try Status := RunCMD(command)
Oldnotify(status)

sleep, 5000
ExitApp





; Functions
;------------------------------------------------