Enregistrement des evènements "au fil de l'eau"
Posté : ven. 31 mars 2017 12:13
Bonjour,
Il y a peu, nous avons fait au travail un exercice de simulation d'attaque terroriste avec une gestion en PC Opérationnel, dans lequel j'avais pour consigne l'enregistrement des évènements au fil de l'eau, avec un affichage sur vidéo projecteur pour l'information de l'ensemble des participants.
Doté d'un simple traitement de texte, je n'ai pas trouvé l'outil particulièrement adapté à ce type d’évènement et je perdais du temps a essayer de rentrer l'heure avant de rentrer le message, ce qui me faisait perdre parfois le fil des informations, car vous vous en doutez, dans ce genre d'exercice les informations arrivent a toute vitesse.
J'ai donc imaginé une interface capable de récupérer le texte et d'y insérer automatiquement l'heure de l'ajout, qui puisse afficher en permanence le nombre de blessés ou décédés au fur et a mesure que les informations arrivent.
de fil en aiguille en développant j'y ai inséré la possibilité d'imprimer le compte rendu avec l'UDF "RTF_Printer.au3 dont j'ai légèrement modifié l'interface graphique pour une présentation plus claire.
Concernant les champs de comptage des victimes, j'ai utilisé l’excellent imputimpose.au3 pour imposer la saisie de nombres dans les champs et pouvoir faire un total facilement.
Concernant le fonctionnement de l'application, il suffit de rentrer du texte dans la zone d’édition et ce dernier s'insère dans le fichier html en dessous.
En même temps un fichier CSV est enregistré palier à une éventuelle fermeture accidentelle ou voulue de l'application et une reprise ultérieure.
l'impression se fait grâce à une boucle for qui insère les éléments enregistrés à partir d'une array elle aussi enregistré lors de la saisie.
Voilà le script :
je mets en lien les UDFs etrangers utilisés dont le rtf_printer modifié a ma sauce.
les fichiers a recuperer
Il y a peu, nous avons fait au travail un exercice de simulation d'attaque terroriste avec une gestion en PC Opérationnel, dans lequel j'avais pour consigne l'enregistrement des évènements au fil de l'eau, avec un affichage sur vidéo projecteur pour l'information de l'ensemble des participants.
Doté d'un simple traitement de texte, je n'ai pas trouvé l'outil particulièrement adapté à ce type d’évènement et je perdais du temps a essayer de rentrer l'heure avant de rentrer le message, ce qui me faisait perdre parfois le fil des informations, car vous vous en doutez, dans ce genre d'exercice les informations arrivent a toute vitesse.
J'ai donc imaginé une interface capable de récupérer le texte et d'y insérer automatiquement l'heure de l'ajout, qui puisse afficher en permanence le nombre de blessés ou décédés au fur et a mesure que les informations arrivent.
de fil en aiguille en développant j'y ai inséré la possibilité d'imprimer le compte rendu avec l'UDF "RTF_Printer.au3 dont j'ai légèrement modifié l'interface graphique pour une présentation plus claire.
Concernant les champs de comptage des victimes, j'ai utilisé l’excellent imputimpose.au3 pour imposer la saisie de nombres dans les champs et pouvoir faire un total facilement.
Concernant le fonctionnement de l'application, il suffit de rentrer du texte dans la zone d’édition et ce dernier s'insère dans le fichier html en dessous.
En même temps un fichier CSV est enregistré palier à une éventuelle fermeture accidentelle ou voulue de l'application et une reprise ultérieure.
l'impression se fait grâce à une boucle for qui insère les éléments enregistrés à partir d'une array elle aussi enregistré lors de la saisie.
Voilà le script :
#include <GuiConstants.au3>
#include <IE.au3>
#include<date.au3>
#include<array.au3>
#include <GuiRichEdit.au3>
#include <RTF_Printer.au3>
#include <InputImpose.au3>
Global $atextForPrinting[1][2], $total_VC, $total_VE, $total_VFS
$form1=GuiCreate("Main courante PCO", @DesktopWidth-40,@DesktopHeight-40,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$inpubox=GUICtrlCreateEdit("",20,20,@DesktopWidth- (@DesktopWidth / 4),100)
$button= GUICtrlCreateButton("OK",@DesktopWidth- (@DesktopWidth / 4) + 30,30,70,70)
$button_print= GUICtrlCreateButton("Imprimer",@DesktopWidth- (@DesktopWidth / 4) + 40 ,@DesktopHeight - 100 ,70,40)
$Group_victimes= GUICtrlCreateGroup("VICTIMES CIVILES", @DesktopWidth- (@DesktopWidth / 4) + 30, 150,@DesktopWidth- (@DesktopWidth / 4), 250)
$menu_fichier=GUICtrlCreateMenu("&Fichier")
$menu_ouvrir=GUICtrlCreateMenuItem("&Ouvrir",$menu_fichier)
$menu_quitter=GUICtrlCreateMenuItem("&Quitter",$menu_fichier)
$menu_Imprimer=GUICtrlCreateMenuItem("&Imprimer",$menu_fichier)
GUICtrlCreateLabel("INDEMNES : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 180)
GUICtrlCreateLabel("UR : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 210)
GUICtrlCreateLabel("UA : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 240)
GUICtrlCreateLabel("DCD : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 270)
GUICtrlCreateLabel("TOTAL : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 300)
$nbr_label_VC_indemnes = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 180)
$nbr_label_VC_UR= GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 210)
$nbr_label_VC_UA = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 240)
$nbr_label_VC_DCD = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 270)
$nbr_label_VC_TOTAL = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 300)
Global $aCondition1 = _InputImpose_Create()
_InputImpose_Update($aCondition1, $__INIM_ALLOW_ANYWHERE, '0..9', $__INIM_ALLOW_ONCE, '.')
_InputImpose_Update($aCondition1, $__INIM_TOOLTIP_TEXT, 'Only a Positive number (Whole or Decimal) is allowed', $__INIM_TOOLTIP_TIMEOUT, 3)
_InputImpose_Update($aCondition1, $__INIM_BEEP_FREQUENCY, 700)
;GUICtrlCreateGroup("", -99, -99, 1, 1)
$group_police = GUICtrlCreateGroup("VICTIMES FORCES DE SECURITE", @DesktopWidth- (@DesktopWidth / 4) + 30, 410, @DesktopWidth- (@DesktopWidth / 4),250)
GUICtrlCreateLabel("UR : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 440)
GUICtrlCreateLabel("UA : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 470)
GUICtrlCreateLabel("DCD : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 500)
GUICtrlCreateLabel("TOTAL : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 530)
$nbr_label_VFS_UR= GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 440)
$nbr_label_VFS_UA = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 470)
$nbr_label_VFS_DCD = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 500)
$nbr_label_VFS_TOTAL = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 530)
;GUICtrlCreateGroup("", -99, -99, 1, 1)
$group_equipage = GUICtrlCreateGroup("VICTIMES EQUIPAGE", @DesktopWidth- (@DesktopWidth / 4) + 30, 690 , @DesktopWidth- (@DesktopWidth / 4),250)
GUICtrlCreateLabel("INDEMNES : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 720)
GUICtrlCreateLabel("UR : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 750)
GUICtrlCreateLabel("UA : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 780)
GUICtrlCreateLabel("DCD : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 810)
GUICtrlCreateLabel("TOTAL : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 840)
$nbr_label_VE_indemnes = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 720)
$nbr_label_VE_UR= GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 750)
$nbr_label_VE_UA = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 780)
$nbr_label_VE_DCD = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 810)
$nbr_label_VE_TOTAL = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 840)
$time_label = GUICtrlCreateLabel(_Nowtime(4) , @DesktopWidth- (@DesktopWidth / 4) +180,30,200,50)
GUICtrlSetFont(-1,40)
Global $csv= @ScriptDir & "\" & stringreplace(_nowdate(),"/","-") & stringreplace(_nowtime(4),":","") & "-pcosave.csv"
Global $file = @TempDir & "\nmci-pco.html"
$oIE = _IECreateEmbedded ()
GuiSetIcon(@SystemDir & "\shell32.dll", 170)
; IE
$GUIActiveX = GUICtrlCreateObj($oIE, 20, 200 , @DesktopWidth- (@DesktopWidth / 4), @DesktopHeight- (@DesktopHeight / 4))
GUICtrlCreateLabel("Main courante P.C.O. du " & _nowdate() & " - Evenement :", 20,150,610,50)
GUICtrlSetFont(-1,20)
$label_evenement= GUICtrlCreateInput("",650,150,600,40)
GUICtrlSetFont(-1,20)
; page internet
GuiSetState(@SW_SHOW)
_makehtml()
;_IENavigate($oIE, $file)
While 1
_InputImpose($form1, $nbr_label_VC_DCD, $aCondition1)
_InputImpose($form1, $nbr_label_VC_indemnes, $aCondition1)
_InputImpose($form1, $nbr_label_VC_UA, $aCondition1)
_InputImpose($form1, $nbr_label_VC_UR, $aCondition1)
_InputImpose($form1, $nbr_label_VE_DCD, $aCondition1)
_InputImpose($form1, $nbr_label_VE_indemnes, $aCondition1)
_InputImpose($form1, $nbr_label_VE_UA, $aCondition1)
_InputImpose($form1, $nbr_label_VE_UR, $aCondition1)
_InputImpose($form1, $nbr_label_VFS_DCD, $aCondition1)
_InputImpose($form1, $nbr_label_VFS_UA, $aCondition1)
_InputImpose($form1, $nbr_label_VFS_UR, $aCondition1)
guictrlsetdata($time_label, _NowTime(4) )
guictrlsetdata($nbr_label_VC_TOTAL,GUICtrlRead($nbr_label_VC_DCD)+GUICtrlRead($nbr_label_VC_indemnes)+GUICtrlRead($nbr_label_VC_UA)+guictrlread($nbr_label_VC_UR))
guictrlsetdata($nbr_label_VE_TOTAL,GUICtrlRead($nbr_label_VE_DCD)+GUICtrlRead($nbr_label_VE_indemnes)+GUICtrlRead($nbr_label_VE_UA)+guictrlread($nbr_label_VE_UR))
guictrlsetdata($nbr_label_VFS_TOTAL,GUICtrlRead($nbr_label_VFS_DCD)+GUICtrlRead($nbr_label_VFS_UA)+guictrlread($nbr_label_VFS_UR))
$msg = GuiGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE, $menu_quitter
FileDelete($file)
if FileExists($csv) then Msgbox(0,"MC P.C.O","Les évènements ont été enregistrés automatiquement dans le fichier " & @crlf & _
$csv & ". Pour continuer cet enregistrement " & @crlf & _
"Utiliser la commande (fichier/ouvrir) du menu et le sélectionner.")
Exit
Case $button
$message=GUICtrlRead($inpubox)
$arrayMsg =StringRegExpReplace($message, '\R', "__")
$aText = StringRegExp($message, "(?m)^(.*)$", 3)
;_ArrayDisplay($aText)
if $message = "" then
consolewrite("")
Else
FileWrite($file, _nowtime(4) & " : ")
FileWrite($csv, _nowtime(4) & " : ;")
For $i = 0 To UBound($aText) - 1
FileWrite($file, $aText[$i] & "<br />")
FileWrite($csv,$aText[$i] & @CRLF)
;_IEErrorHandlerRegister ()
Next
redim $atextForPrinting[ubound($atextForPrinting) +1][2]
$atextForPrinting[ubound($atextForPrinting) -1][0]=_NowTime(4) & " : "
$atextForPrinting[ubound($atextForPrinting) -1][1]= $arrayMsg
;_ArrayDisplay($atextForPrinting)
EndIf
_IENavigate($oIE, $file)
GUICtrlSetdata($inpubox,"")
sleep(1000)
case $button_print, $menu_Imprimer
print()
Case $menu_ouvrir
if FileExists($file) then FileDelete($file)
_makehtml()
$fileopen = FileOpenDialog("Main courante P.C.O.",@ScriptDir,"Fichiers CSV (*.csv)", $FD_FILEMUSTEXIST )
Global $csv= $fileopen
local $scsv = FileRead($csv)
$atextForPrinting= toArrayCsv($scsv)
;_arraydisplay($atextForPrinting)
for $i = 0 to ubound($atextForPrinting) -1
filewrite($file, $atextForPrinting[$i][0] & $atextForPrinting[$i][1] & "</br>")
Next
_IENavigate($oIE, $file)
EndSwitch
WEnd
Func toArrayCsv($s)
Local $line = StringSplit($s,@CRLF,2+1) ; combien de ligne de mon fichier <> tableau
Local $maxCol = 1 ; nombre de colonne de depart
Local $a[UBound($line)][$maxCol] ; je crée un tableau de n ligne et de 1 colonne que je modifierai à ma guise
For $i = 0 To UBound($line)-1 ; parcours toutes les lignes
Local $tmp = StringSplit($line[$i],";",3) ; combien de colonnes pour la ligne n°i
If(UBound($tmp) > $maxCol ) then $maxCol = UBound($tmp) ; pour connaitre le nombre de colonnes
ReDim $a[UBound($line)][$maxCol] ; je redimensionne mon tableau aux bonnes dimensions
For $j = 0 To UBound($tmp)-1 ; je parcours cellule par cellule "de gauche a droite"
$a[$i][$j] = $tmp[$j] ; je remplis chaque cellule
Next
Next
Return $a
EndFunc
func print()
Local $hRichEdit
$hGui = GUICreate("impression", 320, 350, -1, -1)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
_GUICtrlRichEdit_SetFont($hRichEdit,20)
_GUICtrlRichEdit_AppendText($hRichEdit,@CRLF & "Main courante PCO : " & GUICtrlRead($label_evenement))
for $i = 0 to ubound($atextForPrinting)-1
_GUICtrlRichEdit_AppendText($hRichEdit,@CRLF & $atextForPrinting[$i][0] & " " & stringreplace(($atextForPrinting[$i][1] ),"__", @CRLF))
Next
_GUICtrlRichEdit_AppendText($hRichEdit,@CRLF & "----------------------------------------------------------------------------------------------------------")
_GUICtrlRichEdit_AppendText($hRichEdit,@CRLF & "Victimes civiles : " & GUICtrlRead($nbr_label_VC_TOTAL ) & " (" & GUICtrlRead($nbr_label_VC_DCD) & " DCD, " & _
GUICtrlRead($nbr_label_VC_UA) & " UA, " & _
GUICtrlRead($nbr_label_VC_UR) & " UR, " & _
GUICtrlRead($nbr_label_VC_indemnes)& " Indemnes)")
_GUICtrlRichEdit_AppendText($hRichEdit,@CRLF & "Victimes equipage : " & GUICtrlRead($nbr_label_VE_TOTAL ) & " (" & GUICtrlRead($nbr_label_VE_DCD) & " DCD, " & _
GUICtrlRead($nbr_label_VE_UA) & " UA, " & _
GUICtrlRead($nbr_label_VE_UR) & " UR, " & _
GUICtrlRead($nbr_label_VE_indemnes)& " Indemnes)")
_GUICtrlRichEdit_AppendText($hRichEdit,@CRLF & "Victimes Forces Intervention: " & GUICtrlRead($nbr_label_VFS_TOTAL ) & " (" & GUICtrlRead($nbr_label_VFS_DCD) & " DCD, " & _
GUICtrlRead($nbr_label_VFS_UA) & " UA, " & _
GUICtrlRead($nbr_label_VFS_UR) & " UR)")
_GUICtrlRichEdit_SetCharColor($hRichEdit, "0")
_RTF_PrintFile(_GUICtrlRichEdit_StreamToVar($hRichEdit), Default, False)
EndFunc
func _makehtml()
if FileExists($file) then FileDelete($file)
$texte = "<html><head>" & @CRLF & _
"<title>PCO</title>" & @CRLF & _
"<meta name=""title"" content=""PCO"" />" & @CRLF & _
"<meta name=""description"" content=""main courante PCO"" />" & @CRLF & _
"<meta name=""keywords"" content=""PCO"" />" & @CRLF & _
"<meta http-equiv=""content-type"" content=""text/html; charset=UTF-8"" />" & @CRLF & _
"</head>" & @CRLF & _
"<body bgcolor=""#ffffff"" background=""images/"" text=""#000000"" link=""#0000cc"" vlink=""#660033"" alink=""#ff0000"" marginheight=""0"" marginwidth=""0"" leftmargin=""0"" topmargin=""0""><font size=""5""><font face=""Times New Roman""> "; & @CRLF
filewrite($file, $texte)
EndFunc
#include <IE.au3>
#include<date.au3>
#include<array.au3>
#include <GuiRichEdit.au3>
#include <RTF_Printer.au3>
#include <InputImpose.au3>
Global $atextForPrinting[1][2], $total_VC, $total_VE, $total_VFS
$form1=GuiCreate("Main courante PCO", @DesktopWidth-40,@DesktopHeight-40,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$inpubox=GUICtrlCreateEdit("",20,20,@DesktopWidth- (@DesktopWidth / 4),100)
$button= GUICtrlCreateButton("OK",@DesktopWidth- (@DesktopWidth / 4) + 30,30,70,70)
$button_print= GUICtrlCreateButton("Imprimer",@DesktopWidth- (@DesktopWidth / 4) + 40 ,@DesktopHeight - 100 ,70,40)
$Group_victimes= GUICtrlCreateGroup("VICTIMES CIVILES", @DesktopWidth- (@DesktopWidth / 4) + 30, 150,@DesktopWidth- (@DesktopWidth / 4), 250)
$menu_fichier=GUICtrlCreateMenu("&Fichier")
$menu_ouvrir=GUICtrlCreateMenuItem("&Ouvrir",$menu_fichier)
$menu_quitter=GUICtrlCreateMenuItem("&Quitter",$menu_fichier)
$menu_Imprimer=GUICtrlCreateMenuItem("&Imprimer",$menu_fichier)
GUICtrlCreateLabel("INDEMNES : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 180)
GUICtrlCreateLabel("UR : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 210)
GUICtrlCreateLabel("UA : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 240)
GUICtrlCreateLabel("DCD : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 270)
GUICtrlCreateLabel("TOTAL : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 300)
$nbr_label_VC_indemnes = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 180)
$nbr_label_VC_UR= GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 210)
$nbr_label_VC_UA = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 240)
$nbr_label_VC_DCD = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 270)
$nbr_label_VC_TOTAL = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 300)
Global $aCondition1 = _InputImpose_Create()
_InputImpose_Update($aCondition1, $__INIM_ALLOW_ANYWHERE, '0..9', $__INIM_ALLOW_ONCE, '.')
_InputImpose_Update($aCondition1, $__INIM_TOOLTIP_TEXT, 'Only a Positive number (Whole or Decimal) is allowed', $__INIM_TOOLTIP_TIMEOUT, 3)
_InputImpose_Update($aCondition1, $__INIM_BEEP_FREQUENCY, 700)
;GUICtrlCreateGroup("", -99, -99, 1, 1)
$group_police = GUICtrlCreateGroup("VICTIMES FORCES DE SECURITE", @DesktopWidth- (@DesktopWidth / 4) + 30, 410, @DesktopWidth- (@DesktopWidth / 4),250)
GUICtrlCreateLabel("UR : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 440)
GUICtrlCreateLabel("UA : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 470)
GUICtrlCreateLabel("DCD : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 500)
GUICtrlCreateLabel("TOTAL : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 530)
$nbr_label_VFS_UR= GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 440)
$nbr_label_VFS_UA = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 470)
$nbr_label_VFS_DCD = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 500)
$nbr_label_VFS_TOTAL = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 530)
;GUICtrlCreateGroup("", -99, -99, 1, 1)
$group_equipage = GUICtrlCreateGroup("VICTIMES EQUIPAGE", @DesktopWidth- (@DesktopWidth / 4) + 30, 690 , @DesktopWidth- (@DesktopWidth / 4),250)
GUICtrlCreateLabel("INDEMNES : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 720)
GUICtrlCreateLabel("UR : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 750)
GUICtrlCreateLabel("UA : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 780)
GUICtrlCreateLabel("DCD : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 810)
GUICtrlCreateLabel("TOTAL : ", @DesktopWidth- (@DesktopWidth / 4) + 40, 840)
$nbr_label_VE_indemnes = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 720)
$nbr_label_VE_UR= GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 750)
$nbr_label_VE_UA = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 780)
$nbr_label_VE_DCD = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 810)
$nbr_label_VE_TOTAL = GUICtrlCreateInput("", @DesktopWidth- (@DesktopWidth / 4) + 140, 840)
$time_label = GUICtrlCreateLabel(_Nowtime(4) , @DesktopWidth- (@DesktopWidth / 4) +180,30,200,50)
GUICtrlSetFont(-1,40)
Global $csv= @ScriptDir & "\" & stringreplace(_nowdate(),"/","-") & stringreplace(_nowtime(4),":","") & "-pcosave.csv"
Global $file = @TempDir & "\nmci-pco.html"
$oIE = _IECreateEmbedded ()
GuiSetIcon(@SystemDir & "\shell32.dll", 170)
; IE
$GUIActiveX = GUICtrlCreateObj($oIE, 20, 200 , @DesktopWidth- (@DesktopWidth / 4), @DesktopHeight- (@DesktopHeight / 4))
GUICtrlCreateLabel("Main courante P.C.O. du " & _nowdate() & " - Evenement :", 20,150,610,50)
GUICtrlSetFont(-1,20)
$label_evenement= GUICtrlCreateInput("",650,150,600,40)
GUICtrlSetFont(-1,20)
; page internet
GuiSetState(@SW_SHOW)
_makehtml()
;_IENavigate($oIE, $file)
While 1
_InputImpose($form1, $nbr_label_VC_DCD, $aCondition1)
_InputImpose($form1, $nbr_label_VC_indemnes, $aCondition1)
_InputImpose($form1, $nbr_label_VC_UA, $aCondition1)
_InputImpose($form1, $nbr_label_VC_UR, $aCondition1)
_InputImpose($form1, $nbr_label_VE_DCD, $aCondition1)
_InputImpose($form1, $nbr_label_VE_indemnes, $aCondition1)
_InputImpose($form1, $nbr_label_VE_UA, $aCondition1)
_InputImpose($form1, $nbr_label_VE_UR, $aCondition1)
_InputImpose($form1, $nbr_label_VFS_DCD, $aCondition1)
_InputImpose($form1, $nbr_label_VFS_UA, $aCondition1)
_InputImpose($form1, $nbr_label_VFS_UR, $aCondition1)
guictrlsetdata($time_label, _NowTime(4) )
guictrlsetdata($nbr_label_VC_TOTAL,GUICtrlRead($nbr_label_VC_DCD)+GUICtrlRead($nbr_label_VC_indemnes)+GUICtrlRead($nbr_label_VC_UA)+guictrlread($nbr_label_VC_UR))
guictrlsetdata($nbr_label_VE_TOTAL,GUICtrlRead($nbr_label_VE_DCD)+GUICtrlRead($nbr_label_VE_indemnes)+GUICtrlRead($nbr_label_VE_UA)+guictrlread($nbr_label_VE_UR))
guictrlsetdata($nbr_label_VFS_TOTAL,GUICtrlRead($nbr_label_VFS_DCD)+GUICtrlRead($nbr_label_VFS_UA)+guictrlread($nbr_label_VFS_UR))
$msg = GuiGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE, $menu_quitter
FileDelete($file)
if FileExists($csv) then Msgbox(0,"MC P.C.O","Les évènements ont été enregistrés automatiquement dans le fichier " & @crlf & _
$csv & ". Pour continuer cet enregistrement " & @crlf & _
"Utiliser la commande (fichier/ouvrir) du menu et le sélectionner.")
Exit
Case $button
$message=GUICtrlRead($inpubox)
$arrayMsg =StringRegExpReplace($message, '\R', "__")
$aText = StringRegExp($message, "(?m)^(.*)$", 3)
;_ArrayDisplay($aText)
if $message = "" then
consolewrite("")
Else
FileWrite($file, _nowtime(4) & " : ")
FileWrite($csv, _nowtime(4) & " : ;")
For $i = 0 To UBound($aText) - 1
FileWrite($file, $aText[$i] & "<br />")
FileWrite($csv,$aText[$i] & @CRLF)
;_IEErrorHandlerRegister ()
Next
redim $atextForPrinting[ubound($atextForPrinting) +1][2]
$atextForPrinting[ubound($atextForPrinting) -1][0]=_NowTime(4) & " : "
$atextForPrinting[ubound($atextForPrinting) -1][1]= $arrayMsg
;_ArrayDisplay($atextForPrinting)
EndIf
_IENavigate($oIE, $file)
GUICtrlSetdata($inpubox,"")
sleep(1000)
case $button_print, $menu_Imprimer
print()
Case $menu_ouvrir
if FileExists($file) then FileDelete($file)
_makehtml()
$fileopen = FileOpenDialog("Main courante P.C.O.",@ScriptDir,"Fichiers CSV (*.csv)", $FD_FILEMUSTEXIST )
Global $csv= $fileopen
local $scsv = FileRead($csv)
$atextForPrinting= toArrayCsv($scsv)
;_arraydisplay($atextForPrinting)
for $i = 0 to ubound($atextForPrinting) -1
filewrite($file, $atextForPrinting[$i][0] & $atextForPrinting[$i][1] & "</br>")
Next
_IENavigate($oIE, $file)
EndSwitch
WEnd
Func toArrayCsv($s)
Local $line = StringSplit($s,@CRLF,2+1) ; combien de ligne de mon fichier <> tableau
Local $maxCol = 1 ; nombre de colonne de depart
Local $a[UBound($line)][$maxCol] ; je crée un tableau de n ligne et de 1 colonne que je modifierai à ma guise
For $i = 0 To UBound($line)-1 ; parcours toutes les lignes
Local $tmp = StringSplit($line[$i],";",3) ; combien de colonnes pour la ligne n°i
If(UBound($tmp) > $maxCol ) then $maxCol = UBound($tmp) ; pour connaitre le nombre de colonnes
ReDim $a[UBound($line)][$maxCol] ; je redimensionne mon tableau aux bonnes dimensions
For $j = 0 To UBound($tmp)-1 ; je parcours cellule par cellule "de gauche a droite"
$a[$i][$j] = $tmp[$j] ; je remplis chaque cellule
Next
Next
Return $a
EndFunc
func print()
Local $hRichEdit
$hGui = GUICreate("impression", 320, 350, -1, -1)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
_GUICtrlRichEdit_SetFont($hRichEdit,20)
_GUICtrlRichEdit_AppendText($hRichEdit,@CRLF & "Main courante PCO : " & GUICtrlRead($label_evenement))
for $i = 0 to ubound($atextForPrinting)-1
_GUICtrlRichEdit_AppendText($hRichEdit,@CRLF & $atextForPrinting[$i][0] & " " & stringreplace(($atextForPrinting[$i][1] ),"__", @CRLF))
Next
_GUICtrlRichEdit_AppendText($hRichEdit,@CRLF & "----------------------------------------------------------------------------------------------------------")
_GUICtrlRichEdit_AppendText($hRichEdit,@CRLF & "Victimes civiles : " & GUICtrlRead($nbr_label_VC_TOTAL ) & " (" & GUICtrlRead($nbr_label_VC_DCD) & " DCD, " & _
GUICtrlRead($nbr_label_VC_UA) & " UA, " & _
GUICtrlRead($nbr_label_VC_UR) & " UR, " & _
GUICtrlRead($nbr_label_VC_indemnes)& " Indemnes)")
_GUICtrlRichEdit_AppendText($hRichEdit,@CRLF & "Victimes equipage : " & GUICtrlRead($nbr_label_VE_TOTAL ) & " (" & GUICtrlRead($nbr_label_VE_DCD) & " DCD, " & _
GUICtrlRead($nbr_label_VE_UA) & " UA, " & _
GUICtrlRead($nbr_label_VE_UR) & " UR, " & _
GUICtrlRead($nbr_label_VE_indemnes)& " Indemnes)")
_GUICtrlRichEdit_AppendText($hRichEdit,@CRLF & "Victimes Forces Intervention: " & GUICtrlRead($nbr_label_VFS_TOTAL ) & " (" & GUICtrlRead($nbr_label_VFS_DCD) & " DCD, " & _
GUICtrlRead($nbr_label_VFS_UA) & " UA, " & _
GUICtrlRead($nbr_label_VFS_UR) & " UR)")
_GUICtrlRichEdit_SetCharColor($hRichEdit, "0")
_RTF_PrintFile(_GUICtrlRichEdit_StreamToVar($hRichEdit), Default, False)
EndFunc
func _makehtml()
if FileExists($file) then FileDelete($file)
$texte = "<html><head>" & @CRLF & _
"<title>PCO</title>" & @CRLF & _
"<meta name=""title"" content=""PCO"" />" & @CRLF & _
"<meta name=""description"" content=""main courante PCO"" />" & @CRLF & _
"<meta name=""keywords"" content=""PCO"" />" & @CRLF & _
"<meta http-equiv=""content-type"" content=""text/html; charset=UTF-8"" />" & @CRLF & _
"</head>" & @CRLF & _
"<body bgcolor=""#ffffff"" background=""images/"" text=""#000000"" link=""#0000cc"" vlink=""#660033"" alink=""#ff0000"" marginheight=""0"" marginwidth=""0"" leftmargin=""0"" topmargin=""0""><font size=""5""><font face=""Times New Roman""> "; & @CRLF
filewrite($file, $texte)
EndFunc
les fichiers a recuperer