win_optimizer Posted April 7, 2006 Share Posted April 7, 2006 ;=============================================================================== ; ; Description - Returns an integer containing the PID that belongs to a given Process Name. ; Syntax - _ProcessGetPID( $S_NAME ) ; Parameters - $S_NAME - the Name of the Process; example : explorer.exe ; Requirements - None. ; Return Values - Success - PID of the Process Specified ; Failure - Blank string and sets @error ; 1 - Process doesn't exist ; 2 - Error getting process list ; 3 - No processes found ; Author(s) - Win_Optimizer <win_optimizer@yahoo.com> ; ;=============================================================================== Func _ProcessGetPID( $s_NAME ) If Not ProcessExists( $s_NAME ) Then SetError(1) Return '' EndIf Local $a_Processes = ProcessList() If Not @error Then For $i = 1 To $a_Processes[0][0] If $a_Processes[$i][0] = $s_NAME Then Return int($a_Processes[$i][1]) Next EndIf SetError(1) Return '' EndFunc ;==>_ProcessGetPID Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 7, 2006 Moderators Share Posted April 7, 2006 I thought they banned you for that spyware you posted? Anyway... you could shorten probably a tad: If Not ProcessExists('notepad.exe') Then Run('notepad.exe') EndIf MsgBox(0, '', ProcessExists('notepad.exe')) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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