i made this script for security reasons, it asks you all the time if a running program is oke.
the include file compinfo.au3 can be found here: compinfo.au3 topic
please take a look at it.
does someone know how to modify this sothat the cpu usage will go down?
;includes------------------------------ #include<GUIConstants.au3> #include <GuiListView.au3> #include <CompInfo.au3> ;options------------------------------ Opt("GUICloseOnESC",0) Opt("GUIOnEventMode",1) Opt("OnExitFunc","OnAutoItExit") Opt("RunErrorsFatal",0) Opt("TrayAutoPause",0) Opt("TrayIconDebug",1) Opt("TrayMenuMode",1 + 2 + 4) Opt("TrayOnEventMode",1) ;declarations----------------------------- Dim $on = 0 ;0 = uit Dim $Processes Global $hwnd Global $toegevoegd = 0 Global $sleep = 0 ;main gui-------------------------------- GUICreate("Rungate",572,388) GUISetBkColor(0xffffff) GUISetOnEvent($GUI_EVENT_CLOSE,"OnAutoItExit") GuiCtrlSetState(-1,$GUI_DISABLE) GUICtrlCreateLabel("Status:",60,10,120,40) GUICtrlSetFont(-1,30) GUICtrlCreatePic("images\rungate.gif",10,230,148) $list = GUICtrlCreateListView(" Process | Value ",260,10,302,368) $status = GUICtrlCreatePic("images\redshd.gif",200,10,(37 * 60) / 46,60) $on_off = GUICtrlCreatePic("images\end_up.jpg",10,10,40,40) $add = GUICtrlCreateButton("Add",160,388 - 90,90,20) $remove = GUICtrlCreateButton("Remove",160,388 - 60,90,20) $edit = GUICtrlCreateButton("Edit",160,388 - 30,90,20) $timer = GUICtrlCreateSlider(10,60,100,20) GUICtrlSetLimit($timer,10,0) GUICtrlSetOnEvent($on_off,"_on_off") GUICtrlSetOnEvent($add,"_add_list") GUICtrlSetOnEvent($remove,"_remove_list") GUICtrlSetOnEvent($edit,"_edit_list") GUISetState() ;run before starting to use------------------------- _processes() ;main loop-------------------------------------- While 1 If $on = 1 Then Dim $Processes _ComputerGetProcesses($Processes) For $i = 1 To $Processes[0][0] Step 1 If $on = 0 Then ExitLoop EndIf $ini = IniRead("processes.ini","processes",$Processes[$i][0],"-") If $ini = "1" Then ;doe niets ElseIf $ini = "0" Then ProcessClose($Processes[$i][0]) ElseIf $ini = "-" Then $toegevoegd = 0 _check("Name: " & $Processes[$i][0] & @CRLF & "Path: " & $Processes[$i][7] & @CRLF & "discription: " & $Processes[$i][4]) EndIf Next Else $first = GUICtrlRead($timer) Sleep($first) If $sleep = ($first * 1000 * 60) Then $sleep = 0 _on_off() EndIf $sleep = $sleep + 1 If $first <> GUICtrlRead($timer) Then $sleep = 0 EndIf EndIf GUICtrlSetTip($timer,GUICtrlRead($timer)) WEnd ;on/off switch---------------------------- Func _on_off() If $on = 0 Then GUICtrlSetImage($status,"images\greenshd.gif",-1) $on = 1 ElseIf $on = 1 Then GUICtrlSetImage($status,"images\redshd.gif",-1) $on = 0 EndIf EndFunc ;updateing list------------------------------------- Func _processes() _GUICtrlListViewDeleteAllItems($list) $ini = IniReadSection("processes.ini","processes") If not(@error) Then For $n = 1 to $ini[0][0] _GUICtrlListViewInsertItem($list, -1,$ini[$n][0] & "|" & $ini[$n][1]) Next EndIf EndFunc ;list editing--------------------------------------------- Func _add_list() $app = InputBox("Rungate","which process?") If @error = 0 Then $value = InputBox("Rungate","which value?" & @CRLF & "0 = block" & @CRLF & "1 = allow") If @error = 0 Then IniWrite("processes.ini","processes",$app,$value) _processes() EndIf EndIf EndFunc Func _remove_list() $key = _GUICtrlListViewGetItemText($list,_GUICtrlListViewGetSelectedIndices($list),0) IniDelete("processes.ini","processes",$key) _processes() EndFunc Func _edit_list() $key = _GUICtrlListViewGetItemText($list,_GUICtrlListViewGetSelectedIndices($list),0) $key2 = _GUICtrlListViewGetItemText($list,_GUICtrlListViewGetSelectedIndices($list),1) $app = InputBox("Rungate","which process?",$key) If @error = 0 Then $value = InputBox("Rungate","which value?" & @CRLF & "0 = block" & @CRLF & "1 = allow",$key2) If @error = 0 Then IniDelete("processes.ini","processes",$key) IniWrite("processes.ini","processes",$app,$value) _processes() EndIf EndIf EndFunc ;service and processes check------------------------- Func _check($pros) $hwnd = GUICreate("Rungate",200,200,@DesktopWidth - 200,(@DesktopHeight / 2) - 100) GUISetOnEvent($GUI_EVENT_CLOSE,"OnAutoItExit2") $info = GUICtrlCreateLabel($pros,4,4,200 - 4 - 4,200 - 40 -4) $toestaan = GUICtrlCreateButton("Allow",4,200 - 24,71,20) GUICtrlSetOnEvent($toestaan,"_toestaan") $block = GUICtrlCreateButton("Block",4 + 71 + 4,200 - 24,71,20) GUICtrlSetOnEvent($block,"_block") GUISetState() Do Sleep(10) Until $toegevoegd = 1 EndFunc Func _block() GUIDelete() IniWrite("processes.ini","processes",$Processes[$i][0],"0") ProcessClose($Processes[$i][0]) _processes() $toegevoegd = 1 EndFunc Func _toestaan() GUIDelete() IniWrite("processes.ini","processes",$Processes[$i][0],"1") _processes() $toegevoegd = 1 EndFunc ;exit functions------------------------ Func OnAutoItExit() Exit EndFunc Func OnAutoItExit2() GUIDelete() $toegevoegd = 0 EndFunc
the images, see below.
Attached Files
Edited by Pakku, 16 November 2010 - 12:23 AM.






