Jump to content

Recommended Posts

Posted

Hello everyone,

before posting this one I spent 2 hours searching the web for an answer, so I apologize if some obscure post exists about this topic.

I'm trying to get the PID of a Microsoft Edge window/website (any site would do as an example, take wikipedia for example).

 

In this examle I have Edge opened with 2 tabs:

"https://en.wikipedia.org/wiki/Main_Page"

and

"https://support.microsoft.com/en-us"

 

well if I use WinGetProcess("Wikipedia) I get the ApplicationFrameHost.exe PID if Wikipedia tab is active, (the same PID I can see in the task manager details)

whereas I get the "true" Wikipedia window PID if wikipedia is not active(Microsoft support i active instead).

I understand that Microsoft Edge tabs and windows are "behind" the ApplicationFrameHost in windows 10 by now,

 

But How can I get the children PIDS using the window title?

My sample code is as simple as:

#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>


    Local $nm="Wikipedia"
    ;Local $nm="Microsoft"
    Local $r = WinGetProcess($nm)
    $i=0
    msgbox(0,"",$r)

 

The "true" child PID for wikipedia would be 16752 (as per task manager), but I get 8272 which is the ApplicationFrameHost.exe instead.

Here is the screenshot of the task manager, it's in Italian but ok, you get it

image.png.80bc46e6d6080f642bd26fd5c1ab1335.png

 

Posted (edited)

Try this :

#include <Constants.au3>
#include <Array.au3>

MsgBox ($MB_SYSTEMMODAL,"",_GetEdgePID ("Wikipedia"))

Func _GetEdgePID ($sName)
  Local $ar = ProcessList ("MicrosoftEdgeCP.exe")
  Local $aw = WinList($sName)
  Local $iPID, $iIdx
  For $i = 1 to $aw[0][0]
    $iPID = WinGetProcess ($aw[$i][1])
    $iIdx = _ArraySearch($ar,$iPID,1,0,0,0,1,1)
    If $iIdx > 0 Then Return $iPID
  Next
  Return -1
EndFunc

You will have to add error checking in the function...

Edited by Nine

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
  • Recently Browsing   0 members

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