Jump to content

[Need help] Getting hwnd using PID?


Recommended Posts

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?

Link to comment
Share on other sites

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?

WinList()

&

WinGetProcess()

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 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 ...
 

Link to comment
Share on other sites

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)
Link to comment
Share on other sites

  • 7 months later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...