Qvintus 1 Posted June 28, 2011 Hello I was wondering if it's possible to get the hwnd using PID? Currently I found: WinList - Though this requires the window name, wich could be the same for 2 instances in some situations. ProcessList - Can return PID but not hwnd WinGetHandle - Requires window name again Anything I have overlooked for now? Or is ther some sort of bypass somewhere? Basicly I want to finde the hwnd using a ProcessList where 2 windows mostly will have the same name, meaning I can't finde it using the window name. Any ideas? Share this post Link to post Share on other sites
JoHanatCent 13 Posted June 28, 2011 Hello I was wondering if it's possible to get the hwnd using PID?Currently I found:WinList - Though this requires the window name, wich could be the same for 2 instances in some situations.ProcessList - Can return PID but not hwndWinGetHandle - Requires window name againAnything I have overlooked for now? Or is ther some sort of bypass somewhere?Basicly I want to finde the hwnd using a ProcessList where 2 windows mostly will have the same name, meaning I can't finde it using the window name.Any ideas?WinList()&WinGetProcess() Share this post Link to post Share on other sites
Qvintus 1 Posted June 28, 2011 I already know how to get PID, I need to use the PID to somehow get the hwnd. If I can use WinList for that then please explain a little more of what parameter it should be in. Also if I should use "[PID:" & $pid &"]" or something wiered like that? Share this post Link to post Share on other sites
MvGulik 86 Posted June 28, 2011 (edited) WinGetProcess()---To be used on your hwnd's from winlist to see if its the PID your looking for.But, this can return multiple matches, as a process can have multiple windows. so some additional window title information is probably needed to make sure you get the one your after.---See example in next message. Edited June 28, 2011 by iEvKI3gv9Wrkd41u "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)"Believing what you know ain't so" ...Knock Knock ... Share this post Link to post Share on other sites
JoHanatCent 13 Posted June 28, 2011 I already know how to get PID, I need to use the PID to somehow get the hwnd. If I can use WinList for that then please explain a little more of what parameter it should be in. Also if I should use "[PID:" & $pid &"]" or something wiered like that? Just an Example: Global $PID2 = "" $Amow = 100 $hWnd2 = "" $aPID = Run("Notepad.exe") Sleep($Amow) $theWinlist = Winlist() Do For $i = 1 To $theWinlist[0][0] If $theWinlist[$i][0] <> "" Then $iPID2 = WinGetProcess($theWinlist[$i][1]) If $iPID2 = $aPID Then $hWnd2 = $theWinlist[$i][1] ExitLoop EndIf EndIf Next Until $hWnd2 <> 0 MsgBox(0, "Handle is", $hWnd2) WinClose($hWnd2) 1 VenusProject2 reacted to this Share this post Link to post Share on other sites
Qvintus 1 Posted June 28, 2011 (edited) Thx for your replys but I ended out using the WinAPIEx.au3 _WinAPI_EnumProcessWindows(PID) Post I found it in: Edited June 28, 2011 by Qvintus 1 MONaH-Rasta reacted to this Share this post Link to post Share on other sites
Baporing 0 Posted February 12, 2012 Perfect code, JoHanatCent. As long as there is only one exe with that name, it works on everything I tried Share this post Link to post Share on other sites