Code : Tout sélectionner
#include <GuiConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListBoxConstants.au3>
#include <ListViewConstants.au3>
#include <GUIListView.au3>
#include <inet.au3>
#include <array.au3>
#include <File.au3>
#include <WindowsConstants.au3>
;Mode de prise en compte des évenements
Opt("GUIOnEventMode", 1)
dim $a_Fichier_Lst_Stations
$Fichier_Lst_Stations=@ScriptDir&"\_liste_stations.csv"
;Définition de la GUI et de la liste view
$GUI = GUICreate("Réveil des stations par le réseau (WOL)", 712, 468, 192, 126)
;Le groupe stations
$Grp_action_station = GUICtrlCreateGroup("Stations", 8, 8, 432, 377)
;La liste View des Stations
$Lst_Stations = _GUICtrlListView_Create($GUI, "", 10, 25, 428, 356, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS))
_GUICtrlListView_SetExtendedListViewStyle($Lst_Stations, $LVS_EX_FULLROWSELECT)
; Création des colonnes dans la listeView
_GUICtrlListView_InsertColumn($Lst_Stations, 0, "Nom netbios", 100)
_GUICtrlListView_InsertColumn($Lst_Stations, 1, "OS", 55)
_GUICtrlListView_InsertColumn($Lst_Stations, 2, "ARCHI", 50)
_GUICtrlListView_InsertColumn($Lst_Stations, 3, "MAC", 60)
;_GUICtrlListView_InsertColumn($Lst_Stations, 4, "P2", 35)
;_GUICtrlListView_InsertColumn($Lst_Stations, 5, "P3", 35)
;_GUICtrlListView_InsertColumn($Lst_Stations, 6, "P4", 35)
If Not _FileReadToArray($Fichier_Lst_Stations, $a_Fichier_Lst_Stations) Then
MsgBox(0,@scriptname,"Problème pour lire "&$Fichier_Lst_Stations&@CRLF&"code erreur : " & @error)
Exit
EndIf
$nb_stations=$a_Fichier_Lst_Stations[0]
dim $a_Lst_Stations[$nb_stations][4]
For $i=0 To UBound ($a_Fichier_Lst_Stations)-2
$a_Detail_Station=StringSplit($a_Fichier_Lst_Stations[$i],";,")
if $a_Detail_Station[0]=4 Then
$a_Lst_Stations[$i][2]=$a_Detail_Station[4] ;archi
$a_Lst_Stations[$i][1]=$a_Detail_Station[3] ;os
$a_Lst_Stations[$i][0]=$a_Detail_Station[2] ;nom
$a_Lst_Stations[$i][3]=$a_Detail_Station[1] ;mac
EndIf
Next
_ArrayDeleteEmptyRows($a_Lst_Stations)
_ArraySort($a_Lst_Stations,0,0,0,0)
GUISetState(@SW_SHOW)
for $i=0 to UBound($a_Lst_Stations)-1
Local $iIndex=_GUICtrlListView_AddItem($Lst_Stations,$a_Lst_Stations[$i][0],-1 , _GUICtrlListView_GetItemCount($Lst_Stations) + 9999)
For $x = 1 To 3
_GUICtrlListView_AddSubItem($Lst_Stations, $iIndex, $a_Lst_Stations[$i][$x], $x)
Next
Next
GUISetState(@SW_SHOW)
_GUICtrlListView_RegisterSortCallBack($Lst_Stations, False,True)
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
;Evenements
While 1
GUISetOnEvent($GUI_EVENT_CLOSE, "Fin")
WEnd
;---------------------------------------------------------------------------------------------------------------------------------------
;---------------------------------------------------------------------------------------------------------------------------------------
;*********************
;*********************
;** Les Fonctions **
;*********************
;*********************
;---------------------------------------------------------------------------------------------------------------------------------------
; _ArrayDeleteEmptyRows
; supprime les lignes vides d'un tableau http://www.autoitscript.fr/forum/viewtopic.php?f=21&t=9856
;---------------------------------------------------------------------------------------------------------------------------------------
Func _ArrayDeleteEmptyRows(ByRef $_array)
Local $dims = UBound($_array, 0), $fired = 0
If not IsArray($_array) Or $dims > 2 Then Return
Switch $dims
Case 1 ; array 1D
Local $temp[UBound($_array)]
For $i = 0 To UBound($_array)-1
If $_array[$i] = "" Then ; si ligne vide (ou autre condition)
$fired += 1
ContinueLoop ; passe à la ligne suivante
EndIf
$temp[$i-$fired] = $_array[$i]
Next
Redim $temp[UBound($_array)-$fired]
Case 2 ; array 2D
Local $cols = UBound($_array, 2), $row = ""
Local $temp[UBound($_array)][$cols]
For $i = 0 To UBound($_array)-1
For $j = 0 To $cols-1
$row &= $_array[$i][$j] ; concatène la ligne
Next
If $row = "" Then ; si ligne vide (ou autre condition)
$fired += 1
ContinueLoop ; passe à la ligne suivante
EndIf
For $j = 0 To $cols-1
$temp[$i-$fired][$j] = $_array[$i][$j]
Next
$row = ""
Next
Redim $temp[UBound($_array)-$fired][$cols]
EndSwitch
$_array = $temp
$temp = ""
EndFunc
;--------------------------------------------------------------------------------
; Fonctions _WM_NOTIFY : Fonction utile au tri
; permet le tri par colonne http://www.autoitscript.fr/forum/viewtopic.php?f=4&t=3030
;--------------------------------------------------------------------------------
Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iCode, $tNMHDR, $hWndListView, $hWndListView2
$hWndListView = $Lst_Stations
If Not IsHWnd($Lst_Stations) Then $hWndListView = GUICtrlGetHandle($Lst_Stations)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $Lst_Stations
Switch $iCode
Case $LVN_COLUMNCLICK ; A column was clicked
Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
; Kick off the sort callback
_GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, "SubItem"))
; No return value
EndSwitch
EndSwitch
Return $__LISTVIEWCONSTANT_GUI_RUNDEFMSG
EndFunc ;==>_WM_NOTIFY
Func Fin()
_GUICtrlListView_UnRegisterSortCallBack($Lst_Stations)
GUIRegisterMsg($WM_NOTIFY, "")
Exit
GUIDelete($GUI)
EndFunc ;==>Fin