RtheBen Posted March 3, 2020 Posted March 3, 2020 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
RtheBen Posted March 3, 2020 Author Posted March 3, 2020 and this is the screenshot for the ApplicationFrameHost.exe PID
Nine Posted March 3, 2020 Posted March 3, 2020 (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 March 3, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Reveal hidden contents Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now