teaterr
发表于 2009-9-18 10:26:41
:face (13):是从注册表提取的吗?
sglcszp
发表于 2009-9-28 12:30:59
好东西我没钱相爱在了
sglcszp
发表于 2009-9-28 12:31:43
#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <File.au3>
;thnx to PsaltyDS' udf..
Opt('GUIOnEventMode', 1)
$Title = "SBA Task Manager"
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate($Title, 633, 447, 193, 125)
$ListView1 = GUICtrlCreateListView("Name|Priority|Path|CPU|MEM|Date|Size", 0, 0, 494, 446)
GUICtrlSendMsg(-1, 0x101E, 0, 70)
GUICtrlSendMsg(-1, 0x101E, 1, 70)
GUICtrlSendMsg(-1, 0x101E, 2, 70)
GUICtrlSendMsg(-1, 0x101E, 3, 70)
GUICtrlSendMsg(-1, 0x101E, 4, 70)
GUICtrlSendMsg(-1, 0x101E, 5, 70)
GUICtrlSendMsg(-1, 0x101E, 6, 70)
GUICtrlSendMsg(-1, 0x101E, 7, 70)
_SetList($ListView1)
$menu = GUICtrlCreateContextMenu($ListView1)
$DelTask = GUICtrlCreateMenuItem('End Task', $menu)
$Copy = GUICtrlCreateMenuItem('Copy', $menu)
GUICtrlSetOnEvent($DelTask, '_EndTask')
GUICtrlSetOnEvent($Copy, '_CopyItem')
$Button1 = GUICtrlCreateButton("End Task", 528, 416, 75, 25, 0)
GUICtrlSetOnEvent(-1, '_EndTask')
$Button2 = GUICtrlCreateButton("Export List", 528, 389, 75, 25, 0)
GUICtrlSetOnEvent(-1, '_ExportList')
GUISetOnEvent($GUI_EVENT_CLOSE, '_exit')
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
_UpdateList($ListView1)
$nMsg = GUIGetMsg()
WEnd
Func _exit()
exit
EndFunc
Func _GetListItems($sList)
$list = GUICtrlGetHandle($sList)
global $sReturn=''
For $i=0 to _GUICtrlListView_GetItemCount($list)
$tlk = _GUICtrlListView_GetItemTextArray($list, $i)
if $sReturn='' then
$sReturn = $tlk&' - '&$tlk&' - '&$tlk&' - '&$tlk&' - '&$tlk&' - '&$tlk&' - '&$tlk
Else
$sReturn &= @CRLF&$tlk&' - '&$tlk&' - '&$tlk&' - '&$tlk&' - '&$tlk&' - '&$tlk&' - '&$tlk
EndIf
Next
return $sReturn
EndFunc
Func _ExportList()
$AllItems = _GetListItems($ListView1)
$file = FileSaveDialog('Save the tasks..', '', 'Text Files (*.txt)|All Files (*.*)')
if $file = '' then Return -1
_FileCreate($file)
if _FileWriteToLine($file, 1, $AllItems, 1) = 1 then
msgbox(32, $Title, 'Succesfully created task file..'&@CRLF&'Path: '&$file)
Else
msgbox(16, $Title, 'Error creating task file..'&@CRLF&'Path: '&$file)
EndIf
EndFunc
Func _EndTask()
$1 = StringSplit(GUICtrlRead(GUICtrlRead($ListView1)), '|', 1)
ProcessClose($1)
EndFunc
Func _CopyItem()
ClipPut(GUICtrlRead(GUICtrlRead($ListView1)))
EndFunc
Func _SetList($sList)
$process = _ProcessListProperties()
for $i = 1 to $process
GUICtrlCreateListViewItem($process[$i]&'|'&_GetPriority($process[$i])&'|'&$process[$i]&'|'&$process[$i]&'|'&$process[$i]&'|'&$process[$i]&'|'&FileGetSize($process[$i]), $sList)
Next
EndFunc
Func _UpdateList($sList)
$process = _ProcessListProperties()
for $i = 1 to $process
GUICtrLSetData($i+3, $process[$i]&'|'&_GetPriority($process[$i])&'|'&$process[$i]&'|'&$process[$i]&'|'&$process[$i]&'|'&$process[$i]&'|'&FileGetSize($process[$i]))
Next
EndFunc
Func _GetPriority($process)
return $process
EndFunc
;===============================================================================
; Function Name: _ProcessListProperties()
; Description: Get various properties of a process, or all processes
; Call With: _ProcessListProperties( [$Process [, $sComputer]] )
; Parameter(s): (optional) $Process - PID or name of a process, default is "" (all)
; (optional) $sComputer - remote computer to get list from, default is local
; Requirement(s): AutoIt v3.2.4.9+
; Return Value(s):On Success - Returns a 2D array of processes, as in ProcessList()
; with additional columns added:
; - Number of processes listed (can be 0 if no matches found)
; - 1st process name
; - 1st process PID
; - 1st process Parent PID
; - 1st process owner
; - 1st process priority (0 = low, 31 = high)
; - 1st process executable path
; - 1st process CPU usage
; - 1st process memory usage
; - 1st process creation date/time = "MM/DD/YYY hh:mm:ss" (hh = 00 to 23)
; - 1st process command line string
; ...
; thru - last process properties
; On Failure: Returns array with = 0 and sets @Error to non-zero (see code below)
; Author(s): PsaltyDS at http://www.autoitscript.com/forum
; Date/Version: 07/02/2008--v2.0.2
; Notes: If an integer PID or string process name is provided and no match is found,
; then = 0 and @error = 0 (not treated as an error, same as ProcessList)
; This function requires admin permissions to the target computer.
; All properties come from the Win32_Process class in WMI.
; To get time-base properties (CPU and Memory usage), a 100ms SWbemRefresher is used.
;===============================================================================
Func _ProcessListProperties($Process = "", $sComputer = ".")
Local $sUserName, $sMsg, $sUserDomain, $avProcs, $dtmDate
Local $avProcs = [], $n = 1
; Convert PID if passed as string
If StringIsInt($Process) Then $Process = Int($Process)
; Connect to WMI and get process objects
$oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\" & $sComputer & "\root\cimv2")
If IsObj($oWMI) Then
; Get collection processes from Win32_Process
If $Process = "" Then
; Get all
$colProcs = $oWMI.ExecQuery("select * from win32_process")
ElseIf IsInt($Process) Then
; Get by PID
$colProcs = $oWMI.ExecQuery("select * from win32_process where ProcessId = " & $Process)
Else
; Get by Name
$colProcs = $oWMI.ExecQuery("select * from win32_process where Name = '" & $Process & "'")
EndIf
If IsObj($colProcs) Then
; Return for no matches
If $colProcs.count = 0 Then Return $avProcs
; Size the array
ReDim $avProcs[$colProcs.count + 1]
$avProcs = UBound($avProcs) - 1
; For each process...
For $oProc In $colProcs
; = Process name
$avProcs[$n] = $oProc.name
; = Process PID
$avProcs[$n] = $oProc.ProcessId
; = Parent PID
$avProcs[$n] = $oProc.ParentProcessId
; = Owner
;If $oProc.GetOwner($sUserName, $sUserDomain) = 0 Then $avProcs[$n] = $sUserDomain & "\" & $sUserName
; = Priority
$avProcs[$n] = $oProc.Priority
; = Executable path
$avProcs[$n] = $oProc.ExecutablePath
; = Creation date/time
$dtmDate = $oProc.CreationDate
If $dtmDate <> "" Then
; Back referencing RegExp pattern from weaponx
Local $sRegExpPatt = "\A(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(?:.*)"
$dtmDate = StringRegExpReplace($dtmDate, $sRegExpPatt, "$2/$3/$1 $4:$5:$6")
EndIf
$avProcs[$n] = $dtmDate
; = Command line string
$avProcs[$n] = $oProc.CommandLine
; increment index
$n += 1
Next
Else
SetError(2); Error getting process collection from WMI
EndIf
; release the collection object
$colProcs = 0
; Get collection of all processes from Win32_PerfFormattedData_PerfProc_Process
; Have to use an SWbemRefresher to pull the collection, or all Perf data will be zeros
Local $oRefresher = ObjCreate("WbemScripting.SWbemRefresher")
$colProcs = $oRefresher.AddEnum($oWMI, "Win32_PerfFormattedData_PerfProc_Process" ).objectSet
$oRefresher.Refresh
; Time delay before calling refresher
Local $iTime = TimerInit()
Do
Sleep(20)
Until TimerDiff($iTime) >= 100
$oRefresher.Refresh
; Get PerfProc data
For $oProc In $colProcs
; Find it in the array
For $n = 1 To $avProcs
If $avProcs[$n] = $oProc.IDProcess Then
; = CPU usage
$avProcs[$n] = $oProc.PercentProcessorTime
; = memory usage
$avProcs[$n] = $oProc.WorkingSet
ExitLoop
EndIf
Next
Next
Else
SetError(1); Error connecting to WMI
EndIf
; Return array
Return $avProcs
EndFunc;==>_ProcessListProperties
sglcszp
发表于 2009-9-29 12:45:01
有用吗。看看线
sglcszp
发表于 2009-9-29 12:49:25
记得舍友也写过这样个东西,感觉代码挺简单的。。
De调浪漫
发表于 2009-9-29 14:22:49
LZ可不可以共享下源码
幸运1252
发表于 2009-9-29 19:55:59
好东西,笑纳了。谢谢
幸运1252
发表于 2009-9-29 19:56:50
不知会不会被卡巴杀了
zx45362501
发表于 2009-9-29 22:16:59
谢谢分享源码
gto250
发表于 2009-10-1 17:14:33
哈哈,我知道怎么实现的!
之前有个安全管理的udf通过那个就可以编写得到计算机密码的代码
http://lwc.nhome.cn/code/showip.asp
terse
发表于 2009-10-2 19:49:06
没有源码,楼主公布源码吧 另用第三方吗
zx45362501
发表于 2009-10-7 20:28:40
支持分享!!!!!
SXWG38
发表于 2009-10-15 14:41:54
好用吗?:face (13):
SXWG38
发表于 2009-10-15 14:46:35
怎么用啊?打开什么都看不见。
别情
发表于 2009-10-26 08:41:00
哈哈哈,看看不错的