Sign in to follow this  
Followers 0
win_optimizer

_processgetpid Function

2 posts in this topic

;===============================================================================
;
; 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

Share this post


Link to post
Share on other sites



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'))

[center]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.[/center]

Share this post


Link to post
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
Sign in to follow this  
Followers 0