Jump to content

Task Manager


Recommended Posts

hey guys i missed you all :) as usual i have a question :) i am working now to Task Manager the question is there a

function that change what the button will do if pressed NOT Case $msg = $button1

$bla bla = run("bla bla")

i want after clicking on a button the function of another button change

SORRY FOR My bad english and my VERY VERY Stubid question :P

1 £0\\/3 |-|3® $0 |\\/|µ(|-|

Link to comment
Share on other sites

Sorry, I don't quite understand your question, but this should help you out a bit with writing a task manager. I never finished it, feel free to use it...

[autoit]#include <GUIConstants.au3>

#include <GUIListView.au3>

#include <process.au3>

#include "CPU.au3"

Dim $ShowHidden = 0, $CurrentHandles[100], $edit = 0, $edit_2 = 0

Opt("WinTitleMatchMode", 3)

Opt("TrayMenuMode", 1)

$GUI = GUICreate("Total Task Manager 2.0", 450, 400)

WinSetOnTop("Total Task Manager 2.0", "", 1) ; Give TTM 'On Top' attribute

GUISetIcon("ttm.ico")

TraySetIcon("ttm.ico")

TraySetToolTip("Total Task Manager 2.0")

$FileMenu = GUICtrlCreateMenu("File")

$MenuOverride = GUICtrlCreateMenuitem("Override Task Manager", $FileMenu)

GUICtrlCreateMenuitem("", $FileMenu)

$MenuExit = GUICtrlCreateMenuitem("Exit", $FileMenu)

$ShutdownMenu = GUICtrlCreateMenu("Shutdown")

$ShutdownMenuitem = GUICtrlCreateMenuitem("Shutdown", $ShutdownMenu)

$RebootMenuitem = GUICtrlCreateMenuitem("Reboot", $ShutdownMenu)

$LogoffMenuitem = GUICtrlCreateMenuitem("Logoff", $ShutdownMenu)

GUICtrlCreateMenuitem("", $ShutdownMenu)

$PowerMenuitem = GUICtrlCreateMenuitem("Power down", $ShutdownMenu)

$tab = GUICtrlCreateTab(5, 0, 440, 355)

$WindowTab = GUICtrlCreateTabItem("Windows")

$WindowListView = GUICtrlCreateListView("Window name |Handle |X |Y |Width|Height", 15, 40, 420, 280, BitOr($LVS_ICON, $LVS_SINGLESEL))

Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount($WindowListView)]

_GUICtrlListViewSort($WindowListView, $B_DESCENDING, GUICtrlGetState($WindowListView))

$WindowContext = GUICtrlCreateContextMenu($WindowListView)

$WindowClose = GUICtrlCreateMenuitem("Close", $WindowContext)

$WindowFlash = GUICtrlCreateMenuitem("Flash", $WindowContext)

$WindowSetState = GUICtrlCreateMenu("Set window state", $WindowContext)

$LockWindow = GUICtrlCreateMenuitem("Lock", $WindowSetState)

$UnlockWindow = GUICtrlCreateMenuitem("Unlock", $WindowSetState)

GUICtrlCreateMenuitem("", $WindowSetState)

$ShowWindow = GUICtrlCreateMenuitem("Show", $WindowSetState)

$HideWindow = GUICtrlCreateMenuitem("Hide", $WindowSetState)

GUICtrlCreateMenuitem("", $WindowSetState)

$MinimizeWindow = GUICtrlCreateMenuitem("Minimize", $WindowSetState)

$MaximizeWindow = GUICtrlCreateMenuitem("Maximize", $WindowSetState)

$RestoreWindow = GUICtrlCreateMenuitem("Restore", $WindowSetState)

$WindowCopy = GUICtrlCreateMenu("Copy", $WindowContext)

$WindowCopyName = GUICtrlCreateMenuitem("Window Name", $WindowCopy)

$WindowCopyHandle = GUICtrlCreateMenuitem("Window Handle", $WindowCopy)

$WindowCopySize = GUICtrlCreateMenu("Window Size", $WindowCopy)

$WindowCopyWidth = GUICtrlCreateMenuitem("Width", $WindowCopySize)

$WindowCopyHeight = GUICtrlCreateMenuitem("Height", $WindowCopySize)

$WindowCopyPos = GUICtrlCreateMenu("Window Position", $WindowCopy)

$WindowCopyXPos = GUICtrlCreateMenuitem("X", $WindowCopyPos)

$WindowCopyYPos = GUICtrlCreateMenuitem("Y", $WindowCopyPos)

$WindowCopyLocation = GUICtrlCreateMenuitem("Location", $WindowCopy)

GUICtrlCreateMenuitem("", $WindowContext)

$WindowMutate = GUICtrlCreateMenuitem("Mutate", $WindowContext)

$WindowLocate = GUICtrlCreateMenuitem("Locate", $WindowContext)

$ShowHiddenWindowsCheckbox = GUICtrlCreateCheckbox("Show hidden windows", 15, 325, 130, 23)

$WindowRefreshButton = GUICtrlCreateButton("Refresh", 245, 325, 80, 23)

$NewWindowButton = GUICtrlCreateButton("New task (Run)", 330, 325, 85, 23)

_WinList()

$ProcessTab = GUICtrlCreateTabItem("Processes")

$ProcessListView = GUICtrlCreateListView("Process name |PID |Priority |Process location", 15, 40, 420, 280, BitOr($LVS_ICON, $LVS_SINGLESEL))

$ProcessContext = GUICtrlCreateContextMenu($ProcessListView)

$EndProcess = GUICtrlCreateMenuitem("End process", $ProcessContext)

$ProcessPriority = GUICtrlCreateMenu("Priority", $ProcessContext)

$LowPriority = GUICtrlCreateMenuitem("Low/Idle", $ProcessPriority)

$BelowNormalPriority = GUICtrlCreateMenuitem("Below Normal", $ProcessPriority)

$NormalPriority = GUICtrlCreateMenuitem("Normal", $ProcessPriority)

$AboveNormalPriority = GUICtrlCreateMenuitem("Above Normal", $ProcessPriority)

$HighPriority = GUICtrlCreateMenuitem("High", $ProcessPriority)

GUICtrlCreateMenuitem("", $ProcessPriority)

$RealtimePriority = GUICtrlCreateMenuitem("Realtime", $ProcessPriority)

$ProcessRefreshButton = GUICtrlCreateButton("Refresh", 245, 325, 80, 23)

$NewWindowButton = GUICtrlCreateButton("New task (Run)", 330, 325, 85, 23)

_ProcessList()

$PerfTab = GUICtrlCreateTabItem("Performance")

GUICtrlCreateGroup("CPU Usage", 15, 40, 75, 120)

$CPUProgress = GUICtrlCreateProgress(30, 60, 45, 70, BitOR($PBS_SMOOTH, $PBS_VERTICAL))

GUICtrlSetBkColor(-1, 0x000000)

GUICtrlSetColor(-1, 0x00FF00)

GUICtrlSetData(-1, 50)

$CPULabel1 = GUICtrlCreateLabel("50%", 42, 138, 40, 20)

GUICtrlCreateGroup("RAM Usage", 15, 170, 75, 120)

$RAMProgress = GUICtrlCreateProgress(30, 190, 45, 70, BitOR($PBS_SMOOTH, $PBS_VERTICAL))

GUICtrlSetBkColor(-1, 0x000000)

GUICtrlSetColor(-1, 0x00FF00)

GUICtrlSetData(-1, 50)

$RAMLabel = GUICtrlCreateLabel("50%", 42, 268, 40, 20)

GUICtrlCreateGroup("CPU Usage History", 100, 40, 160, 120)

GUICtrlCreateGroup("PF Usage History", 270, 40, 160, 120)

$CleanRAM = GUICtrlCreateButton("Clean RAM", 15, 296, 75, 22)

$DefragRAM = GUICtrlCreateButton("Defrag RAM", 15, 325, 75, 22)

$TweaksTab = GUICtrlCreateTabItem("Tweaks")

GUICtrlCreateLabel("This feature allows you to make small changes to your Windows interface", 20, 28)

$serial = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProductId")

GUICtrlCreateLabel("Windows Product ID:", 20, 43 )

$input1 = GUICtrlCreateInput($serial, 20, 57, 180 )

GUICtrlSetBkColor($input1, 0x000084)

GUICtrlSetState($input1, $GUI_DISABLE)

GUICtrlSetColor($input1, 0xFFFFFF)

$copy1 = GUICtrlCreateButton("Copy", 205, 56, 50, 22)

$edit1 = GUICtrlCreateButton("Edit", 260, 56, 50, 22)

GUICtrlCreateLabel("Drive Labels:", 20, 80 )

$DriveLetter = "C:\"

$input2 = GUICtrlCreateInput(DriveGetLabel($DriveLetter), 20, 95, 180 )

GUICtrlSetLimit($input2, 11)

GUICtrlSetBkColor($input2, 0x000084)

GUICtrlSetColor($input2, 0xFFFFFF)

GUICtrlSetState($input2, $GUI_DISABLE)

$drive = GUICtrlCreateList("", 205, 96, 50, 22)

GUICtrlSetData($drive, "A:\|B:\|C:\|D:\|E:\|F:\|G:\|H:\|I:\|J:\|K:\|L:\|M:\|N:\|O:\|P:\|Q:\|R:\|S:\|T:\|U:\|V:\|W:\|X:\|Y:\|Z:\", "C:\")

GUICtrlSetColor($drive, 0x000084)

$edit2 = GUICtrlCreateButton("Edit", 260, 94, 50, 22)

GUICtrlCreateLabel("Your system dir is: " & @SystemDir & "\", 20, 120 )

GUICtrlCreateLabel("Your temp dir is: " & @TempDir & "\", 20, 135 )

GUICtrlCreateLabel("Your Windows build is: " & @OSBuild, 20, 150 )

GUICtrlCreateLabel("Your computer is called: " & @ComputerName, 20, 165 )

GUICtrlCreateLabel("Your IP Address is: " & @IPAddress1, 20, 180 )

GUICtrlCreateLabel("Your screen size is: " & @Desktopwidth & "x" & @DesktopHeight, 20, 195 )

GUICtrlCreateLabel(" Depth: " & @DesktopDepth & " bit", 20, 210 )

GUICtrlCreateLabel("Your OS info is: " & @OSVersion & " " & @OSServicePack, 20, 225 )

$admin = ""

If IsAdmin() <> 1 Then $admin = "do not "

GUICtrlCreateLabel("You " & $admin & "have admin privileges", 20, 240)

GUICtrlCreateLabel("Of " & Round(DriveSpaceTotal("C:\")/1000, 2) & "GB, your C:\ drive is " & _

Round(DriveSpaceTotal("C:\")/1000-DriveSpaceFree("C:\")/1000, 2) & _

"GB full", 20, 255)

$OptionsTab = GUICtrlCreateTabItem("Options")

GUICtrlCreateLabel("Total Task Manager options:", 20, 30, 150, 17)

$ReplaceTaskManagerCheckbox = GUICtrlCreateCheckbox("Replace Task Manager", 20, 50, 250, 18)

GUICtrlSetState(-1, $GUI_CHECKED)

GUICtrlCreateLabel("Opens when Ctrl+Alt+Del is pressed", 50, 70)

$DisplaySplashCheckbox = GUICtrlCreateCheckbox("Display splash on exit", 20, 85, 250, 18)

GUICtrlSetState(-1, $GUI_CHECKED)

GUICtrlCreateLabel("Display a quick MSI logo when closed", 50, 105)

$AlwaysOnTopCheckbox = GUICtrlCreateCheckbox("Always on top", 20, 120, 250, 18)

GUICtrlSetState(-1, $GUI_CHECKED)

GUICtrlCreateLabel("TTM remains above all other windows", 50, 140)

$ShowIconCheckbox = GUICtrlCreateCheckbox("Show the TTM icon", 20, 155, 250, 18)

GUICtrlSetState(-1, $GUI_CHECKED)

GUICtrlCreateLabel("The TTM icon appears in the tray", 50, 175)

$StartupCheckbox = GUICtrlCreateCheckbox("Run TTM on startup", 20, 190, 250, 18)

GUICtrlCreateLabel("TTM will run when you turn your computer on", 50, 210)

GUICtrlCreateTabItem("")

$ProcessLabel = GUICtrlCreateLabel(" processes", 5, 360, 120, 18, $SS_SUNKEN)

$CPULabel2 = GUICtrlCreateLabel(" CPU usage: %", 128, 360, 125, 18, $SS_SUNKEN)

$TTMLabel = GUICtrlCreateLabel("Total Task Manager 2.0", 256, 360, 189, 18, BitOr($SS_SUNKEN, $SS_CENTER))

adlib()

AdlibEnable("adlib", 2175)

GUISetState()

While 1

$msg = GUIGetMsg()

sleep(15)

If $msg = $GUI_EVENT_CLOSE or $msg = $MenuExit Then _exit()

; Top menu

If $msg = $LogoffMenuitem Then

If MsgBox(0x40124, "Logoff?", "Are you sure you want to logoff?", 9) = 6 Then Shutdown(0)

EndIf

If $msg = $ShutDownMenuitem Then

If MsgBox(0x40124, "Shutdown?", "Are you sure you want to shutdown?", 9) = 6 Then Shutdown(1)

EndIf

If $msg = $RebootMenuitem Then

If MsgBox(0x40124, "Reboot?", "Are you sure you want to reboot?", 9) = 6 Then Shutdown(2)

EndIf

If $msg = $PowerMenuitem Then

If MsgBox(0x40124, "Power down?", "Are you sure you want to power down?", 9) = 6 Then Shutdown(4)

EndIf

; Window context menu

If $msg = $WindowClose Then _WindowClose()

If $msg = $WindowFlash Then _WindowFlash()

If $msg = $LockWindow Then _WindowSetState(@SW_LOCK)

If $msg = $UnlockWindow Then _WindowSetState(@SW_UNLOCK)

If $msg = $ShowWindow Then _WindowSetState(@SW_SHOW)

If $msg = $HideWindow Then _WindowSetState(@SW_HIDE)

If $msg = $MinimizeWindow Then _WindowSetState(@SW_MINIMIZE)

If $msg = $MaximizeWindow Then _WindowSetState(@SW_MAXIMIZE)

If $msg = $RestoreWindow Then _WindowSetState(@SW_RESTORE)

If $msg = $WindowCopyName Then _WindowCopy(1)

If $msg = $WindowCopyHandle Then _WindowCopy(2)

If $msg = $WindowCopyWidth Then _WindowCopy(5)

If $msg = $WindowCopyHeight Then _WindowCopy(6)

If $msg = $WindowCopyXPos Then _WindowCopy(3)

If $msg = $WindowCopyYPos Then _WindowCopy(4)

If $msg = $WindowRefreshButton Then _WinList()

If $msg = $ShowHiddenWindowsCheckbox Then _WinList()

; Process context

If $msg = $ProcessRefreshButton Then _ProcessList()

If $msg = $LowPriority Then _ProcessPriority(0)

If $msg = $BelowNormalPriority Then _ProcessPriority(1)

If $msg = $NormalPriority Then _ProcessPriority(2)

If $msg = $AboveNormalPriority Then _ProcessPriority(3)

If $msg = $HighPriority Then _ProcessPriority(4)

If $msg = $RealtimePriority Then _ProcessPriority(5)

If $msg = $EndProcess Then _EndProcess()

; Perfermance

If $msg = $CleanRAM Then MemoryOptimize()

; Tweaks

if $edit_2 <> 1 Then

if DriveGetType(GUICtrlRead($drive)) <> "" Then

GUICtrlSetData($input2, DriveGetLabel(GUICtrlRead($drive)))

Else

GUICtrlSetData($input2, "Drive not present")

EndIf

EndIf

If $msg = $edit2 and $edit_2 = 0 Then ; Enable edit2

If DriveGetType(GUICtrlRead($drive)) <> "" Then

If DriveGetType(GUICtrlRead($drive)) <> "FIXED" and DriveGetType(GUICtrlRead($drive)) <> "REMOVABLE" Then

WinSetOnTop("Total Task Manager by Ben Perkins", "", 0)

MsgBox(0x1040, "Warning!", "You may not be able to change the label of this drive," & @LF & _

"since it doesn't appear to be a removable or fixed drive.")

EndIf

GUICtrlSetState($input2, $GUI_ENABLE)

GUICtrlSetState($drive, $GUI_DISABLE)

GUICtrlSetData($edit2, "Done")

$edit_2 = 1

EndIf

$msg = ""

EndIf

If $msg = $edit2 and $edit_2 <> 0 Then ; Disable edit2

GUICtrlSetState($input2, $GUI_DISABLE)

GUICtrlSetState($drive, $GUI_ENABLE)

ControlSetText("Total Task Manager by Ben Perkins", "", $edit2, "Edit")

DriveSetLabel(GUICtrlRead($drive), GUICtrlRead($input2))

$edit_2 = 0

GUICtrlSetData($edit2, "Edit")

EndIf

If $msg = $edit1 and $edit = 0 Then ; Enable edit1

GUICtrlSetState($input1, $GUI_ENABLE)

GUICtrlSetData($edit1, "Done")

$edit = 1

$msg = ""

EndIf

If $msg = $edit1 and $edit <> 0 Then ; Disable edit1

GUICtrlSetState($input1, $GUI_DISABLE)

ControlSetText("Total Task Manager by Ben Perkins", "", $edit1, "Edit")

$serial = ControlGetText("","",$input1)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProductId", "REG_SZ", $serial)

$edit = 0

GUICtrlSetData($edit1, "Edit")

EndIf

; Options

If $msg = $AlwaysOnTopCheckbox Then

If GUICtrlRead($AlwaysOnTopCheckbox) = 1 Then

WinSetOnTop("Total Task Manager 2.0", "", 1)

Else

WinSetOnTop("Total Task Manager 2.0", "", 0)

EndIf

EndIf

If $msg = $ShowIconCheckbox Then

If GUICtrlRead($ShowIconCheckbox) = 1 Then

Opt("TrayIconHide", 0)

Else

Opt("TrayIconHide", 1)

EndIf

EndIf

If $msg = $StartupCheckbox Then

If GUICtrlRead($StartupCheckbox) = 1 Then

FileCreateShortcut(@ScriptFullPath, @StartupDir & "\Total Task Manager.lnk")

Else

FileDelete(@StartupDir & "\Total Task Manager.lnk")

EndIf

EndIf

If $msg = $WindowCopyLocation Then

$title = _GUICtrlListViewGetItemTextArray($WindowListView, _GUICtrlListViewGetCurSel($WindowListView))

ClipPut(GetExePathByPid(WinGetProcess($title[1])))

EndIf

If $msg = $WindowLocate Then _WindowLocate()

If GUICtrlRead($ShowHiddenWindowsCheckbox) = 1 Then

$ShowHidden = 1

Else

$ShowHidden = 0

EndIf

WEnd

Func adlib()

; Update stats

$ProcessList = ProcessList()

GUICtrlSetData($ProcessLabel, " " & $ProcessList[0][0] & " processes")

$CPUUsage = _ProcessListCPU("", 0)

GUICtrlSetData($CPULabel2, "CPU usage: " & $CPUUsage[0][1] - 2 & "%")

GUICtrlSetData($CPULabel1, $CPUUsage[0][1] - 2 & "%")

GUICtrlSetData($CPUProgress, $CPUUsage[0][1] - 2)

$MemStats = MemGetStats()

GUICtrlSetData($RAMProgress, $MemStats[0])

GUICtrlSetData($RAMLabel, $MemStats[0] & "%")

EndFunc

Func _ProcessPriority($priority)

If $priority = 5 Then

If MsgBox(0x40004, "Assign realtime command?", "Not all programs accept realtime commands," & @CRLF & "and it may cause undesired results. Continue?") <> 6 Then Return

EndIf

$title = _GUICtrlListViewGetItemTextArray($ProcessListView, _GUICtrlListViewGetCurSel($ProcessListView))

If IsArray($title) Then

ProcessSetPriority($title[1], $priority)

If $priority = 0 Then

$priority = "Low/Idle"

ElseIf $priority = 1 Then

$priority = "Below normal"

ElseIf $priority = 2 Then

$priority = "Normal"

ElseIf $priority = 3 Then

$priority = "Above normal"

ElseIf $priority = 4 Then

$priority = "High"

ElseIf $priority = 5 Then

$priority = "Realtime"

EndIf

_GUICtrlListViewSetItemText($ProcessListView, _GUICtrlListViewGetCurSel($ProcessListView), 2, $priority)

EndIf

EndFunc

Func _EndProcess()

$title = _GUICtrlListViewGetItemTextArray($ProcessListView, _GUICtrlListViewGetCurSel($ProcessListView))

If MsgBox(0x40124, "Close process: " & $title[1], "Closing a process may cause in undesired results." & @CRLF & "Continue?", 8) = 6 Then

If ProcessClose($title[1]) Then _GUICtrlListViewDeleteItemsSelected($ProcessListView)

EndIf

EndFunc

Func _WindowLocate()

$title = _GUICtrlListViewGetItemTextArray($WindowListView, _GUICtrlListViewGetCurSel($WindowListView))

If Not IsArray($title) Then Return

MsgBox(262144, "'" & $title[1] & "' is:", GetExePathByPid(WinGetProcess($title[1])))

EndFunc

Func GetListPathByPid($list)

Dim $var[$list[0][0]]

$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")

For $i = 1 to $list[0][0]-1

$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId = " & $list[$i][1], "WQL", 0x10 + 0x20)

If IsObj($colItems) Then

For $objItem In $colItems

$path = $objItem.ExecutablePath

If $path = "" Then $path = " No valid path supplied"

$var[$i] = $path

Next

EndIf

Next

Return $var

EndFunc

Func GetExePathByPid($pid)

$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")

$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId = " & $pid, "WQL", 0x10 + 0x20)

If IsObj($colItems) Then

For $objItem In $colItems

$path = $objItem.ExecutablePath

If $path = "" Then $path = " No valid path supplied"

Return $path

Next

EndIf

EndFunc

Func _WindowCopy($item)

$title = _GUICtrlListViewGetItemTextArray($WindowListView, _GUICtrlListViewGetCurSel($WindowListView))

If Not IsArray($title) Then Return

$ClipInfo = $title[$item]

ClipPut($ClipInfo)

EndFunc

Func _WindowSetState($state)

$title = _GUICtrlListViewGetItemTextArray($WindowListView, _GUICtrlListViewGetCurSel($WindowListView))

If Not IsArray($title) Then Return

WinSetState($title[1], "", $state)

EndFunc

Func _WindowFlash()

$title = _GUICtrlListViewGetItemTextArray($WindowListView, _GUICtrlListViewGetCurSel($WindowListView))

If Not IsArray($title) Then Return

WinFlash($title[1])

EndFunc

Func _WindowClose()

$title = _GUICtrlListViewGetItemTextArray($WindowListView, _GUICtrlListViewGetCurSel($WindowListView))

If Not IsArray($title) Then Return

If WinClose($title[1]) Then _GUICtrlListViewDeleteItemsSelected($WindowListView)

EndFunc

Func _WinList()

$WindowList = WinList()

_GUICtrlListViewDeleteAllItems($WindowListView)

For $i = 1 to $WindowList[0][0]

If $ShowHidden = 0 Then

$IsVisible = "No"

Else

$IsVisible = "Yes"

EndIf

If $WindowList[$i][0] <> "" and $WindowList[$i][0] <> "Program Manager" Then

If BitAnd( WinGetState($WindowList[$i][0]), 2 ) Then $IsVisible = "Yes"

If $WindowList[$i][0] = "Total Task Manager 2.0" Then $IsVisible = "Yes"

If $IsVisible = "Yes" Then

$WinPos = WinGetPos($WindowList[$i][0])

If IsArray($WinPos) Then GUICtrlCreateListViewItem($WindowList[$i][0] & "|" & $WindowList[$i][1] & "|" & $WinPos[0] & "|" & $WinPos[1] & "|" & $WinPos[2] & "|" & $WinPos[3], $WindowListView)

GUICtrlSetImage(-1, GetExePathByPid(WinGetProcess($WindowList[$i][0])), 0)

EndIf

EndIf

Next

EndFunc

Func _ProcessList()

$ProcessList = ProcessList()

_GUICtrlListViewDeleteAllItems($ProcessListView)

$location = GetListPathByPid(ProcessList())

For $i = 1 to $ProcessList[0][0] - 1

$priority = _ProcessGetPriority($ProcessList[$i][0])

If $priority = 0 Then

$priority = "Low/Idle"

ElseIf $priority = 1 Then

$priority = "Below normal"

ElseIf $priority = 2 Then

$priority = "Normal"

ElseIf $priority = 3 Then

$priority = "Above normal"

ElseIf $priority = 4 Then

$priority = "High"

ElseIf $priority = 5 Then

$priority = "Realtime"

ElseIf $priority = -1 Then

$priority = ""

EndIf

GUICtrlCreateListViewItem($ProcessList[$i][0] & "|" & $ProcessList[$i][1] & "|" & $priority & "|" & $location[$i], $ProcessListView)

If $location[$i] <> " No valid path supplied" Then

GUICtrlSetImage(-1, $location[$i], 0)

Else

GUICtrlSetImage(-1, StringReplace(@ScriptDir & "\" & @ScriptName, ".au3", ".exe"), 1)

EndIf

Next

EndFunc

Func MemoryOptimize() ; Reduces memory usage, I did NOT write the code to the memory optimize!

$memory1 = MemGetStats ( )

Do

ReduceMemory()

$list = ProcessList()

For $i=1 To $list[0][0]

ReduceMemory($list[$i][1])

Next

$memory2 = $memory1

$memory1 = MemGetStats ( )

Until $memory1[2] >= $memory2[2]

EndFunc

Func ReduceMemory($i_PID = -1)

If $i_PID <> -1 Then

Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)

Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])

DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])

Else

Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)

EndIf

Return $ai_Return[0]

EndFunc

Func _exit()

;If GUICtrlRead($ReplaceTaskManagerCheckbox) = 1 Then

;If GUICtrlRead($DisplaySplashCheckbox) = 1 Then

Opt("TrayIconHide", 1)

Exit

EndFunc

Edited by magician13134
Link to comment
Share on other sites

MAn its pretty easy use the first command button to set a value for a variable these values are other script files name wich will execute when u press the othe button wich is linked to execute the script name in the varaible hope u understand

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...