Jump to content
Sign in to follow this  
Trait

GUI Time Difference Calc

Recommended Posts

Trait

;Loss of Hours and minutes between two days in a month

#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("LostTime", 327, 287,(@DesktopWidth-407)/2, (@DesktopHeight-347)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Label_0 = GuiCtrlCreateLabel("Time calc to find lost hours", 60, 20, 240, 30)

GUICtrlSetFont ($label_0,14)

$Label_1 = GuiCtrlCreateLabel("Start", 30, 50, 100, 30)

GUICtrlSetFont ($label_1,18)

$Label_2 = GuiCtrlCreateLabel("Day", 30, 90, 40, 30)

GUICtrlSetFont ($label_2,12)

$Label_3 = GuiCtrlCreateLabel("Hour", 30, 130, 40, 30)

GUICtrlSetFont ($label_3,12)

$Label_4 = GuiCtrlCreateLabel("Minute", 30, 170, 60, 30)

GUICtrlSetFont ($label_4,12)

$Label_5 = GuiCtrlCreateLabel("End", 210, 50, 100, 30)

GUICtrlSetFont ($label_5,18)

$Label_6 = GuiCtrlCreateLabel("Day", 210, 90, 40, 30)

GUICtrlSetFont ($label_6,12)

$Label_7 = GuiCtrlCreateLabel("Hour", 210, 130, 40, 30)

GUICtrlSetFont ($label_7,12)

$Label_8 = GuiCtrlCreateLabel("Minute", 210, 170, 60, 30)

GUICtrlSetFont ($label_8,12)

$StartDay = GuiCtrlCreateInput("", 80, 90, 40, 20)

$DaySlider1 = GUICtrlCreateUpdown($StartDay)

GUICtrlSetLimit( $DaySlider1,31,1)

$SHour = GuiCtrlCreateInput("", 80, 130, 40, 20)

$HourSlider1 = GUICtrlCreateUpdown($SHour)

GUICtrlSetLimit( $HourSlider1,23,0)

$StartMin = GuiCtrlCreateInput("", 80, 170, 40, 20)

$MinSlider1 = GUICtrlCreateUpdown($StartMin)

GUICtrlSetLimit( $MinSlider1,59,0)

$EndDay = GuiCtrlCreateInput("", 260, 90, 40, 20)

$DaySlider2 = GUICtrlCreateUpdown($EndDay)

GUICtrlSetLimit( $DaySlider2,31,1)

$EHour = GuiCtrlCreateInput("", 260, 130, 40, 20)

$HourSlider2 = GUICtrlCreateUpdown($EHour)

GUICtrlSetLimit( $HourSlider2,23,0)

$EndMin = GuiCtrlCreateInput("", 260, 170, 40, 20)

$MinSlider2 = GUICtrlCreateUpdown($EndMin)

GUICtrlSetLimit( $MinSlider2,59,0)

$Calculate = GuiCtrlCreateButton("Tell me", 30, 230, 120, 50)

GUICtrlSetOnEvent( $Calculate ,"Calc")

GUICtrlSetFont ($Calculate,16)

GuiSetState()

HotKeySet("{End}","Calc")

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Calculate

call ("Calc")

Case Else

EndSelect

WEnd

Exit

Func Calc()

$Day1 = GUICtrlRead( $StartDay)

$Day2 = GUICtrlRead( $EndDay)

$Hour1 = GUICtrlRead( $SHour)

$Hour2 = GUICtrlRead( $EHour)

$Min1 = GUICtrlRead( $StartMin)

$Min2 = GUICtrlRead( $EndMin)

$DifDay = ($Day2 - $Day1)*24

$DifHour = $Hour2 - $Hour1

$DifMin = $Min2-$Min1

If $DifMin < 0 Then

$DifHour = $DifHour - 1

$DifMin = $DifMin + 60

EndIf

$THour = $DifDay + $DifHour

TrayTip("LostTime","",0)

TrayTip("LostTime","Hours "&$THour&" "&"Mins "&$DifMin,1)

$LostMW = GUICtrlCreateLabel("Hours:"&$THour&@CR&"Minutes:"&$DifMin, 170, 230, 105, 65)

GUICtrlSetFont ($LostMW,16)

EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×