Jump to content

Time Breakdown Converter


gseller
 Share

Recommended Posts

Here is a lil project I put together for folks at work testing circiuts with telco's.. You type in the time you have been testing and it will breakdown the calculations for ya. Thought someone might enjoy not having to make it from scratch.. LOL Download Here

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.12.0 
 Author:         gseller

 Script Function:
Conversion Sites
[url="http://www.onlineconversion.com/time.htm"]http://www.onlineconversion.com/time.htm[/url]
[url="http://www.calculateme.com/Time/index.htm"]http://www.calculateme.com/Time/index.htm[/url]

 

#ce ----------------------------------------------------------------------------

#include <GUIConstants.au3>

Global Const $SS_SUNKEN   = 0x1000
Global Const $WM_COMMAND = 0x0111
Global Const $UDS_ALIGNLEFT   = 0x0008
Global Const $ES_RIGHT = 2
Global Const $ES_LEFT = 0

;Create GUI
$AForm1 = GUICreate("Time Breakdown", 510, 150, 417, 181)

;Create The Group
$MainGrp = GUICtrlCreateGroup("Time Converter", 8, 8, 490, 113)

;Create Labels
$mmLabel = GUICtrlCreateLabel("MilliSeconds", 24, 56, 75, 17)
$sLabel = GUICtrlCreateLabel("Seconds", 118, 56, 75, 17)
$mLabel = GUICtrlCreateLabel("Minutes", 191, 56, 75, 17)
$hLabel = GUICtrlCreateLabel("Hours", 278, 56, 75, 17)
$hLabel = GUICtrlCreateLabel("Days", 362, 56, 75, 17)
$hLabel = GUICtrlCreateLabel("Weeks", 438, 56, 55, 17)

;Create inputs
$mm = GUICtrlCreateInput("", 16, 32, 73, 21, $ES_LEFT)
$s = GUICtrlCreateInput("", 97, 32, 73, 21, $ES_LEFT)
$m = GUICtrlCreateInput("", 176, 32, 73, 21, $ES_LEFT)
$h = GUICtrlCreateInput("", 255, 32, 73, 21, $ES_LEFT)
$d = GUICtrlCreateInput("", 336, 32, 73, 21, $ES_LEFT)
$w = GUICtrlCreateInput("", 417, 32, 73, 21, $ES_LEFT)

;Create buttons
$clear = GUICtrlCreateButton("CLEAR", 88, 90, 105, 25)
$Exit = GUICtrlCreateButton("EXIT", 250, 90, 105, 25)

;Create status bar
$Status = GUICtrlCreateLabel("", 0, 133, 510, 17,$SS_SUNKEN)
GUISetState(@SW_SHOW)

;Conversion handler
GUIRegisterMsg($WM_COMMAND,"_TEST")
$i = 0
Func _TEST($hWnd, $Msg, $wParam, $lParam)
    Local $nNotifyCode    = BitShift($wParam, 16)
    Local $nID            = BitAnd($wParam, 0x0000FFFF)
    Local $hCtrl          = $lParam
    Local $EN_CHANGE =  0x0300
    If $nNotifyCode = $EN_CHANGE Then
    Switch $nID
        Case $mm
            MMConvert()
        Case $s
            SConvert()
        Case $m
            MConvert()
        Case $h
            HConvert()
        Case $d
            DConvert()
        Case $w
            WConvert()
    EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

;Creat loop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_Event_Close
            Exit 0
  Case $msg = $clear
   GUICtrlSetData($mm,"")
   GUICtrlSetData($s,"")
   GUICtrlSetData($m,"")
   GUICtrlSetData($h,"")
   GUICtrlSetData($d,"")
   GUICtrlSetData($w,"")
  Case $msg = $Exit
   Exit
    EndSelect
WEnd

Func MMConvert()   ;==>MMConvert
    $r = GUICtrlRead($mm)
If $r > 0 Then
    GUICtrlSetData($Status,"")
 
 GUICtrlSetData($mm, Number($r))
 GUICtrlSetData($s, Number($r/1000))
 GUICtrlSetData($m, Number($r/60000))
 GUICtrlSetData($h, Number($r/3600000))
 GUICtrlSetData($d, Number($r/86400000 )) 
 GUICtrlSetData($w, Number($r/604800000)) 
Else
        GUICtrlSetData($Status,"Please input P Number")
EndIf

EndFunc   ;==>MMConvert

Func SConvert()   ;==>SConvert
    $r = GUICtrlRead($s)
If $r > 0 Then
 GUICtrlSetData($Status,"")
 GUICtrlSetData($mm, Number($r * 1000))
 GUICtrlSetData($s, Number($r))
 GUICtrlSetData($m, Number($r /60))
 GUICtrlSetData($h, Number($r/3600))
 GUICtrlSetData($d, Number($r/86400)) 
 GUICtrlSetData($w, Number($r/604800)) 
Else
        GUICtrlSetData($Status,"Please input S Number")
EndIf

EndFunc   ;==>SConvert

Func MConvert()   ;==>MConvert
    $r = GUICtrlRead($m)
If $r > 0 Then
 GUICtrlSetData($Status,"")
 GUICtrlSetData($mm, Number($r * 60000))
 GUICtrlSetData($s, Number($r * 60))
 GUICtrlSetData($m, Number($r))
 GUICtrlSetData($h, Number($r/60)) 
 GUICtrlSetData($d, Number($r/1440)) 
 GUICtrlSetData($w, Number($r/10080)) 
Else
        GUICtrlSetData($Status,"Please input a digit")
EndIf

EndFunc   ;==>MConvert

Func HConvert()   ;==>HConvert
    $r = GUICtrlRead($h)
If $r > 0 Then
 GUICtrlSetData($Status,"")
 GUICtrlSetData($mm, Number($r * 3600000))
 GUICtrlSetData($s, Number($r * 3600))
 GUICtrlSetData($m, Number($r * 60))
 GUICtrlSetData($h, Number($r))
 GUICtrlSetData($d, Number($r/24)) 
 GUICtrlSetData($w, Number($r/168)) 
Else
        GUICtrlSetData($Status,"Please input a digit")
EndIf

EndFunc   ;==>HConvert

Func DConvert()   ;==>DConvert
    $r = GUICtrlRead($d)
If $r > 0 Then
 GUICtrlSetData($Status,"")
 GUICtrlSetData($mm, Number($r * 86400000))
 GUICtrlSetData($s, Number($r * 86400))
 GUICtrlSetData($m, Number($r * 1440))
 GUICtrlSetData($h, Number($r * 24))
 GUICtrlSetData($d, Number($r)) 
 GUICtrlSetData($w, Number($r/7)) 
Else
        GUICtrlSetData($Status,"Please input a digit")
EndIf

EndFunc   ;==>DConvert

Func WConvert()   ;==>WConvert
    $r = GUICtrlRead($w)
If $r > 0 Then
 GUICtrlSetData($Status,"")
 GUICtrlSetData($mm, Number($r * 604800000))
 GUICtrlSetData($s, Number($r * 604800))
 GUICtrlSetData($m, Number($r * 10080))
 GUICtrlSetData($h, Number($r * 168 ))
 GUICtrlSetData($d, Number($r * 7)) 
 GUICtrlSetData($w, Number($r)) 
Else
        GUICtrlSetData($Status,"Please input a digit")
EndIf

EndFunc   ;==>WConvert
Link to comment
Share on other sites

I love it! Nicely done :)

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

I found a bug:

Posted Image

I just put in 456 ms.

Or any seconds less than 10, any minutes less than 1

One solution for MMConvert is

Func MMConvert() ;==>MMConvert
    $r = GUICtrlRead($mm)
If $r > 0 Then
    GUICtrlSetData($Status,"")
 
 GUICtrlSetData($mm, Number($r))
 GUICtrlSetData($s, StringFormat("%f",$r/1000))
 GUICtrlSetData($m, StringFormat("%f",$r/60000))
 GUICtrlSetData($h, StringFormat("%f",$r/3600000))
 GUICtrlSetData($d, StringFormat("%f",$r/86400000 ))
 GUICtrlSetData($w,StringFormat("%f",$r/604800000))
Else
        GUICtrlSetData($Status,"Please input P Number")
EndIf

Apart from that, my life is now complete - I know that 1 million seconds is 11.574 days.(approximately)

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...