Anonymous Anonymous - 1 month ago
161 0

No description

AutoHotkey

Embroidery Cost Analysis GUI

#SingleInstance, Force



;------------------------------------------------------
Gui, Add, GroupBox, x2 y0 w980 h90 , 
Gui, Add, GroupBox, x22 y110 w460 h200 , Basic
Gui, Add, GroupBox, x22 y320 w460 h290 , Cost of Operation Calculator
Gui, Add, GroupBox, x502 y110 w460 h500 , 
;------------------------------------------------------
Gui, Add, Text, x42 y130 h20 , Stitches Per Minute
Gui, Add, Edit, x42 y150 w100 h20 number vsts_pm_edit gUpdateGUI, 650
;------------------------------------------------------
;Gui, Add, Text, x42 y190 h20 , Hourly Cost of Operation:
;Gui, Add, Text, x32 y212 h20 , $
;Gui, Add, Edit, x42 y210 w100 h20 vhco_edit gUpdateGUI, 25

Gui, Add, Text, x172 y130 h20 , Hourly Cost of Operation
Gui, Add, Text, x162 y153 h20 , $
Gui, Add, Edit, x172 y150 w100 h20 vhco_edit gUpdateGUI hwndHCO_Handle, 25
;------------------------------------------------------
;Gui, Add, Text, x42 y240  r2 , Production Time Lost Per Hour:`n(thread breaks, color changes, thread trims, machine setup, hoop swap, setup, finishing, etc.)
;Gui, Add, Edit, x42 y270 w100 h20 number vproduction_time_lost_ph_edit gUpdateGUI, 20
;Gui, Add, Text, x145 y273  h20 , (minutes)

Gui, Add, Text, x303 y130 r2 , Production Time Lost Per Hour ;`n(thread breaks, color changes, thread trims, machine setup, hoop swap, setup, finishing, etc.)
Gui, Add, Edit, x303 y150 w100 h20 number vproduction_time_lost_ph_edit gUpdateGUI hwndPTLPH_Handle, 20
Gui, Add, Text, x405 y153 h20 , (minutes)
;------------------------------------------------------
;Gui, Add, Text, x172 y130 w100 h20 , Stitch Count:
;Gui, Add, Edit, x172 y150 w100 h20 number vsts_count_edit gUpdateGUI, 

Gui, Add, Text, x42 y190 h20 , Stitch Count
Gui, Add, Edit, x42 y210 w100 h20 number vsts_count_edit gUpdateGUI, 
;------------------------------------------------------
Gui, Add, Text, x172 y190 h20 , Total Embroidery Heads
Gui, Add, Edit, x172 y210 w100 h20 number vembroidery_head_count_edit gUpdateGUI, 
;------------------------------------------------------
Gui, Add, Text, x303 y190 h20 , Number of Hats (Units)
Gui, Add, Edit, x303 y210 w100 h20 number vunit_count_edit gUpdateGUI, 
;------------------------------------------------------
Gui, Add, Text, x42 y250 h20 , Cost Per Unit
Gui, Add, Text, x32 y273 h20 , $
Gui, Add, Edit, x42 y270 w100 h20 vcp_unit_edit gUpdateGUI hwndCP_Unit_Handle, 0.00
Gui, Add, Text, x145 y273 w300 h20 ,
;------------------------------------------------------
Gui, Add, Text, x172 y250 h20 , Desired Markup
Gui, Add, Text, x275 y273 h20 , `%
Gui, Add, Edit, x172 y270 w100 h20 vmarkup_edit gUpdateGUI, 
;------------------------------------------------------
Gui, Add, Text, x512 y130 h20 , Cost Per
Gui, Add, ComboBox, x556 y127 w60 vcp_sts_ddl gUpdateGUI, 1|10|100|1000||10000
Gui, Add, Text, x620 y130 h20 , Stitches
Gui, Add, edit, x512 y150 w100 h20 vcpvar_sts_text ReadOnly hwndCP_Var_Stitches_Handle, $%var_cpvar_sts%


;Gui, Add, Text, x512 y130 h20 , Cost Per 1000 Stitches:
;Gui, Add, edit, x302 y150 w100 h20 vcp1k_sts_text ReadOnly, $%var_cp1k_sts%

;Gui, Add, Text, x512 y190 h20 , Investment Per Unit Produced
;Gui, Add, Text, x512 y210 w100 h20 vinvestment_per_unit_text, $%var_investment_per_unit%

Gui, Add, Text, x512 y190 h20 , Units Sewn Per Hour
Gui, Add, Text, x512 y210 w100 h20 vunit_sewn_ph_text, %var_unit_sewn_ph%

Gui, Add, Text, x512 y250 h20 , Investment Per Unit Produced
Gui, Add, Text, x512 y270 w100 h20 vinvestment_per_unit_text, $%var_investment_per_unit%

;Gui, Add, Text, x512 y250 w100 h20 , Cost of Operation:
;Gui, Add, Text, x512 y270 w100 h20 vcost_of_operation_text, $%var_cost_of_operation%

Gui, Font, s12 w700
Gui, Add, Text, x512 y310 r1 , Break-Even Figure
Gui, Add, Text, x512 y330 w400 r1 vbreak_even_text, $%var_break_even%
Gui, Font, s9 w400

Gui, Add, Text, x682 y190 h20 , Total Time Required
Gui, Add, Text, x682 y210 w100 h20 vtime_required_text, %var_time_required%

;------------------------------------------------------
AddTooltip(PTLPH_Handle,"Total production time lost(per hour, per machine) due to thread breaks, color changes, thread trims, machine setup, hoop swap, setup, finishing, etc.")
AddTooltip(HCO_Handle,"All of the projected costs(per hour).`nThis should be equal to the sum of all employee's wages in addition to the cost of all resources used.")
AddTooltip(CP_Unit_Handle,"Include shipping, taxes, COD, etc")
AddTooltip(CP_Var_Stitches_Handle,"Cost Per Stitch = Hourly Cost of Operation / Stitches Produced Per Hour")

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




;Gui, Show, Center h616 w988, New GUI Window
Gui, Show, Center h700 w988, New GUI Window

return

UpdateGUI:
{
GuiControlGet, sts_pm_edit
GuiControlGet, production_time_lost_ph_edit
GuiControlGet, sts_count_edit
GuiControlGet, unit_count_edit
GuiControlGet, embroidery_head_count_edit
GuiControlGet, cp_unit_edit
GuiControlGet, markup_edit
GuiControlGet, hco_edit
GuiControlGet, cp_sts_ddl
;------------------------------------------------------
var_eyco := 60000 ;estimated yearly costs of operation
var_owpy := 48 ;weeks to operate business per year
var_wco := var_eyco/var_owpy ;weekly cost of operation
var_dco := var_wco/5 ;daily cost of operation
;var_hco := var_dco/40 ;hourly cost of operation
var_hco := hco_edit
;------------------------------------------------------
var_sts_pm := sts_pm_edit ;stitches per minute
var_production_time_lost_ph := production_time_lost_ph_edit ;production time lost(per hour) due to thread breaks, color changes, thread trims, machine setup, hoop swap, setup, finishing, etc. 
var_sts_produced_ph := (var_sts_pm*60)-(var_sts_pm*60)*((var_production_time_lost_ph*(100/60))/100) ;expected stitches to be produced per hour
var_cp_sts := var_hco/var_sts_produced_ph ;cost per stitch
var_cp1k_sts := Round(var_cp_sts*1000,2) ;cost per 1000 stitches
var_sts_count := sts_count_edit ;stitch count
var_cpvar_sts := var_cp_sts*cp_sts_ddl,2 ;cost per variable stitchs


var_unit_count := unit_count_edit ;total number of units
var_embroidery_head_count := embroidery_head_count_edit ;number of embroidery heads in use.
var_unit_sewn_ph := Round((var_sts_produced_ph*var_embroidery_head_count) / var_sts_count,2) ;units sewn per hour
var_cp_unit := cp_unit_edit ;cost per unit(including shipping, taxes, COD, etc)
var_investment_per_unit := Round((var_hco/var_unit_sewn_ph)+var_cp_unit,2)
var_markup := markup_edit ;desired markup


var_break_even := Round(var_unit_count*var_investment_per_unit,2) ;break-even figure
var_total_income :=  ;total income
var_revenue :=  ;revenue
var_time_required := Round(var_unit_count/var_unit_sewn_ph,2) ;estimated time required to complete the job
var_cost_of_operation := Round(var_time_required * var_hco,2) ;total cost of operation based on time required and hourly cost of operation


if production_time_lost_ph_edit > 60
{
GuiControl,,production_time_lost_ph_edit, 60
Send {End}
}





GuiControl,,cpvar_sts_text, $%var_cpvar_sts%
GuiControl,,investment_per_unit_text, $%var_investment_per_unit%
;GuiControl,,cost_of_operation_text, $%var_cost_of_operation_text%
GuiControl,,break_even_text, $%var_break_even%
GuiControl,,unit_sewn_ph_text, %var_unit_sewn_ph%
GuiControl,,time_required_text, %var_time_required% Hours

}
Return

GuiClose:
ExitApp


; ### End Code #####

AddToolTip(con,text,Modify = 0){
  Static TThwnd,GuiHwnd
  If (!TThwnd){
    Gui,+LastFound
    GuiHwnd:=WinExist()
    TThwnd:=CreateTooltipControl(GuiHwnd)
  }
  Varsetcapacity(TInfo,44,0)
  Numput(44,TInfo)
  Numput(1|16,TInfo,4)
  Numput(GuiHwnd,TInfo,8)
  Numput(con,TInfo,12)
  Numput(&text,TInfo,36)
  Detecthiddenwindows,on
  If (Modify){
    SendMessage,1036,0,&TInfo,,ahk_id %TThwnd%
  }
  Else {
    Sendmessage,1028,0,&TInfo,,ahk_id %TThwnd%
    SendMessage,1048,0,300,,ahk_id %TThwnd%
  }
  
}

CreateTooltipControl(hwind){
  Ret:=DllCall("CreateWindowEx"
          ,"Uint",0
          ,"Str","TOOLTIPS_CLASS32"
          ,"Uint",0
          ,"Uint",2147483648 | 3
          ,"Uint",-2147483648
          ,"Uint",-2147483648
          ,"Uint",-2147483648
          ,"Uint",-2147483648
          ,"Uint",hwind
          ,"Uint",0
          ,"Uint",0
          ,"Uint",0)
          
  Return Ret
}