Pakku Posted August 22, 2006 Share Posted August 22, 2006 (edited) hi,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 topicplease take a look at it. does someone know how to modify this sothat the cpu usage will go down?expandcollapse popup;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 EndFuncthe images, see below.rungate.zip Edited November 16, 2010 by Pakku How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:My filemanMy profilePM me Link to comment Share on other sites More sharing options...
theguy0000 Posted August 22, 2006 Share Posted August 22, 2006 try adding Sleep (50) AFTER the EndIf in the main loop The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
Skrip Posted August 22, 2006 Share Posted August 22, 2006 Heh, you might want to supply the images... [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
Pakku Posted August 22, 2006 Author Share Posted August 22, 2006 @theguy0000 hi, that isn't working, it is going up and down between 70% en 20% cpu usage. @Firestorm i will edit my first post How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:My filemanMy profilePM me Link to comment Share on other sites More sharing options...
JSThePatriot Posted August 22, 2006 Share Posted August 22, 2006 (edited) Calling my functions will use a bit of processor. I dont believe it should be a consistant value, but it may be since you are constantly calling it. You may condider adding an option to check every 1-10 minutes versus checking all the time. That way your program would have a moment to sleep unless the user explicitly wants it not to. I also noticed you had a bit of code in your _processes() function that looked like this...If @error = 1 Then Else ;You did something here EndIfoÝ÷ Ù8^æ«y§(º^¡ûax,¶r¥u·{ajÛ-jצz{E»-Ç(«x-ç«®í¢Ø^ÔƲmè}ê뢴ázâÂ¥u·zÛ^«)è7«¢{¦mêâ±Ê'²'^çm®ç+0¢é]jYhÃ*.¶µÈZ[ayê뢻Ùè¶;¬µ«)yÈÊ'y8^ìm¶§*.ç¶hÇh²¶§'âµê뢻=¶)²¡ýt!©¬º·²¢êߺw-éz·è®k-ç(®··²nëm«uÒØmg²¢ç¢¶«ç¶h²¶§ëzÛ«¡ûayû§rب¥£ "h+ÞʱjjezËajÛ!¢é]Âäjëh×6;Method 1 If @error Then Return Else ;Your existing code. EndIf ;Method 2 If Not(@error) Then ;Your existing code. EndIf Edit01: I wanted to thank you for posting a link to my UDF's. I appreciate your seeing a good use for them. I hope this helps you in your AutoIt Experience, JS Edited August 22, 2006 by JSThePatriot AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Pakku Posted August 22, 2006 Author Share Posted August 22, 2006 (edited) @JSThePatriot thanks for your response. i allways put a link to my resources (only to very good resources). i have changed the code a bit and i edited my first post. Edited November 16, 2010 by Pakku How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:My filemanMy profilePM me Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 22, 2006 Share Posted August 22, 2006 This seems like a spin off on my Process Watcher. Mine only asked when programs started though, and it was an option to ask in the first place. Link to comment Share on other sites More sharing options...
autosc Posted August 23, 2006 Share Posted August 23, 2006 hi, 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? expandcollapse popup#include<GUIConstants.au3> #include<GuiListView.au3> #include<CompInfo.au3> 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) Func OnAutoItExit() Exit EndFunc Func OnAutoItExit2() GUIDelete() $toegevoegd = 1 EndFunc Dim $on = 0 ; uit Dim $Processes Dim $Processes Global $hwnd Global $toegevoegd = 0 GUICreate("Rungate",572,388,0,0) GUISetBkColor(0xffffff) GUISetOnEvent($GUI_EVENT_CLOSE,"OnAutoItExit") GuiCtrlSetState(-1,$GUI_DISABLE) GUICtrlCreateLabel("Status:",60,10,120,40) GUICtrlSetFont(-1,30) $status = GUICtrlCreatePic("images\redshd.gif",200,10,(37 * 60) / 46,60) $on_off = GUICtrlCreatePic("images\end_up.jpg",10,10,40,40) GUICtrlSetOnEvent($on_off,"_on_off") GUICtrlCreatePic("images\rungate.gif",10,230,148) $list = GUICtrlCreateListView(" Process | Value ",160,80,402,260) GUISetState() _processes() 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],1) EndIf Sleep(10) Next ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Dim $Services _ComputerGetServices($Services, "Running") For $ii = 1 To $Services[0][0] Step 1 If $on = 0 Then ExitLoop EndIf $inii = IniRead("processes.ini","services",$Services[$ii][0],"-") If $inii = "1" Then Sleep(1) ElseIf $inii = "0" Then ProcessClose($Services[$ii][0]) ElseIf $inii = "-" Then $toegevoegd = 0 _check("Name: " & $Services[$ii][0] & @CRLF & "discription: " & $Services[$ii][4],2) EndIf Next Else Sleep(10) EndIf WEnd 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 Func _processes() _GUICtrlListViewDeleteAllItems($list) $ini = IniReadSection("processes.ini","processes") If @error = 1 Then Else For $n = 1 to $ini[0][0] _GUICtrlListViewInsertItem($list, -1,$ini[$n][0] & "|" & $ini[$n][1]) Next EndIf EndFunc Func _check($pros,$type) $hwnd = GUICreate("Rungate",200,200,@DesktopWidth - 200,(@DesktopHeight / 2) - 100) GUISetOnEvent($GUI_EVENT_CLOSE,"OnAutoItExit") $info = GUICtrlCreateLabel($pros,4,4,200 - 4 - 4,200 - 40 -4) $toestaan = GUICtrlCreateButton("allow",4,200 - 24,71,20) $block = GUICtrlCreateButton("Block",4 + 71 + 4,200 - 24,71,20) If $type = 1 Then GUICtrlSetOnEvent($toestaan,"_toestaan") GUICtrlSetOnEvent($block,"_block") ElseIf $type = 2 Then GUICtrlSetOnEvent($toestaan,"_toestaan2") GUICtrlSetOnEvent($block,"_block2") EndIf GUICtrlSetOnEvent($GUI_EVENT_CLOSE,"OnAutoItExit2") 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 Func _block2() GUIDelete() IniWrite("processes.ini","services",$Services[$ii][0],"0") RunWait("sc stop '" & $Services[$ii][0] & "'") _processes() $toegevoegd = 1 EndFunc Func _toestaan2() GUIDelete() IniWrite("processes.ini","services",$Services[$ii][0],"1") _processes() $toegevoegd = 1 EndFunc the images, see below. Nothing happens on my screen while using yopur script . Just the GUI displays ... no more ! Link to comment Share on other sites More sharing options...
Pakku Posted August 23, 2006 Author Share Posted August 23, 2006 (edited) you have to hit the on/off switch in the right corner. EDIT: see first post Edited November 16, 2010 by Pakku How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:My filemanMy profilePM me Link to comment Share on other sites More sharing options...
JSThePatriot Posted August 23, 2006 Share Posted August 23, 2006 you have to hit the on/off switch in the right corner.EDIT: see first postAre you going to modify the If statements as I posted in my first reply to this thread? I think that would help clean up your code. I dont know that it would give you any advantage over CPU usage as I think that comes from my UDF's that you are using, but its always worth a try.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Pakku Posted August 24, 2006 Author Share Posted August 24, 2006 (edited) hi, i'm a little bussy with the new version of it so it will come later. thanks for your reply! Edited November 16, 2010 by Pakku How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:My filemanMy profilePM me Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now