oageng Posted May 20, 2009 Share Posted May 20, 2009 I want to create a list of processes and the script to compare against the running processes and close any process not on the list. How do I do this? And if somebody wants to launch Task Manager, they press a hotkey and prompted to enter a password. How? This is functionality that I want: 1)Compare running processes against a process list, and close any process not on list 2)Assign a hotkey for opening Task Manger 3)Prompt for password to open Task Manager Link to comment Share on other sites More sharing options...
oMBRa Posted May 20, 2009 Share Posted May 20, 2009 1) search in the helpfile for ProcessList 2) hotkeyset 3) when u run task manager make the window invisible, ask the password and if it is right make the window visible Link to comment Share on other sites More sharing options...
oageng Posted May 20, 2009 Author Share Posted May 20, 2009 1) search in the helpfile for ProcessList2) hotkeyset3) when u run task manager make the window invisible, ask the password and if it is right make the window visibleCould you help with the script? I'm still learning how to code scripts Link to comment Share on other sites More sharing options...
oMBRa Posted May 20, 2009 Share Posted May 20, 2009 ask what u didnt understand... Link to comment Share on other sites More sharing options...
oageng Posted May 20, 2009 Author Share Posted May 20, 2009 ask what u didnt understand...Please if you cant help don't make this a burden on yourself. This is not a concrete block. Others may help if they can Link to comment Share on other sites More sharing options...
Yashied Posted May 20, 2009 Share Posted May 20, 2009 I want to create a list of processes and the script to compare against the running processes and close any process not on the list. How do I do this?And if somebody wants to launch Task Manager, they press a hotkey and prompted to enter a password. How?This is functionality that I want:1)Compare running processes against a process list, and close any process not on list2)Assign a hotkey for opening Task Manger3)Prompt for password to open Task ManagerI also do not understand your question. What are you going to compare the resulting list of processes? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
oMBRa Posted May 20, 2009 Share Posted May 20, 2009 (edited) Please if you cant help don't make this a burden on yourself. This is not a concrete block. Others may help if they canif u want someone to make the code for u then go here: www.rentacoder.com, if u have a specific question then ask. Edited May 20, 2009 by oMBRa Link to comment Share on other sites More sharing options...
MrCreatoR Posted May 20, 2009 Share Posted May 20, 2009 (edited) 1)Compare running processes against a process list, and close any process not on list 2)Assign a hotkey for opening Task Manger 3)Prompt for password to open Task ManagerSomething like this: expandcollapse popup#NoTrayIcon Global $sPassword = "AutoIt" Global $sProcList = _ProcessListToString() HotKeySet("^+t", "_Run_TaskMgr_Proc") ;Ctrl + Shift + T will call our function to run task manager HotKeySet("^+e", "_Quit_Proc") ;Ctrl + Shift + E will exit the script AdlibEnable("_CompareProcesses_Proc", 2000) ;Every 2 seconds we compare the processes list While 1 Sleep(100) WEnd Func _ProcessListToString() Local $aProcList = ProcessList() Local $sRet_ProcList = "|" For $i = 1 To $aProcList[0][0] $sRet_ProcList &= $aProcList[$i][1] & "|" Next Return $sRet_ProcList EndFunc Func _Run_TaskMgr_Proc() While 1 Local $iPassword_Ask = InputBox("Task Manager Run", "Please enter password to run Task Manager:", "", "*") If @error Then Return If $iPassword_Ask == $sPassword Then Return Run("Taskmgr.exe") MsgBox(48, "Task Manager Run - Error", "Wrong password, please try again.") WEnd EndFunc Func _CompareProcesses_Proc() Local $aProcList = ProcessList() For $i = 1 To $aProcList[0][0] If Not StringInStr($sProcList, "|" & $aProcList[$i][1] & "|") Then ProcessClose($aProcList[$i][1]) Next EndFunc Func _Quit_Proc() Exit EndFunc ? P.S The comparision process will not be executed when InputBox is displayed, but that also can be fixed with callback timers. Edited May 20, 2009 by MrCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 20, 2009 Moderators Share Posted May 20, 2009 (edited) That seems like it could end up with an awful lot of loops MrCreator. I might suggest reading the first ProcList() into a string with front and back non-digit delimiters. Then loop through the new ProcList() with a StringInStr() method. I only say this, because if I had an exaggerated amount of processes (let's say 200), then every time you call that function, you're going to loop 40,000 times (if no new processes are started). When you could loop just 200. Edited May 20, 2009 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
oageng Posted May 20, 2009 Author Share Posted May 20, 2009 Something like this: expandcollapse popup#NoTrayIcon Global $sPassword = "AutoIt" Global $aProcList = ProcessList() HotKeySet("^+t", "_Run_TaskMgr_Proc") ;Ctrl + Shift + T will call our function to run task manager HotKeySet("^+e", "_Quit_Proc") ;Ctrl + Shift + E will exit the script AdlibEnable("_CompareProcesses_Proc", 2000) ;Every 2 seconds we compare the processes list While 1 Sleep(100) WEnd Func _Run_TaskMgr_Proc() While 1 Local $iPassword_Ask = InputBox("Task Manager Run", "Please enter password to run Task Manager:", "", "*") If @error Then Return If $iPassword_Ask == $sPassword Then Return Run("Taskmgr.exe") MsgBox(48, "Task Manager Run - Error", "Wrong password, please try again.") WEnd EndFunc Func _CompareProcesses_Proc() Local $aCurent_ProcList = ProcessList() Local $iProc_Found = 0 For $i = 1 To $aCurent_ProcList[0][0] $iProc_Found = 0 For $j = 1 To $aProcList[0][0] If $aCurent_ProcList[$i][1] = $aProcList[$j][1] Then $iProc_Found = 1 ExitLoop EndIf Next If Not $iProc_Found Then ProcessClose($aCurent_ProcList[$i][1]) Next EndFunc Func _Quit_Proc() Exit EndFunc ? P.S The comparision process will not be executed when InputBox is displayed, but that also can be fixed with callback timers. Thank you very much. Let me run this and I'll give you feedback (though I'm new to AutoIT). I'm grateful that u were able to understand my idea. We always learn from others. Tomorrow you could lean on me i.e I could also extend my hand Link to comment Share on other sites More sharing options...
MrCreatoR Posted May 20, 2009 Share Posted May 20, 2009 That seems like it could end up with an awful lot of loops MrCreator. I might suggest reading the first ProcList() into a string with front and back non-digit delimiters. Then loop through the new ProcList() with a StringInStr() method.I only say this, because if I had an exaggerated amount of processes (let's say 200), then every time you call that function, you're going to loop 40,000 times (if no new processes are started). When you could loop just 200.Ok, modified my post with the example. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
oageng Posted May 25, 2009 Author Share Posted May 25, 2009 Something like this: expandcollapse popup#NoTrayIcon Global $sPassword = "AutoIt" Global $sProcList = _ProcessListToString() HotKeySet("^+t", "_Run_TaskMgr_Proc") ;Ctrl + Shift + T will call our function to run task manager HotKeySet("^+e", "_Quit_Proc") ;Ctrl + Shift + E will exit the script AdlibEnable("_CompareProcesses_Proc", 2000) ;Every 2 seconds we compare the processes list While 1 Sleep(100) WEnd Func _ProcessListToString() Local $aProcList = ProcessList() Local $sRet_ProcList = "|" For $i = 1 To $aProcList[0][0] $sRet_ProcList &= $aProcList[$i][1] & "|" Next Return $sRet_ProcList EndFunc Func _Run_TaskMgr_Proc() While 1 Local $iPassword_Ask = InputBox("Task Manager Run", "Please enter password to run Task Manager:", "", "*") If @error Then Return If $iPassword_Ask == $sPassword Then Return Run("Taskmgr.exe") MsgBox(48, "Task Manager Run - Error", "Wrong password, please try again.") WEnd EndFunc Func _CompareProcesses_Proc() Local $aProcList = ProcessList() For $i = 1 To $aProcList[0][0] If Not StringInStr($sProcList, "|" & $aProcList[$i][1] & "|") Then ProcessClose($aProcList[$i][1]) Next EndFunc Func _Quit_Proc() Exit EndFunc ? P.S The comparision process will not be executed when InputBox is displayed, but that also can be fixed with callback timers. I tried to modify this because it has an undesired behaviour. It immediately closes Task Manager after entering the password. If it could pause for some specified time or wait for Task Manager to close that would be great. I thought to register Task Manager as soon as the script executes, so that it puts it in the current process list. But this doesn't work. Task Manager doesn't show. What could be the problem? expandcollapse popup#NoTrayIcon Global $sPassword = "deception" Global $aProcList = ProcessList() HotKeySet("!t", "_Run_TaskMgr");Alt+T will call our function to run task manager HotKeySet("!e","Terminate") AdlibEnable("_CompareProcesses_Proc", 2000);Every 2 seconds we compare the processes list While 1 Sleep(100) WEnd Run("Taskmgr.exe","",@SW_HIDE);register Task Manager(in hidden mode) in the current process list Func _Run_TaskMgr() ;While 1 Local $iPassword_Ask = InputBox("Task Manager Run", "Please enter password to run Task Manager:", "", "*") If @error Then Return If $iPassword_Ask == $sPassword Then Return WinSetState("Windows Task Manager","",@SW_SHOW) MsgBox(48, "Task Manager Access - Error", "Wrong password, please try again.") ;WEnd EndFunc Func _CompareProcesses_Proc() Local $aCurent_ProcList = ProcessList() Local $iProc_Found = 0 For $i = 1 To $aCurent_ProcList[0][0] $iProc_Found = 0 For $j = 1 To $aProcList[0][0] If $aCurent_ProcList[$i][1] = $aProcList[$j][1] Then $iProc_Found = 1 ExitLoop EndIf Next If Not $iProc_Found Then ProcessClose($aCurent_ProcList[$i][1]) Next EndFunc Func Terminate() Exit EndFunc Link to comment Share on other sites More sharing options...
Tec Posted May 25, 2009 Share Posted May 25, 2009 You need to start it befor $aProcList = ProcessList() is create #NoTrayIcon Run("Taskmgr.exe","",@SW_HIDE);register Task Manager(in hidden mode) in the current process list Global $sPassword = "deception" Global $aProcList = ProcessList() HotKeySet("!t", "_Run_TaskMgr");Alt+T will call our function to run task manager HotKeySet("!e","Terminate") AdlibEnable("_CompareProcesses_Proc", 2000);Every 2 seconds we compare the processes list While 1 Sleep(100) WEnd . . Link to comment Share on other sites More sharing options...
oageng Posted May 25, 2009 Author Share Posted May 25, 2009 : If $iPassword_Ask == $sPassword Then Return WinSetState("Windows Task Manager","",@SW_SHOW) : How can I make this show for a specified amount of time, and hide Task Manager again? Link to comment Share on other sites More sharing options...
Tec Posted May 25, 2009 Share Posted May 25, 2009 If Not $iProc_Found And $aCurent_ProcList[$i][0] <> "taskmgr.exe" Then ProcessClose($aCurent_ProcList[$i][1]) did you understand what you are doing there ? i don't think so :-| Link to comment Share on other sites More sharing options...
oageng Posted May 25, 2009 Author Share Posted May 25, 2009 If Not $iProc_Found And $aCurent_ProcList[$i][0] <> "taskmgr.exe" Then ProcessClose($aCurent_ProcList[$i][1]) did you understand what you are doing there ? i don't think so :-| I don't understand much, A bit. I do have some idea. I'm still learning... Link to comment Share on other sites More sharing options...
Tec Posted May 25, 2009 Share Posted May 25, 2009 First check what is the resulte from ProcessList() #include <array.au3> Global $aProcList = ProcessList() _ArrayDisplay( $aProcList )oÝ÷ ØX§vÂËaz·¬º[_®´ß¦®ËvÑ©ÝÓ~>º.+-ÛV®¶sb6æ6ÇVFRfÇC¶'&æS2fwC°¤vÆö&Âb33c¶&ö4Æ7BÒ&ö6W74Æ7B¤6öç6öÆUw&FRb33c¶&ö4Æ7E³%Õ³Òfײ5"¤6öç6öÆUw&FRb33c¶&ö4Æ7E³%Õ³Òfײ5"¥ô'&F7Æb33c¶&ö4Æ7B Try to understand what _CompareProcesses_Proc() is doing and how to prevent that taskmgr.exe is closed. _CompareProcesses_Proc() compare $aProcList[$i][1] with aCurent_ProcList[$i][1]. [$i][1] is the pid. So one way is to start the taskmgr.exe and prevent that taskmgr.exe is closed. If Not $iProc_Found And $aCurent_ProcList[$i][0] <> "taskmgr.exe" Then ProcessClose($aCurent_ProcList[$i][1]) $aCurent_ProcList[$i][0] retrun the Processname. So if processname not equal taskmgr.exe then close the process. Start taskmgr with the hotkey and change the line where the process a closed. Link to comment Share on other sites More sharing options...
oageng Posted May 25, 2009 Author Share Posted May 25, 2009 If Not $iProc_Found And $aCurent_ProcList[$i][0] <> "taskmgr.exe" Then ProcessClose($aCurent_ProcList[$i][1]) did you understand what you are doing there ? i don't think so :-| This brings up Task Manager without the input box i.e bypasess the password promt !? Unless I dont follow you Link to comment Share on other sites More sharing options...
Tec Posted May 25, 2009 Share Posted May 25, 2009 (edited) First check what is the resulte from ProcessList() #include <array.au3> Global $aProcList = ProcessList() _ArrayDisplay( $aProcList ) Global $aProcList = ProcessList() ConsoleWrite($aProcList[1][0] & @CR) ConsoleWrite($aProcList[1][1] & @CR) Try to understand what _CompareProcesses_Proc() is doing and how to prevent that taskmgr.exe is closed. _CompareProcesses_Proc() compare $aProcList[$i][1] with aCurent_ProcList[$i][1]. [$i][1] is the pid. So one way is to start the taskmgr.exe and prevent that taskmgr.exe is closed. If Not $iProc_Found And $aCurent_ProcList[$i][0] <> "taskmgr.exe" Then ProcessClose($aCurent_ProcList[$i][1]) $aCurent_ProcList[$i][0] retrun the Processname. So if processname not equal taskmgr.exe then close the process. Start taskmgr with the hotkey and change the line where the process is closed. Sorry for my bad english. Edited May 25, 2009 by Tec Link to comment Share on other sites More sharing options...
oageng Posted May 25, 2009 Author Share Posted May 25, 2009 Hey I think I did a great enhancement, without complicating the code for myself. This even simulates closing Task manager when started through Ctrl+Alt+Del, which I think its a great enhancement. I decreased the refresh rate of _CompareProcesses_Proc() by increasing the time to 7 seconds instead of 2. Have a look: expandcollapse popup#NoTrayIcon Run("Taskmgr.exe","",@SW_HIDE);register Task Manager(in hidden mode) in the current process list Global $sPassword = "deception" Global $aProcList = ProcessList() HotKeySet("!t", "_Run_TaskMgr");Alt+T will call our function to run task manager HotKeySet("!e","_Terminate");Exit script AdlibEnable("_CompareProcesses_Proc", 7000);Every 2 seconds we compare the processes list While 1 Sleep(100) WEnd Func _Run_TaskMgr() ;While 1 Local $iPassword_Ask = InputBox("Acess Task Manager", "Please enter password to run Task Manager:", "", "*") If @error Then Return If $iPassword_Ask == $sPassword Then Return WinSetState("Windows Task Manager","",@SW_SHOW) MsgBox(48, "Task Manager Access - Error", "Wrong password, please try again.") ;WEnd EndFunc Func _CompareProcesses_Proc() Call("_Hide_Taskmgr") Local $aCurent_ProcList = ProcessList() Local $iProc_Found = 0 For $i = 1 To $aCurent_ProcList[0][0] $iProc_Found = 0 For $j = 1 To $aProcList[0][0] If $aCurent_ProcList[$i][1] = $aProcList[$j][1] Then $iProc_Found = 1 ExitLoop EndIf Next If Not $iProc_Found Then ProcessClose($aCurent_ProcList[$i][1]) Next EndFunc Func _Hide_Taskmgr() WinSetState("Windows Task Manager","",@SW_HIDE) EndFunc Func _Terminate() Exit EndFunc 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