RAMzor Posted February 9, 2006 Share Posted February 9, 2006 Hello all! How can I get full file name (with path) of running applications (window)? For example, accoording to PID of opened window.... It is possible? :"> Thx! Link to comment Share on other sites More sharing options...
BigDod Posted February 9, 2006 Share Posted February 9, 2006 Hello all! How can I get full file name (with path) of running applications (window)? For example, accoording to PID of opened window.... It is possible? :"> Thx!I found this on the forums Local $List = WinList() Local $Title = "" For $i = 1 To $List[0][0] ;uncomment to show all visible programs ;If $List[$i][0] <> "" And IsVisible($List[$i][1]) Then ;uncomment to show all programs If $List[$i][0] <> "" Then Dim $Process = IDtoName( WinGetProcess($List[$i][0])) $Title &= $Process & @TAB & $List[$i][0] & @CRLF EndIf Next msgbox(0,"",$Title) Func IDtoName($Handle) Dim $ProcList = ProcessList() For $i = 1 To $ProcList[0][0] If $ProcList[$i][1] = $Handle Then Return ($ProcList[$i][0]) EndIf Next EndFunc Func IsVisible($Handle) If BitAND( WinGetState($Handle), 2) Then Return 1 Else Return 0 EndIf EndFunc Not written by me. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
JerryD Posted February 9, 2006 Share Posted February 9, 2006 Hello all! How can I get full file name (with path) of running applications (window)? For example, accoording to PID of opened window.... It is possible? :"> Thx!Here's a function that will return the full PID path: expandcollapse popupMsgBox ( 0, 'This proccess path:', _ProcessIdPath(@AutoItPID) ) ;=============================================================================== ; ; Function Name: _ProcessIdPath () ; Description: Returns the full path of a Process ID ; Parameter ( s ): $vPID - Process ID (String or Integer) ; Requirement ( s ): AutIt 3.1.1 (tested with version 3.1.1.107) ; Return Value ( s ): On Success - Returns the full path of the PID Executeable ; On Failure - returns a blank string ; @ERROR = 1 - Process doesn't exist ( ProcessExist ( $vPID ) =0 ) ; @ERROR = 2 - Path is unknown ; $objItem.ExecutablePath=0 ; AND ; @SystemDir\$objItem.Caption doesn't exist ; @ERROR = 3 - Process Not Found ( in WMI ) ; @ERROR = 4 - WMI Object couldn't be created ; @ERROR = 5 - Unknown Error ; Author: JerryD ; ;=============================================================================== ; Func _ProcessIdPath ( $vPID ) Local $objWMIService, $oColItems Local $sNoExePath = '' Local Const $wbemFlagReturnImmediately = 0x10 Local Const $wbemFlagForwardOnly = 0x20 Local $RetErr_ProcessDoesntExist = 1 Local $RetErr_ProcessPathUnknown = 2 Local $RetErr_ProcessNotFound = 3 Local $RetErr_ObjCreateErr = 4 Local $RetErr_UnknownErr = 5 If Not ProcessExists ( $vPID ) Then SetError ( $RetErr_ProcessDoesntExist ) Return $sNoExePath EndIf $objWMIService = ObjGet ( 'winmgmts:\\localhost\root\CIMV2' ) $oColItems = $objWMIService.ExecQuery ( 'SELECT * FROM Win32_Process', 'WQL', $wbemFlagReturnImmediately + $wbemFlagForwardOnly ) If IsObj ( $oColItems ) Then For $objItem In $oColItems If $vPID = $objItem.ProcessId Then If $objItem.ExecutablePath = '0' Then If FileExists ( @SystemDir & '\' & $objItem.Caption ) Then Return @SystemDir & '\' & $objItem.Caption Else SetError ( $RetErr_ProcessPathUnknown ) Return $sNoExePath EndIf Else Return $objItem.ExecutablePath EndIf EndIf Next SetError ( $RetErr_ProcessNotFound ) Return $sNoExePath Else SetError ( $RetErr_ObjCreateErr ) Return $sNoExePath EndIf SetError ( $RetErr_UnknownErr ) Return $sNoExePath EndFunc ;==>_ProcessIdPath I can't take a lot of credit for this, the bulk of the code was generated by SvenP great port of the MS WMI Scriptomatic tool - Scriptomatic.au3. That said, what I REALLY wanted to do was:Have the function accept either a PID or Process NAMEReturn a two dimensional array element[0][0] contains the number of processes found element[x][0] contains the exepath element[x][1] contains the command line paramaters element[x][3] = PID more?I'm swamped these days, and without the Scriptomatic tool wouldn't have even had the time to put this together! This code, and the code generated by Scriptmatic (Win32_Process.AU3) in case there are any takers! _ProcessIdPath.au3 Win32_Process.AU3 Link to comment Share on other sites More sharing options...
RAMzor Posted February 10, 2006 Author Share Posted February 10, 2006 First of all thanks all of you!all work nice but I have some problem to run code from Larry located hereI have a ERROR: DllStructDelete(): undefined function. DllStructDelete($Process)I use latest version of AutoIt and Beta (v3.1.1.107) Link to comment Share on other sites More sharing options...
BigDod Posted February 10, 2006 Share Posted February 10, 2006 First of all thanks all of you!all work nice but I have some problem to run code from Larry located hereI have a ERROR: DllStructDelete(): undefined function. DllStructDelete($Process)I use latest version of AutoIt and Beta (v3.1.1.107)Replace DlllStructDelete($Process) with $Process=0 you will find it occurs twice in the script. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother 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