Retrieves the Process ID (PID) associated with a window.
WinGetProcess ( "title" [, "text"] )
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. |
Success: | a process ID (PID). |
Failure: | -1 if the window is not found. |
ProcessList, ProcessWait, ProcessWaitClose
#include <MsgBoxConstants.au3>
Example()
Func Example()
; Run Notepad
Run("notepad.exe")
; Wait 10 seconds for the Notepad window to appear.
Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)
; Retrieve the PID of Notepad using the window handle returned by WinWait.
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 WinWait.
WinClose($hWnd)
EndFunc ;==>Example