Code : Tout sélectionner
#include <GuiConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <ListviewConstants.au3>
$width = 510
$height = 380
$titre = "test"
$GUI = GUICreate($titre, $width, $height)
$button = GUICtrlCreateButton("Value?", 20, 280, 70, 20)
$ListView = GUICtrlCreateListView("Activé|Programme|Emplacement Fichier", 20, 25, $width - 45, 250, -1)
For $i = 1 To 100
$var = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $i)
If @error <> 0 Then ExitLoop
GUICtrlCreateListViewItem("oui" & "|" & $var & "|" & RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $var), $ListView)
GUICtrlSetState(-1, $GUI_CHECKED)
Next
For $i1 = 1 To 100
$var1 = RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", $i1)
If @error <> 0 Then ExitLoop
GUICtrlCreateListViewItem("oui" & "|" & $var1 & "|" & RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", $var1), $ListView)
GUICtrlSetState(-1, $GUI_CHECKED)
Next
For $i = 1 To 100
$var1 = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg", $i)
If @error <> 0 Then ExitLoop
GUICtrlCreateListViewItem("non" & "|" & $var1 & "|" & RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $var1, "command"), $ListView)
Next
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $button
If GUICtrlRead(GUICtrlRead($ListView)) == 0 Then
MsgBox(16, "listview item", "Vous n'avez pas selectionné de programme")
Else
;MsgBox(0, "listview item", GUICtrlRead(GUICtrlRead($ListView)))
If StringLeft(GUICtrlRead(GUICtrlRead($ListView)), 3) == "oui" Then
$oui = MsgBox(4, $titre, "Ce programme est lancé au démarrage,souhaitez vous le retirer ?")
If $oui == 6 Then
$groupe2 = 2 ;0 étant le nombre de groupe 2 étant le permier groupe ...
$fichier = GUICtrlRead(GUICtrlRead($ListView))
$tab = StringSplit($fichier, "|")
;MsgBox(0, "", $tab[$groupe2])
$groupe3 = 3 ;0 étant le nombre de groupe 3 étant le dexieme groupe ...
$fichier = GUICtrlRead(GUICtrlRead($ListView))
$tab = StringSplit($fichier, "|")
;MsgBox(0, "", $tab[$groupe3])
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2], "key", "REG_SZ", "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2], "item", "REG_SZ", $tab[$groupe2])
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2], "command", "REG_SZ", $tab[$groupe3])
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2], "inimapping", "REG_SZ", "0")
If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $tab[$groupe2]) = $tab[$groupe3] Then
;MsgBox(0, $titre & "test registre", RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $tab[$groupe2]))
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2], "hkey", "REG_SZ", "HKLM")
RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $tab[$groupe2])
EndIf
If RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", $tab[$groupe2]) = $tab[$groupe3] Then
;MsgBox(0, $titre & "test registre", RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", $tab[$groupe2]))
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2], "hkey", "REG_SZ", "HKCU")
RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", $tab[$groupe2])
EndIf
EndIf
EndIf
If StringLeft(GUICtrlRead(GUICtrlRead($ListView)), 3) == "non" Then
$oui = MsgBox(4, $titre, "Ce programme n'est pas lancé au démarrage,souhaitez vous le rajouter ?")
If $oui == 6 Then
$groupe2 = 2 ;0 étant le nombre de groupe 2 étant le permier groupe ...
$fichier = GUICtrlRead(GUICtrlRead($ListView))
$tab = StringSplit($fichier, "|")
;MsgBox(0, "", $tab[$groupe2])
$groupe3 = 3 ;0 étant le nombre de groupe 3 étant le deuxieme groupe ...
$fichier = GUICtrlRead(GUICtrlRead($ListView))
$tab = StringSplit($fichier, "|")
;MsgBox(0, "", $tab[$groupe3])
$valuename = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2], "hkey")
If $valuename = "HKLM" Then
;MsgBox(0, "", "HKLM")
$keyname = "HKEY_LOCAL_MACHINE\"
$key = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2], "key")
$item = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2], "item")
$command = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2], "command")
RegWrite($keyname & $key, $item, "REG_SZ", $command)
RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2])
EndIf
If $valuename = "HKCU" Then
;MsgBox(0, "", "HKCU")
$keyname = "HKEY_LOCAL_MACHINE\"
$key = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2], "key")
$item = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2], "item")
$command = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2], "command")
RegWrite($keyname & $key, $item, "REG_SZ", $command)
RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\" & $tab[$groupe2])
EndIf
EndIf
EndIf
EndIf
; Case $msg = $listview
; MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview))
EndSelect
WEnd