FinalVersion Posted February 14, 2010 Share Posted February 14, 2010 expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #RequireAdmin #NoTrayIcon Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown. Local $trayMsg, $showWindow ;Tray stuff $showWindow = TrayCreateItem("Show Window") Local $Processes = ProcessList() $frmMain = GUICreate("Process Management", 381, 433, 255, 122) $lstProcesses = GUICtrlCreateListView("Process Name|Process ID (PID)", 8, 8, 362, 382, BitOR($WS_BORDER, $WS_VSCROLL, $LVS_SINGLESEL, $LVS_SORTASCENDING)) $btnCease = GUICtrlCreateButton("Cease Process", 264, 400, 107, 25, $WS_GROUP) $lblProcesses = GUICtrlCreateLabel("Processes:", 8, 408, 56, 17) $lblCount = GUICtrlCreateLabel($Processes[0][0], 64, 408, 16, 17) GUISetState(@SW_SHOW) For $i = 3 To $Processes[0][0] GUICtrlCreateListViewItem($Processes[$i][0] & "|" & $Processes[$i][1], $lstProcesses) Next _GUICtrlListView_SetColumnWidth($lstProcesses, 0, 233) While 1 If WinGetState("Process Management") = 23 Then ; 23 = 1 + 2 + 4 + 16 - Exists, Visible, Enabled, Minimized GUISetState(@SW_HIDE) Opt("TrayIconHide", 0) EndIf $trayMsg = TrayGetMsg() Select Case $trayMsg = $showWindow GUISetState(@SW_SHOW) WinSetState("Process Management", "", @SW_RESTORE) Opt("TrayIconHide", 1) EndSelect $nMsg = GUIGetMsg() Switch $nMsg Case $btnCease $Sel_Proc = GUICtrlRead(GUICtrlRead($lstProcesses)) $Sel_Proc_Result = StringSplit($Sel_Proc, "|") $Msg = MsgBox(4 + 32, "Close?", "Are you sure you want to close " & $Sel_Proc_Result[1] & "(" & $Sel_Proc_Result[2] & ")?") If $Msg = 6 Then ; Yes $pClose = ProcessClose($Sel_Proc_Result[1]) If @error Then MsgBox(0 + 16, "Error", "Failed to close process!") EndIf ElseIf $Msg = 7 Then ; No Else ; Unknown EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch $wUpdate = ProcessList() GUICtrlSetData($lblCount, $wUpdate[0][0]) If $Processes[0][0] < $wUpdate[0][0] Then Do GUICtrlCreateListViewItem("", $lblProcesses) Until $wUpdate[0][0] = $Processes[0][0] For $t = 0 To $wUpdate[0][0] GUICtrlSetData($lstProcesses, $wUpdate[$t][0] & "|" & $wUpdate[$t][1]) Next EndIf WEnd Basically in the while loop I have it constantly updating, but it isn't working. The label change works, but not my attempt of updating the items. I made the Do loop so there are enough ListView items, anyway thanks. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
andybiochem Posted February 14, 2010 Share Posted February 14, 2010 You had a few errors. 1) use of "If $Processes[0][0] < $wUpdate[0][0] Then" will only trigger an update if new processes start, if you kill them then this condition will never be fulfilled. 2) you can't update listviewitems like that. You either need to put each item's handle in an array and GUICtrlSetData to the array items, OR simply create the listviewitems with the correct data in the first instance, and delete them before updating again. 3) you never update $Processess in the loop, thus the listview update would be triggered over and over and over as soon as something changes (given that item 1 above is corrected) Here is the corrected code: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <Array.au3> #RequireAdmin ;#NoTrayIcon Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown. Local $trayMsg, $showWindow ;Tray stuff $showWindow = TrayCreateItem("Show Window") Local $Processes = ProcessList() $frmMain = GUICreate("Process Management", 381, 433, 255, 122) $lstProcesses = GUICtrlCreateListView("Process Name|Process ID (PID)", 8, 8, 362, 382, BitOR($WS_BORDER, $WS_VSCROLL, $LVS_SINGLESEL, $LVS_SORTASCENDING)) $btnCease = GUICtrlCreateButton("Cease Process", 264, 400, 107, 25, $WS_GROUP) $lblProcesses = GUICtrlCreateLabel("Processes:", 8, 408, 56, 17) $lblCount = GUICtrlCreateLabel($Processes[0][0], 64, 408, 16, 17) GUISetState(@SW_SHOW) For $i = 3 To $Processes[0][0] GUICtrlCreateListViewItem($Processes[$i][0] & "|" & $Processes[$i][1], $lstProcesses) Next _GUICtrlListView_SetColumnWidth($lstProcesses, 0, 233) While 1 If WinGetState("Process Management") = 23 Then ; 23 = 1 + 2 + 4 + 16 - Exists, Visible, Enabled, Minimized GUISetState(@SW_HIDE) Opt("TrayIconHide", 0) EndIf $trayMsg = TrayGetMsg() Select Case $trayMsg = $showWindow GUISetState(@SW_SHOW) WinSetState("Process Management", "", @SW_RESTORE) Opt("TrayIconHide", 1) EndSelect $nMsg = GUIGetMsg() Switch $nMsg Case $btnCease $Sel_Proc = GUICtrlRead(GUICtrlRead($lstProcesses)) $Sel_Proc_Result = StringSplit($Sel_Proc, "|") $Msg = MsgBox(4 + 32, "Close?", "Are you sure you want to close " & $Sel_Proc_Result[1] & "(" & $Sel_Proc_Result[2] & ")?") If $Msg = 6 Then ; Yes $pClose = ProcessClose($Sel_Proc_Result[1]) If @error Then MsgBox(0 + 16, "Error", "Failed to close process!") EndIf ElseIf $Msg = 7 Then ; No Else ; Unknown EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch $wUpdate = ProcessList() If $Processes[0][0] <> $wUpdate[0][0] Then GUICtrlSetData($lblCount, $wUpdate[0][0]) $Processes = $wUpdate _GUICtrlListView_DeleteAllItems($lstProcesses) For $t = 1 To $wUpdate[0][0] GUICtrlCreateListViewItem($wUpdate[$t][0] & "|" & $wUpdate[$t][1],$lstProcesses) Next EndIf WEnd - Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar! Link to comment Share on other sites More sharing options...
FinalVersion Posted February 14, 2010 Author Share Posted February 14, 2010 Thanks. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] 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