# Function Reference

# WinGetProcess

Retrieves the Process ID (PID) associated with a window.

WinGetProcess ( "title" [, "text"] )

## Parameters

title | The title/hWnd/class of the window to get the PID. See Title special definition.
text | [optional] The text of the window to get the PID. Default is an empty string. See Text special definition.

## Return Value

Success: | a process ID (PID).
Failure: | -1 if the window is not found.

## Related

ProcessList, ProcessWait, ProcessWaitClose

## Example

    #include <MsgBoxConstants.au3>

    Example()

    Func Example()
        ; Run Notepad
        Run("notepad.exe")

        Local $hWnd = WinWaitActive("[CLASS:Notepad]", "")

        ; Retrieve the PID of Notepad using the window handle returned by WinWaitActive.
        Local $iPID = WinGetProcess($hWnd)

        ; Display the PID of the window.
        MsgBox($MB_SYSTEMMODAL, "", "The PID is: " & $iPID)

        ; Close the Notepad window using the handle returned by WinWaitActive.
        WinClose($hWnd)
    EndFunc   ;==>Example