Sorry about that, here is an example for those that come across this thread in the future.
I also found a problem where the handle wasn't being returned but instead the title of the window.
AutoIt
Example()Func Example(); Run NotepadLocal$iPID=Run("notepad.exe"); Wait 10 seconds for the Notepad window to appear.Local$hNotepad=WinWait("[CLASS:Notepad]","",10); Wait for 2 seconds to display the Notepad window.Sleep(2000); Retrieve the handle using the PID of returned by Run.Local$hWnd=_WinGetByPID($iPID,1)MsgBox(4096,"","_WinGetByPID hWnd: "&$hWnd&@CRLF&"WinWait hWnd: "&$hNotepad); Close the Notepad window using the classname of Notepad.WinClose("[CLASS:Notepad]")EndFunc;==>ExampleFunc_WinGetByPID($iPID,$iArray=1); 0 Will Return 1 Base Array & 1 Will Return The First Window.Local$aError[1]=[0],$aWinList,$sReturnIfIsString($iPID)Then$iPID=ProcessExists($iPID)EndIf$aWinList=WinList()For$A=1To$aWinList[0][0]IfWinGetProcess($aWinList[$A][1])=$iPIDAndBitAND(WinGetState($aWinList[$A][1]),2)ThenIf$iArrayThenReturn$aWinList[$A][1]EndIf$sReturn&=$aWinList[$A][1]&Chr(1)EndIfNextIf$sReturnThenReturnStringSplit(StringTrimRight($sReturn,1),Chr(1))EndIfReturnSetError(1,0,$aError)EndFunc;==>_WinGetByPID