James Posted January 23, 2007 Share Posted January 23, 2007 Hey, I am making this for a friend. It's supposed to list processes, and then when he types in a process name and clicks Kill process, it will kill it. I have made this: #include <GUIConstants.au3> $ProcessKiller = GUICreate("ProcessKiller", 529, 208, -1, -1) $ProcessBox = GUICtrlCreateEdit("", 8, 8, 233, 193, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) $ProcessName = GUICtrlCreateInput("", 248, 8, 273, 21, BitOR($ES_RIGHT,$ES_AUTOHSCROLL)) $KillProcessRun = GUICtrlCreateButton("Kill Process", 320, 40, 129, 25, 0) $GetProcessList = GUICtrlCreateButton("Get Running Processes", 320, 72, 129, 25, 0) $InfoBox = GUICtrlCreateInput("ProcessKiller", 248, 176, 273, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY)) GUISetState(@SW_SHOW) While 1 $iKill = GUIGetMsg() Switch $iKill Case $GUI_EVENT_CLOSE Exit Case $GetProcessList $ProcessMe = ProcessList("explorer.exe") GUICtrlSetData($ProcessBox, $ProcessMe) Case $KillProcessRun ProcessClose($ProcessName) If $ProcessName = "" Then MsgBox(16, "Process", "Error reading process") EndIf EndSwitch WEnd It doesn't give any errors? And it doesn't show or close then processes. I tried De-bugging the non-existant, with a MsgBox, it displayed nothing. I am really confused because it doesnt display anything. And when I type in a Process to kill, it doesn't kill it. Thanks Secure Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Xenobiologist Posted January 23, 2007 Share Posted January 23, 2007 Hi, CODEexpandcollapse popupOpt("WinTitleMatchMode", 4) #include <GUIConstants.au3> #include <Process.au3> $GUI = GUICreate("Exit Programm", 233, 251, 192, 125) ;Group $options_G = GUICtrlCreateGroup("Options", 8, 40, 217, 201) ;RadioButton $taskkill_R = GUICtrlCreateRadio("Taskkill", 16, 64, 80, 17) $winClose_R = GUICtrlCreateRadio("WinClose", 16, 88, 80, 17) $winKill_R = GUICtrlCreateRadio("WinKill", 16, 112, 80, 17) $processClose_R = GUICtrlCreateRadio("ProcessClose", 16, 136, 80, 17) $pid_R = GUICtrlCreateRadio("ProcessID", 126, 112, 80, 17) ;Label $status_L = GUICtrlCreateLabel("Ready...", 16, 216, 203, 17, $SS_SUNKEN) $headline_L = GUICtrlCreateLabel("Exit Program", 16, 8, 211, 25) $program_L = GUICtrlCreateLabel("Choose Program", 16, 160, 203, 17, $SS_SUNKEN) ;Button $Go_B = GUICtrlCreateButton("GO", 126, 64, 89, 30) ;ComboBox $processCombo_C = GUICtrlCreateCombo("", 16, 184, 201, 21) GUICtrlSetColor($headline_L, "0xff0000") GUICtrlSetColor($program_L, "0xff0000") GUICtrlSetFont($headline_L, 14, 400, "", "Arial") GUICtrlSetState($processCombo_C, $GUI_FOCUS) GUISetState(@SW_SHOW) GUICtrlSetState($taskkill_R, $GUI_CHECKED) _processCombo() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Go_B If GUICtrlRead($taskkill_R) = $GUI_CHECKED Then _taskkill() If GUICtrlRead($winClose_R) = $GUI_CHECKED Then _winClose() If GUICtrlRead($winKill_R) = $GUI_CHECKED Then _winKill() If GUICtrlRead($processClose_R) = $GUI_CHECKED Then _processClose() If GUICtrlRead($pid_R) = $GUI_CHECKED Then _killByPID() Case $msg = $taskkill_R Or $msg = $processClose_R _processCombo() Case $msg = $winKill_R Or $msg = $winClose_R _winListCombo() Case Else ;;;;;;; EndSelect WEnd Func _taskkill() $rc = _RunDOS("start taskkill /F /IM " & GUICtrlRead($processCombo_C) & " /T") GUICtrlSetData($status_L, "Process " & GUICtrlRead($processCombo_C) & " killed") Sleep(2500) GUICtrlSetData($status_L, "Ready...") EndFunc ;==>_taskkill Func _winClose() If WinExists(GUICtrlRead($processCombo_C)) Then WinClose(GUICtrlRead($processCombo_C)) Else GUICtrlSetData($status_L, "Window doesn't exist") Sleep(2500) GUICtrlSetData($status_L, "Ready...") EndIf EndFunc ;==>_winClose Func _winKill() If WinExists(GUICtrlRead($processCombo_C)) Then WinKill(GUICtrlRead($processCombo_C)) Else GUICtrlSetData($status_L, "Window doesn't exist") Sleep(2500) GUICtrlSetData($status_L, "Ready...") EndIf EndFunc ;==>_winKill Func _processClose() If ProcessExists(GUICtrlRead($processCombo_C)) Then ProcessClose(GUICtrlRead($processCombo_C)) Else GUICtrlSetData($status_L, "Process doesn't exist") Sleep(2500) GUICtrlSetData($status_L, "Ready...") EndIf EndFunc ;==>_processClose Func _killByPID() If _ProcessGetName(GUICtrlRead($processCombo_C)) <> '' Then $rc = _RunDOS("start taskkill /PID " & GUICtrlRead($processCombo_C) & " /T") GUICtrlSetData($status_L, "ProcessID " & GUICtrlRead($processCombo_C) & " - (" & _ProcessGetName(GUICtrlRead($processCombo_C)) & ")" & " killed") Sleep(2500) GUICtrlSetData($status_L, "Ready...") Else GUICtrlSetData($status_L, "ProcessID doesn't exist") Sleep(2500) GUICtrlSetData($status_L, "Ready...") EndIf EndFunc ;==>_killByPID Func _processCombo() Dim $processArray = ProcessList() For $i = 1 To $processArray[0][0] GUICtrlSetData($processCombo_C, $processArray[$i][0]) Next EndFunc ;==>_processCombo Func _winListCombo() Dim $windowArray = WinList() For $i = 1 To $windowArray[0][0] ; Only display visble windows that have a title If $windowArray[$i][0] <> "" Then ;AND IsVisible($var[$i][1]) Then GUICtrlSetData($processCombo_C, $windowArray[$i][0]) EndIf Next EndFunc ;==>_winListCombo So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
James Posted January 23, 2007 Author Share Posted January 23, 2007 That's perfect. Thanks MG, your great! Secure Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Xenobiologist Posted January 23, 2007 Share Posted January 23, 2007 HI, no prpblem. Glad I could help you out once more. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times 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