Code : Tout sélectionner
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\Adobe_Dreamweaver_XML.ico
#AutoIt3Wrapper_Outfile=..\Tasks-read.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <Array.au3>
FileCopy("tasks.xml", "tasks-orig.xml", 0)
FileMove ("tasks.xml", "tasks-modif.xml", 1)
Global $xml = @scriptdir & "\tasks-modif.xml"
Global $new_xml = @scriptdir & "\tasks.xml"
$txt = FileRead($xml)
Global $array = StringRegExp($txt, '(?s)Task\h+label="([^"]+)', 3) ; récupère les noms
Global $array2 = StringRegExp($txt, '(?s)\s*<!.+?Task label=[^>]+>', 3) ; récupère les lignes du xml
; _ArrayDisplay($array2)
$gui = GUICreate("Modification Tasks.xml pour maj iNot", 1000, 430, 5, 50)
$listview = GUICtrlCreateListView("étapes de maj", 10, 10, 335, 330, -1, $LVS_EX_CHECKBOXES)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 0, 320)
For $i = 0 To UBound($array)-1
GUICtrlCreateListViewItem($array[$i], $listview)
Next
$edit = GuiCtrlCreateEdit($txt, 350, 10, 640, 420)
;~ GUICtrlCreateLabel("Supression", 20, 350, 80, 25)
;~ $degage = GuiCtrlCreateButton("Supprimer la séléction", 10, 345, 160, 22)
;~ $degageall = GuiCtrlCreateButton("Supprimer jusqu'a la séléction", 10, 373, 160, 22)
;~ $appwiz = GuiCtrlCreateButton("Appwiz", 180, 345, 160, 22)
;~ $required = GuiCtrlCreateButton("Séléctionner les Required", 180, 373, 160, 22)
$degage = GuiCtrlCreateButton("Supprimer la sélection", 10, 373, 160, 22)
GUICtrlSetColor($degage, 0xff0000)
$degageall = GuiCtrlCreateButton("Supprimer jusqu'a la sélection", 180, 373, 160, 22)
GUICtrlSetColor($degageall, 0xff0000)
$keep = GuiCtrlCreateButton("Conserver les checkbox", 180, 345, 160, 22)
$required = GuiCtrlCreateButton("Séléctionner les Required", 10, 345, 160, 22)
$appwiz = GuiCtrlCreateButton("Appwiz.cpl", 10, 400, 160, 22)
$RAZ = GuiCtrlCreateButton("RAZ", 180, 400, 160, 22)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
Case $appwiz
Run(@ComSpec & " /c " & 'C:\windows\system32\appwiz.cpl', "", @SW_HIDE)
Case $degage
WinClose ( "tasks.xml")
If $array <>"" Then
$count = _GUICtrlListView_GetItemCount($listview)
For $i = $count-1 to 0 step -1
If _GUICtrlListView_GetItemChecked($listview, $i) = true Then
_GUICtrlListView_DeleteItem($listview, $i)
$txt = StringReplace($txt, $array2[$i], "")
_ArrayDelete($array, $i)
_ArrayDelete($array2, $i)
EndIf
Next
EndIf
FileDelete($new_xml)
FileWrite($new_xml, $txt)
GuiCtrlSetData($edit, $txt)
;~ Run("notepad.exe " & $new_xml)
Case $degageall
WinClose ( "tasks.xml")
For $i = 0 to _GUICtrlListView_GetItemCount($listview)-1
If _GUICtrlListView_GetItemChecked($listview, $i) Then
For $j = 0 To $i
_GUICtrlListView_SetItemChecked($listview, $j)
Next
EndIf
Next
If $array <>"" Then
$count = _GUICtrlListView_GetItemCount($listview)
For $i = $count-1 to 0 step -1
If _GUICtrlListView_GetItemChecked($listview, $i) = True Then
_GUICtrlListView_DeleteItem($listview, $i)
$txt = StringReplace($txt, $array2[$i], "")
_ArrayDelete($array, $i)
_ArrayDelete($array2, $i)
EndIf
Next
EndIf
FileDelete($new_xml)
FileWrite($new_xml, $txt)
GuiCtrlSetData($edit, $txt)
;~ Run("notepad.exe " & $new_xml)
Case $required
$count = _GUICtrlListView_GetItemCount($listview)
For $i = 0 to $count-1
If _GUICtrlListView_GetItemChecked($listview, $i) Then
$req = StringRegExpReplace($array2[$i], '(?s).*For="([^"]+).*', "$1")
;~ _ArrayDisplay($array)
MsgBox(0,"information",$req)
For $j = 0 to UBound($array2)-1
If StringInStr($array2[$j], $req) Then _GUICtrlListView_SetItemChecked($listview, $j)
Next
EndIf
Next
Case $keep
WinClose ( "tasks.xml")
If $array <>"" Then
$count = _GUICtrlListView_GetItemCount($listview)
For $i = $count-1 to 0 step -1
If _GUICtrlListView_GetItemChecked($listview, $i) = False Then
_GUICtrlListView_DeleteItem($listview, $i)
$txt = StringReplace($txt, $array2[$i], "")
_ArrayDelete($array, $i)
_ArrayDelete($array2, $i)
EndIf
Next
EndIf
FileDelete($new_xml)
FileWrite($new_xml, $txt)
GuiCtrlSetData($edit, $txt)
;~ Run("notepad.exe " & $new_xml)
Case $RAZ
FileDelete($xml)
FileMove ("tasks-orig.xml", "tasks.xml", 0)
MsgBox(0,"information","Fichier tasks.xml d'origne restauré, relancer tasks-read.exe si vous voulez faire de nouvelles modifications")
Exit
EndSwitch
Wend