; ************ Constants and declaration ************ #include #include #include #include #include #include #include ;Opt ( "TrayIconHide", 1 ) Opt ( "GUIOnEventMode", 1) Opt("GUICoordMode", 1) $i = "0" $report = "0" $user_demande_report = "0" Global $retardeInstall, $lanceInstall Global $yes_install_button, $no_install_button, $yes_retard_button, $no_retard_button Global $temp_affichage_install_box, $temp_affichage_retard_box Global $retourinstallbouton, $retourretardbouton Global $mainwindow, $messageboxretard, $messageboxinstall ; ; si besoin je fournis le fichier INI qui permet de récupere différents valeurs ; ; mais les plus importante pour le fonctionnement sont : ;temp_initial = "10" en minutes ;temp_report = "15" en minutes ;nombre_report = "5" en nombre de reports ;temp_affichage = "20" en secondes ; ; ************ Recuperation of the INI value ************ $temp_initial = "20" $temp_report = "15" $temp_affichage = "8" $nombre_report = "3" $SecondsTxt = "seconde(s)" $MinutesTxt = "minutes" $RunTxt = "executer" $DelayTxt = "retarder" $CancelTxt = "annuler" $windows_name = "mise a jour" $titre_principal = "détail" $nom_principal = "nom" $contenu_nom_principal = "install du logiciel" $description_principal = "description" $contenu_description_principal = "nouvelle version" $information_principal = "détails de la MAJ" $contenu_information_principal = "mise a jour 2009" $question_information_principal = "installer ou retarder" $delai_information_principal = "MAJ dans" $report_principal = "report" $progress_name = "temp restant" $titre_retard_box = "retarder l'install" $contenuA_retard_box = "retarder pour reporter" $contenuB_retard_box = "annuler pour retour" $delai_retard_box = "report dans" $titre_lance_box = "lancer install" $contenuA_lance_box = "executer pour lancement" $contenuB_lance_box = "annuler pour retour" $delai_lance_box = "install dans" $popup_name = "install" $popup_messageA = "mise a jour en cours" $popup_messageB = "aprés la MAJ le pc redémarre" ; ************ Create the main window ************ $mainwindow = GUICreate ( $windows_name , 733 , 520 , -1 , -1 , $WS_EX_OVERLAPPEDWINDOW , $WS_EX_TOPMOST ) GUISetState( @SW_SHOW, $mainwindow ) GUISetFont ( 9, 400, 4, "" ) ;UNDERLINE GUICtrlCreateLabel ( $titre_principal, 20, 114, 250, 20 ) ;UNDERLINE GUICtrlCreateLabel ( $information_principal, 20, 254, 250, 20 ) ;UNDERLINE GUISetFont ( 9, 800, 0, "" ) ;GRAS GUICtrlCreateLabel ( $contenu_nom_principal , 20, 154 , 693 , 20, $SS_CENTER ) ;GRAS GUICtrlCreateLabel ( $contenu_description_principal , 20, 194 , 693 , 20, $SS_CENTER ) ;GRAS GUICtrlCreateLabel ( $contenu_information_principal , 20, 274 , 693 , 50, $SS_CENTER ) ;GRAS $mainquestion = GUICtrlCreateLabel ( $question_information_principal & " " & $temp_report & " " & $MinutesTxt & " ?" , 20, 334 , 693 , 20, $SS_CENTER ) ;GRAS GUISetFont ( 9, 400, 0, "" ) ;NORMAL GUICtrlCreateLabel ( $nom_principal , 170, 134, 250, 20 ) ;NORMAL GUICtrlCreateLabel ( $description_principal , 170, 174, 250, 20 ) ;NORMAL GUISetFont ( 9, 400, 0, "" ) GUICtrlCreateLabel ( $report_principal , 20, 424, 200, 20, $SS_RIGHT ) $affichage_du_report = GUICtrlCreateLabel ( " " & $report & " / " & $nombre_report , 240, 424, 120, 20 ) $premiertimer = GUICtrlCreateLabel ( $delai_information_principal & " " & $temp_initial & " " & $MinutesTxt, 20, 364 , 693 , 20, $SS_CENTER ) $progress_bar_name = GUICtrlCreateLabel ( $progress_name , 20, 387, 200, 20, $SS_RIGHT ) $progressbar = GUICtrlCreateProgress ( 240, 384, 260, 20 ) GUICtrlSetState ( $progress_bar_name, $GUI_HIDE ) GUICtrlSetState ( $progressbar, $GUI_HIDE ) $lanceInstall = GUICtrlCreateButton ( $RunTxt , 360, 424, 140, 30 ) $retardeInstall = GUICtrlCreateButton ( $DelayTxt , 560, 424, 140, 30 ) GUICtrlSetOnEvent ( $lanceInstall, "lanceInstall" ) GUICtrlSetOnEvent ( $retardeInstall, "retardeInstall" ) $pas = ( 100 / $temp_report ) $startexetimer = TimerInit() Do Sleep ( 200 ) If TimerDiff ($startexetimer) >= "1000" Then ; "60000" $temp_initial = ($temp_initial - "1" ) $startexetimer = TimerInit() GUICtrlSetData ( $premiertimer, $delai_information_principal & " " & $temp_initial & " " & $MinutesTxt ) EndIf Until $temp_initial <= "0" GUICtrlDelete ( $premiertimer ) If $user_demande_report = "0" Then _FileWriteLog ( "C:\_Logfiles\InfPrePatch_NewVersion.log","==> No user interaction ...***...***...***...***...***...***...", -1 ) runInstall() EndIf If $report = $nombre_report Then GUICtrlDelete ($retardeInstall) GUICtrlDelete ($mainquestion) EndIf If $user_demande_report = "1" And $report <> $nombre_report Then GUICtrlSetState ( $progress_bar_name, $GUI_SHOW ) GUICtrlSetState ( $progressbar, $GUI_SHOW ) $startreporttimer = TimerInit() Do If TimerDiff ($startreporttimer) >= "1000" Then $i = $i + $pas GUICtrlSetData( $progressbar, $i ) $startreporttimer = TimerInit() EndIf If $i >= "100" Then runInstall() EndIf Until $report = $nombre_report And $i >= "100" EndIf func retardeInstall() messageboxretard() If $user_demande_report = "0" Then If $retourretardbouton = 6 Or $retourretardbouton = 0 Then $report = $report + 1 GUICtrlSetData ( $affichage_du_report, " " & $report & " / " & $nombre_report ) GUICtrlDelete ( $premiertimer ) $temp_initial = "0" $user_demande_report = "1" _FileWriteLog ( "C:\_Logfiles\InfPrePatch_NewVersion.log","==> User ask to postpone installation " & $report & " time(s)" , -1 ) EndIf If $report = $nombre_report Then GUICtrlDelete ($retardeInstall) GUICtrlDelete ($mainquestion) EndIf Else If $retourretardbouton = 6 Or $retourretardbouton = 0 Then $report = $report + 1 GUICtrlSetData ( $affichage_du_report, " " & $report & " / " & $nombre_report ) $i = "0" $startreporttimer = TimerInit() GUICtrlSetData( $progressbar, 0 ) _FileWriteLog ( "C:\_Logfiles\InfPrePatch_NewVersion.log","==> User ask to postpone installation " & $report & " time(s)" , -1 ) EndIf If $report = $nombre_report Then GUICtrlDelete ($retardeInstall) GUICtrlDelete ($mainquestion) EndIf EndIf EndFunc func lanceInstall() messageboxinstall() If $retourinstallbouton = 6 Or $retourinstallbouton = 0 Then $report = $nombre_report GUICtrlDelete ( $premiertimer ) $temp_initial = "0" _FileWriteLog ( "C:\_Logfiles\InfPrePatch_NewVersion.log", "==> Install popup windows closed", -1 ) EndIf If $report = $nombre_report And ($lancemsgbox = 6 Or $lancemsgbox = -1) Then GUICtrlDelete ($retardeInstall) GUICtrlDelete ($mainquestion) runInstall() EndIf EndFunc Func messageboxretard() _FileWriteLog ( "C:\_Logfiles\InfPrePatch_NewVersion.log", "==> postpone message box popup", -1 ) GUISetState ( @SW_HIDE, $mainwindow ) $messageboxretard = GUICreate ( $titre_retard_box , 600 , 300 , -1 , -1 , $WS_EX_OVERLAPPEDWINDOW , $WS_EX_TOPMOST ) GUISetState ( @SW_SHOW, $messageboxretard ) GUICtrlCreateLabel ( $contenuA_retard_box & @CRLF & @CRLF & $contenuB_retard_box, 20, 120, 560, 50, $SS_CENTER ) $temp_affichage_retard_box = "0" $temp_affichage_retard_box = $temp_affichage $messageboxretard_delay_updt = GUICtrlCreateLabel ( $delai_retard_box &" "& $temp_affichage_retard_box &" "& $SecondsTxt, 20, 190, 560, 20, $SS_CENTER ) $retourretardbouton = "0" $yes_retard_button = GUICtrlCreateButton ( $DelayTxt, 145, 220, 140, 30 ) $no_retard_button = GUICtrlCreateButton ( $canceltxt, 315, 220, 140, 30 ) GUICtrlSetOnEvent ( $yes_retard_button, "retard_yes_button") GUICtrlSetOnEvent ( $no_retard_button, "retard_no_button") $startboxretardtimer = TimerInit() Do Sleep ( 100 ) If TimerDiff ($startboxretardtimer) >= "1000" Then $temp_affichage_retard_box = ($temp_affichage_retard_box - "1" ) $startboxretardtimer = TimerInit() GUICtrlSetData ( $messageboxretard_delay_updt, $delai_retard_box &" "& $temp_affichage_retard_box &" "& $SecondsTxt ) EndIf Until $temp_affichage_retard_box = "0" GUISetState ( @SW_HIDE, $messageboxretard ) GUISetState ( @SW_SHOW, $mainwindow ) EndFunc Func messageboxinstall() _FileWriteLog ( "C:\_Logfiles\InfPrePatch_NewVersion.log", "==> install message box popup", -1 ) GUISetState ( @SW_HIDE, $mainwindow ) $messageboxinstall = GUICreate ( $titre_lance_box , 600 , 300 , -1 , -1 , $WS_EX_OVERLAPPEDWINDOW , $WS_EX_TOPMOST ) GUISetState ( @SW_SHOW, $messageboxinstall ) GUICtrlCreateLabel ( $contenuA_lance_box & @CRLF & @CRLF & $contenuB_lance_box, 20, 120, 560, 50, $SS_CENTER ) $temp_affichage_install_box = "0" $temp_affichage_install_box = $temp_affichage $messageboxinstall_delay_updt = GUICtrlCreateLabel ( $delai_lance_box &" "& $temp_affichage_install_box &" "& $SecondsTxt, 20, 190, 560, 20, $SS_CENTER ) $retourinstallbouton = "0" GUISetState() $yes_install_button = GUICtrlCreateButton ( $RunTxt, 145, 220, 140, 30 ) $no_install_button = GUICtrlCreateButton ( $canceltxt, 315, 220, 140, 30 ) GUICtrlSetOnEvent ( $yes_install_button, "install_yes_button" ) GUICtrlSetOnEvent ( $no_install_button, "install_no_button") $startboxinstalltimer = TimerInit() Do Sleep ( 100 ) If TimerDiff ($startboxinstalltimer) >= "1000" Then $temp_affichage_install_box = ($temp_affichage_install_box - "1" ) $startboxinstalltimer = TimerInit() GUICtrlSetData ( $messageboxinstall_delay_updt, $delai_lance_box &" "& $temp_affichage_install_box &" "& $SecondsTxt ) EndIf Until $temp_affichage_install_box <= "0" GUISetState ( @SW_HIDE, $messageboxinstall ) GUISetState ( @SW_SHOW, $mainwindow ) EndFunc Func retard_yes_button() _FileWriteLog ( "C:\_Logfiles\InfPrePatch_NewVersion.log", "### postpone button presed is " & $DelayTxt, -1 ) $retourretardbouton = "6" $temp_affichage_retard_box = "0" EndFunc Func retard_no_button() _FileWriteLog ( "C:\_Logfiles\InfPrePatch_NewVersion.log", "### postpone button presed is " & $canceltxt, -1 ) $retourretardbouton = "7" $temp_affichage_retard_box = "0" EndFunc Func install_yes_button() _FileWriteLog ( "C:\_Logfiles\InfPrePatch_NewVersion.log", "### installation button presed is " & $RunTxt, -1 ) $retourinstallbouton = "6" $temp_affichage_install_box = "0" EndFunc Func install_no_button() _FileWriteLog ( "C:\_Logfiles\InfPrePatch_NewVersion.log", "### installation button presed is " & $canceltxt, -1 ) $retourinstallbouton = "7" $temp_affichage_install_box = "0" EndFunc Func runInstall() GUISetState ( @SW_HIDE, $mainwindow ) GUISetState ( @SW_HIDE, $messageboxinstall ) GUISetState ( @SW_HIDE, $messageboxretard ) $secondwindows = GUICreate ( $popup_name , 600 , 250 , -1 , -1 , $WS_EX_OVERLAPPEDWINDOW , $WS_EX_TOPMOST ) GUISetState ( @SW_SHOW, $secondwindows ) GUISetFont ( 14, 400, 0, "" ) GUICtrlCreateLabel ( $popup_messageA & @CRLF & $popup_messageB , 20, 120, 560, 80, $SS_CENTER ) Sleep ( 10000 ) Exit EndFunc