Code : Tout sélectionner
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.2.10.0
Author: Damian Iste
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
#include <GuiConstants.au3>
GuiCreate("Age des rats", 380, 190)
$date1=GuiCtrlCreateDate("", 5, 0, 200, 20,$DTS_RIGHTALIGN )
GuiCtrlCreateLabel("Date de naissance du rat", 10, 20, 200, 20)
$button1=GuiCtrlCreatecombo("Rat predefinit", 250, 00, 120, 100)
$date2=GuiCtrlCreateDate("", 5, 40, 200, 20,$DTS_RIGHTALIGN )
GuiCtrlCreateLabel("Date de comparaison", 10, 60, 200, 20)
$button2=GuiCtrlCreateButton("Aujourd'hui", 250, 40, 120, 20)
$button3=GuiCtrlCreateButton("Ajouter rats", 250, 80, 120, 20)
$no=GuiCtrlCreateInput("Nom", 250, 100, 120, 20)
$an=GuiCtrlCreateInput("Année (AAAA)", 250, 120, 120, 20)
$mo=GuiCtrlCreateInput("Mois (MM)", 250, 140, 120, 20)
$jo=GuiCtrlCreateInput("Jour (JJ)", 250, 160, 120, 20)
$button4=GuiCtrlCreateButton("Calculer", 10, 100, 200, 20)
$age=GuiCtrlCreateInput("Age du rat", 10, 120, 150, 20)
$age2=GuiCtrlCreateInput("Nb jours", 160, 120, 50, 20)
IniWriteSection ( "c:\agedesrats","","")
GuiCtrlCreateLabel("http://sita-rats.fr", 10, 170, 200, 20)
$irat=IniReadSectionNames ( "c:\agedesrats" )
For $i = 1 To $irat[0]
GUICtrlSetData ($button1, $irat[$i])
Next
GuiSetState()
While 1
$button = GUIGetMsg()
Select
Case $button = $GUI_EVENT_CLOSE
ExitLoop
Case $button = $button2
GUICtrlSetData($date2,@YEAR&"/"&@MON&"/"&@MDAY)
Case $button = $button1
GUICtrlSetData ( $date1, (IniRead ( "c:\agedesrats", (GUICtrlRead ($button1)), "ddn", "0000/00/00" )))
Case $button = $button3
IniWriteSection ( "c:\agedesrats", (GUICtrlRead ($no)), "ddn="&(GUICtrlRead ($an))&"/"&(GUICtrlRead ($mo))&"/"&(GUICtrlRead ($jo)))
GUICtrlSetData ($button1, (GUICtrlRead ($no)))
Case $button = $button4
$ca1=StringRight((StringLeft((GUICtrlRead ($date1)), 10)), 4)
$cm1=StringRight((StringLeft((GUICtrlRead ($date1)), 5)), 2)
$cj1=StringRight((StringLeft((GUICtrlRead ($date1)), 2)), 2)
$ca2=StringRight((StringLeft((GUICtrlRead ($date2)), 10)), 4)
$cm2=StringRight((StringLeft((GUICtrlRead ($date2)), 5)), 2)
$cj2=StringRight((StringLeft((GUICtrlRead ($date2)), 2)), 2)
$ca=$ca2-$ca1
$cm=$cm2-$cm1
$cj=$cj2-$cj1
If $cj <0 Then
$cj=$cj+30
$cm=$cm-1
EndIf
If $cm <0 Then
$cm=$cm+12
$ca=$ca-1
EndIf
$nbj=((365*$ca)+(30*$cm)+$cj)
GUICtrlSetData ($age, $ca&"an(s) "&$cm&"mois "&$cj&"jour(s)")
GUICtrlSetData ($age2, $nbj&" - "&Int($nbj/7)&"s")
EndSelect
WEnd