je suis débutant
voilà plusieurs jours que je galère sur un script
le but de mon projet est de réaliser une listview avec possibilité d'enregistrer et de supprimé un utilisateur en cochant la case qui lui est associée
enregistrement est ok mais pas la suppression ...
voici mon script merci pour votre aide
► Afficher le texte
Code : Tout sélectionner
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=..\Desktop\test.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>
#include <Misc.au3>
#Include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
Global $dll = DllOpen("user32.dll")
Dim $sFile = "Config.ini"
$aTaskbar = WinGetPos("[CLASS:Shell_TrayWnd]", "")
Dim $CompteurUtilisateurs = 0
Main()
Func Main()
; create main GUI
GLOBAL $Principale = GUICreate("test", 240, 550, @DesktopWidth, @DesktopHeight, -1, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
$hButton_Parametres = GUICtrlCreateButton("Parametres", 10, 30, 90, 30)
$hButton_Start = GUICtrlCreateButton("Demarrer", 95, 500, 60, 30)
GUISetState()
$aWin = WinGetPos($Principale)
WinMove($Principale, "", @DesktopWidth - $aWin[2] - 22, @DesktopHeight - $aWin[1] - -137)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $hButton_Parametres
parametres()
Case $hButton_Start
;notepad()
EndSwitch
WEnd
EndFunc
Func parametres()
$Teamread = IniRead($sFile, "Configuration", "Team", "")
$Pseudoread = IniRead($sFile, "Configuration", "Pseudo", "")
$AffichageRead = IniRead($sFile, "Configuration", "Affichage", "")
$Affichage = "800x600|1024x768|1900x1200"
$hParamGUI = GUICreate("Parametre", 400, 600, -1, -1, -1, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
GUICtrlCreateLabel("Team", 10, 10, 80, 20)
$Team = GUICtrlCreateInput($Teamread, 10, 30, 200, 20)
GUICtrlCreateLabel("Affichage", 10, 60, 200, 20)
$Affichage = GUICtrlCreateCombo($AffichageRead, 10, 80, 200, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "800x600|1024x768|1900x1200")
GUICtrlCreateLabel("Pseudo :", 10, 110, 80, 20)
$Pseudo = GUICtrlCreateInput($Pseudoread, 10, 130, 200, 20)
$hButton_add = GUICtrlCreateButton("Add Users", 10, 270, 80, 30)
$hButton_Sauvegarder = GUICtrlCreateButton("Sauvegarder", 90, 270, 100, 30) ;prochain bouton compte principale
$hButton_Souris = GUICtrlCreateButton("Position Souris", 10, 160, 100, 30)
$hButton_supprimer = GUICtrlCreateButton("Supprimer", 190, 270, 100, 30)
Global $ListView1 = GUICtrlCreateListView("",8, 313, 610, 230, $GUI_SS_DEFAULT_LISTVIEW, BitOR($LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_AddColumn($ListView1, "Pseudo", 60)
_GUICtrlListView_AddColumn($ListView1, "Team", 60)
_GUICtrlListView_AddColumn($ListView1, "Affichage", 60)
_GUICtrlListView_AddColumn($ListView1, "souris y", 60)
_GUICtrlListView_AddColumn($ListView1, "souris x", 60)
_GUICtrlListView_AddColumn($ListView1, "Suprimer", 60)
ChargerUtilisateurs()
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
GUIDelete($hParamGUI)
GuiDelete($Principale)
main()
Case $hButton_add
Ajouter(GUICtrlRead($Pseudo), GUICtrlRead($Team), GUICtrlRead($Affichage), ($y), ($x))
Case $hButton_supprimer
_GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($ListView1))
Case $hButton_Souris
Sourispos()
EndSwitch
WEnd
EndFunc
Func Sourispos()
SplashTextOn("Position Souris", "Deplacez la souris sur l'endroit a enregistrer puis faites click gauche", -1, 100, 200, 100, 0, "verdana", 12, 450)
While _IsPressed("01", $dll) =0 ;Will continue to loop if button isn't pressed
sleep(50)
WEnd
While _IsPressed("01", $dll) ;Will continue to loop when button is pressed.
sleep(50)
WEnd
$pos = MouseGetPos() ;Gets mouse position once button is released
Global $x = $pos[0]
Global $y = $pos[1]
splashOff()
EndFunc
Func Ajouter($Pseudo, $Team, $Affichage, $y, $x)
$CompteurUtilisateurs += 1
GUICtrlCreateListViewItem($Pseudo & "|" & $Team & "|" & $Affichage & "|" & $y & "|" & $x , $ListView1)
IniWrite($sFile, "Utilisateur" & $CompteurUtilisateurs, "Nom", $Pseudo)
IniWrite($sFile, "Utilisateur" & $CompteurUtilisateurs, "Team", $Team)
IniWrite($sFile, "Utilisateur" & $CompteurUtilisateurs, "Résolution", $Affichage)
IniWrite($sFile, "Utilisateur" & $CompteurUtilisateurs, "Position souris y", $y)
IniWrite($sFile, "Utilisateur" & $CompteurUtilisateurs, "Position souris x", $x)
EndFunc
Func ChargerUtilisateurs()
Local $NomSections
Local $NomChamps
If(FileExists($sFile)) Then
$NomSections = IniReadSectionNames($sFile)
For $i = 1 To $NomSections[0]
$NomChamps = IniReadSection($sFile, $NomSections[$i])
If($NomChamps[0][0] >= 5) Then
Ajouter($NomChamps[1][1], $NomChamps[2][1], $NomChamps[3][1] , $NomChamps[4][1], $NomChamps[5][1])
EndIf
Next
EndIf
EndFunc
func SupprimerUtilisteurs()
If _GUICtrlListView_GetItemChecked($ListView1, "") = True Then
IniDelete ($Pseudo)
IniDelete($Team)
IniDelete($Affichage)
IniDelete($x)
IniDelete($y)
EndIf
EndFunc


