<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic RE: Getting Window Title by PID in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/Getting-Window-Title-by-PID/m-p/58312#M12174</link>
    <description>Hi &lt;a href="https://community.blueprism.com/t5/user/viewprofilepage/user-id/1155"&gt;@HongJooChoi&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;You can get it with this line of code: &lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE&gt;title = Process.GetProcessById(3016).MainWindowTitle;&lt;/CODE&gt;&lt;/PRE&gt;
​&lt;BR /&gt;&lt;BR /&gt;In one VBO, you need to add this name space "System.Diagnostics" and change the language to C#&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps you!&lt;BR /&gt;&lt;BR /&gt;See you in the Community, bye &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Pablo Sarabia&lt;BR /&gt;Solution Manager &amp;amp; Architect&lt;BR /&gt;Altamira Assets Management&lt;BR /&gt;Madrid&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
    <pubDate>Fri, 15 Jul 2022 10:38:00 GMT</pubDate>
    <dc:creator>PabloSarabia</dc:creator>
    <dc:date>2022-07-15T10:38:00Z</dc:date>
    <item>
      <title>Getting Window Title by PID</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Getting-Window-Title-by-PID/m-p/58310#M12172</link>
      <description>Hi, Community.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Is there any way to find the Window Title by the PID?&lt;BR /&gt;&lt;BR /&gt;The right Window Title is already known and &lt;BR /&gt;what I want to do is to find the right PID from the list (as shown below) by looping through the list of PID and comparing Window Title for each.&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="20739.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/20885iED5B527B5797E42B/image-size/large?v=v2&amp;amp;px=999" role="button" title="20739.png" alt="20739.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;HongJoo Choi&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Jul 2022 09:19:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Getting-Window-Title-by-PID/m-p/58310#M12172</guid>
      <dc:creator>HongJooChoi</dc:creator>
      <dc:date>2022-07-15T09:19:00Z</dc:date>
    </item>
    <item>
      <title>RE: Getting Window Title by PID</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Getting-Window-Title-by-PID/m-p/58311#M12173</link>
      <description>Hi HongJoo,&lt;BR /&gt;&lt;BR /&gt;Utility - General available on DX can be used for this.&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Shashank Kumar&lt;BR /&gt;DX Integrations Partner Consultant&lt;BR /&gt;Blue Prism&lt;BR /&gt;Singapore&lt;BR /&gt;+6581326707&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Jul 2022 10:18:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Getting-Window-Title-by-PID/m-p/58311#M12173</guid>
      <dc:creator>shashank.kumar280</dc:creator>
      <dc:date>2022-07-15T10:18:00Z</dc:date>
    </item>
    <item>
      <title>RE: Getting Window Title by PID</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Getting-Window-Title-by-PID/m-p/58312#M12174</link>
      <description>Hi &lt;a href="https://community.blueprism.com/t5/user/viewprofilepage/user-id/1155"&gt;@HongJooChoi&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;You can get it with this line of code: &lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE&gt;title = Process.GetProcessById(3016).MainWindowTitle;&lt;/CODE&gt;&lt;/PRE&gt;
​&lt;BR /&gt;&lt;BR /&gt;In one VBO, you need to add this name space "System.Diagnostics" and change the language to C#&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps you!&lt;BR /&gt;&lt;BR /&gt;See you in the Community, bye &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Pablo Sarabia&lt;BR /&gt;Solution Manager &amp;amp; Architect&lt;BR /&gt;Altamira Assets Management&lt;BR /&gt;Madrid&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Jul 2022 10:38:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Getting-Window-Title-by-PID/m-p/58312#M12174</guid>
      <dc:creator>PabloSarabia</dc:creator>
      <dc:date>2022-07-15T10:38:00Z</dc:date>
    </item>
    <item>
      <title>RE: Getting Window Title by PID</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Getting-Window-Title-by-PID/m-p/58313#M12175</link>
      <description>Hi HongJoo,&lt;BR /&gt;&lt;BR /&gt;I agree with Shashank - using the Utility - General is probably your best bet here.&amp;nbsp; There is an action in that utility called Read Memory Stats which accepts an input collection of [Process Names]. That collection needs to have 2 data points in it, both of type text, named Process Name and PID.&amp;nbsp; If you put the process name of msedge in your initial values and leave the PID blank, then run the action, it will return a collection (default name [Process Statistics]) that includes the Process Name, PID, Working Set and Virtual Memory.&amp;nbsp; You can ignore the pieces you don't need and then loop through the [Process Statistics.PID] data point to attach via PID, check for some element you need, then either proceed or detach and loop through until you get to the right one.&lt;BR /&gt;&lt;BR /&gt;One note with this action call is that it will always also return the Idle process with the PID of 0.&amp;nbsp; I recommend at the top of your loop through the PIDs you include a decision to check if [Process Statistics.PID]=0 and just jump to the end of the loop if so.&lt;BR /&gt;&lt;BR /&gt;I hope this explanation helps. I've used this action a lot when I have similar things where multiple processes are spawned with the same name, so I also have some sample code I can screenshot over to you if needed.&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Diane Sanzone&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Jul 2022 12:32:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Getting-Window-Title-by-PID/m-p/58313#M12175</guid>
      <dc:creator>diane.sanzone</dc:creator>
      <dc:date>2022-07-15T12:32:00Z</dc:date>
    </item>
    <item>
      <title>RE: Getting Window Title by PID</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Getting-Window-Title-by-PID/m-p/58314#M12176</link>
      <description>&lt;P&gt;Hi &lt;A class="user-content-mention" data-sign="@" data-contactkey="cd8d2ab4-dea2-479d-9daa-5603a7212f2f" data-tag-text="@Diane Sanzone" href="https://community.blueprism.com/network/profile?UserKey=cd8d2ab4-dea2-479d-9daa-5603a7212f2f" data-itemmentionkey="431eec36-01ba-4b51-81e4-6f81a167e767"&gt;@Diane Sanzone&lt;/A&gt;&amp;nbsp; The opened tabs are only two but in Process Statistics collection there are many rows with PID, Please help me to understand it better. How can I attach to a dynamic window title using this PID feature.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;sivaranjani singaravel&lt;BR /&gt;Assistance Software Engineer&lt;BR /&gt;accenture&lt;BR /&gt;Asia/Kolkata&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Wed, 01 Mar 2023 01:53:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Getting-Window-Title-by-PID/m-p/58314#M12176</guid>
      <dc:creator>sivaranjani_96</dc:creator>
      <dc:date>2023-03-01T01:53:00Z</dc:date>
    </item>
    <item>
      <title>RE: Getting Window Title by PID</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Getting-Window-Title-by-PID/m-p/58315#M12177</link>
      <description>&lt;P&gt;Hi Sivaranjani,&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I'll admit I don't understand why, but when you open an Edge or Chrome window it will spawn multiple processes on your machine (as is visible through the details tab of task manager).&amp;nbsp; Each additional tab in the browser will spawn multiple new processes, and I don't &lt;EM&gt;think &lt;/EM&gt;there's any ratio for it.&amp;nbsp; In my experience, you don't need to know which processes go with each tab.&amp;nbsp; For BP purposes you can just loop through each ID and see if it's the right one by checking for a valid element.&amp;nbsp; It's hard to explain, so I'll attempt to describe the logic flow.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Assuming you know the window title, you can do this pretty easily with a loop around your attach stage:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Utility - General - Read Memory Stats. &amp;nbsp;
&lt;OL&gt;
&lt;LI&gt;Inputs- C&lt;SPAN&gt;ollection named Process Names. That collection needs to have 2 data points in it, both of type text, named Process Name and PID.&amp;nbsp; You won't have the PID for the input, but you should have the process name (msedge, chrome, etc.) This is going to be a single row collection with an initial value of whichever browser you're using&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Outputs - collection (default name [Process Statistics]) that includes the Process Name, PID, Working Set and Virtual Memory.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Loop through the [Process Statistics] collection&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Inside the loop, have an attach stage where your inputs to the attach are (at minimum)&lt;/SPAN&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN&gt;PID - [Process Statistics.PID]&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Window Title - {your known window title here}&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Put a block around the attach stage to recover any exception (mismatch of PID to window title is expected). Resume and direct back to the end of the loop.&amp;nbsp; If the attach action completes, direct to the calculation for attached = true and then end the page (you're attached to the correct window)&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;If you want to further confirm you have the right one before ending, you can also add a wait stage for a known element after the attach is successful and before directing to the calculation stage. This adds minimal processing time but lots of stability.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;One thing to note - one of the records returned in the Process Statistics collection will have a PID of 0.&amp;nbsp; You should add logic to skip that process. It's the "idle" process and doesn't correspond to any browser window.&amp;nbsp; There are many ways to do that (filter the collection for anything where PID &amp;lt;&amp;gt; 0 to start, check the PID before attempting attach, etc.).&amp;nbsp; It's up to you how to best complete that part.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I hope this helps clarify.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Diane Sanzone&lt;BR /&gt;------------------------------&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 13:33:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Getting-Window-Title-by-PID/m-p/58315#M12177</guid>
      <dc:creator>diane.sanzone</dc:creator>
      <dc:date>2023-03-01T13:33:00Z</dc:date>
    </item>
  </channel>
</rss>

