Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#Include <GuiTreeView.au3>
#include <StaticConstants.au3>
#include <IE.au3>
;====================================================================================
; Name : Startup_software
; Description : Manage the startup-software
; Author : Jbnh <hardwarez@hotmail.co.uk>
; Note(s) : Please be carefull with this kind of manipulation
; ===================================================================================
If Not FileExists("Startup_soft_log.htm") Then
FileWrite("Startup_soft_log.htm","<font face=Verdana size=1> All your modifications...<br>")
EndIf
GUICreate("Startup", 430, 210)
$treeview = GUICtrlCreateTreeView(6, 6, 150, 200, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewItem("CurrentVersion\Run", $treeview)
GUICtrlSetColor(-1, 0x0000C0)
_GetInstalledItems()
GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON))
_GUICtrlTreeView_Sort($treeview)
Func _GetInstalledItems()
$i = 0
Do
$i = $i + 1
$var = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $i)
If @error <> 0 Then $i = -1
GUICtrlCreateTreeViewItem($var, $generalitem)
Until $i = -1
Endfunc
GUICtrlCreateLabel("Nom", 160, 10) ;Le nom de la key
$nom = GUICtrlCreateInput("", 190, 10, 210, 20)
GUICtrlCreateLabel("Path", 160, 40) ;Le chemin de l'executable
$path = GUICtrlCreateInput("", 190, 40, 210, 20)
$btn1 = GUICtrlCreateButton("...", 405, 40, 20, 20)
$btn2 = GUICtrlCreateButton("Create", 165, 70, 80)
$btn3 = GUICtrlCreateButton("Delete", 250, 70, 80)
$btn4 = GUICtrlCreateButton ("Annuler ", 335, 70, 80)
$pic1 = GUICtrlCreatePic ("help.jpg", 170, 105, 255,100)
GUISetState(@SW_SHOW)
GUICtrlSetState($Btn2, $GUI_DISABLE)
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") ; Déclare la fonction WM_Notify_Events
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $btn1
$Opened_File = FileOpenDialog("Open Script/Executable File", "", "All executable Files (*.exe;*.au3)|All Files (*.*)",12)
GUICtrlSetData($path, $Opened_File)
GUICtrlSetState($btn2, $GUI_ENABLE)
Case $msg = $btn2
Regwrite ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", GUICtrlRead($nom),"REG_SZ", GUICtrlRead($path))
$var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", GUICtrlRead($nom))
If $var = GUICtrlRead($path) Then
MsgBox(0, "Startup_Create", "The key has been well created")
$file = FileOpen("Startup_soft_log.htm", 1)
FileWrite($file, "The keyname <font color=#FF8000 style=font-size:12px><i>"&GUICtrlRead($nom)&"</i></font>with the value <font color=#FF8000 style=font-size:12px><i>"&GUICtrlRead($path)&"</i></font> has been created in "&@year&"\"&@mon&"\"&@mday&"<br> ")
Else
MsgBox(0, "Startup_Create", "An error occurred")
Endif
ExitLoop
Case $msg = $btn3
$var2 = RegDelete ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", GUICtrlRead($nom))
If $var2 = 1 Then
MsgBox(0, "Startup_Create", "The key has been well deleted")
$file = FileOpen("Startup_soft_log.htm", 1)
FileWrite($file, "The keyname <font color=#FF8000 style=font-size:12px><i>"&GUICtrlRead($nom)&"</i></font> has been deleted in "&@year&"\"&@mon&"\"&@mday&" <br>")
Else
MsgBox(0, "Startup_Create", "This name doesn't exist")
Endif
ExitLoop
Case $msg = $btn4
ExitLoop
Case $msg = $pic1
$oIE = _IECreate ("http://www.autoitscript.fr/forum/viewtopic.php?f=6&t=1114")
EndSelect
Wend
Func Treeview_Click() ; action suite simple clic
$cle = _GUICtrlTreeView_GetText($treeview,_GUICtrlTreeView_GetSelection($treeview))
GUICtrlSetData($nom,$cle)
GUICtrlSetData($path,RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $cle))
EndFunc ;==>Treeview_Click
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) ; WM_NOTIFY event handler
Local $tagNMHDR, $event
$tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code)
If @error Then Return
$event = DllStructGetData($tagNMHDR, 3)
Select
Case $wParam = $treeview
Select
Case $event = $NM_CLICK
Treeview_Click()
EndSelect
EndSelect
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_Notify_Events