Code : Tout sélectionner
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#include <Array.au3>
#Region ### START Koda GUI section ### Form=
Global $fDblClk = False
Global $ar_Array
$Form1 = GUICreate("Services", 633, 447, 192, 124)
$List1 = GUICtrlCreateListView("", 8, 8, 617, 383)
_GUICtrlListView_AddColumn($List1, "Servcies Name", 200)
_GUICtrlListView_AddColumn($List1, "Status", 200)
_GUICtrlListView_AddColumn($List1, "Description", 200)
$Lst_Handle = GUICtrlGetHandle(-1)
$Button1 = GUICtrlCreateButton("Lister", 144, 408, 97, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Exit", 336, 408, 97, 25, $WS_GROUP)
GUIRegisterMsg($WM_NOTIFY, "WM_ListView_DoubleClick")
GUISetState(@SW_SHOW, $Form1)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Lister()
Case $Button2
exit
EndSwitch
Sleep(10)
If $fDblClk = True Then
$fDblClk = False
Lst_ValuesClick()
EndIf
WEnd
Func Lister()
_GUICtrlListView_DeleteAllItems($List1)
$strComputer = "127.0.0.1"
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colProcessList = $objWMIService.ExecQuery("Select * from Win32_Service")
For $objProcess In $colProcessList
$services = $objProcess.Caption
$status = $objProcess.State
$Description = $objProcess.Description
GUICtrlCreateListViewItem($services & "|" & $status & "|" & $Description, $List1)
Next
EndFunc
Func Lst_ValuesClick()
$SelIndexItem = _GUICtrlListView_GetSelectedIndices($List1) +0
$SelIndex = _GUICtrlListView_GetItem($List1, $SelIndexItem)
$Form2 = GUICreate("Action à réaliser", 333, 159, 327, 268)
$Label1 = GUICtrlCreateLabel("Vous avez sélectionner le service : ", 16, 16, 171, 17)
$Label2 = GUICtrlCreateLabel("", 16, 40, 308, 20)
$Label3 = GUICtrlCreateLabel("Action : ", 16, 80, 43, 17)
$Combo1 = GUICtrlCreateCombo("", 64, 80, 60, 25)
GUICtrlSetData(-1, "Start|Stop|Restart")
$Button3 = GUICtrlCreateButton("Lancer", 224, 80, 89, 25, $WS_GROUP)
$Button4 = GUICtrlCreateButton("Fermer", 224, 110, 89, 25, $WS_GROUP)
GUISetState()
GUICtrlSetData($Label2, $SelIndex[3])
GUICtrlSetState($Button3, $GUI_DISABLE)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
GUIDelete($Form2)
ExitLoop
Case $Button4
GUIDelete($Form2)
ExitLoop
EndSwitch
Sleep(10)
If GUICtrlRead($Combo1) <> "" Then
GUICtrlSetState($Button3, $GUI_ENABLE)
Endif
WEnd
EndFunc
Func WM_ListView_DoubleClick($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $wParam
Local $tNMHDR = DllStructCreate("int;int;int", $lParam)
If @error Then Return
If DllStructGetData($tNMHDR, 1) = $Lst_Handle Then
If DllStructGetData($tNMHDR, 3) = $NM_DBLCLK Then $fDblClk = True
EndIf
$tNMHDR = 0
Return $GUI_RUNDEFMSG
EndFunc