Solved

How do I get process information about IE window

Posted on 2013-05-24
5
2,101 Views
Last Modified: 2013-06-16
I am using the vb.net code below to find an instance of IE that is displaying a particular URL.

How can I also get the process information? If I could get the process ID then I could find the process. Thanks.

Dim window As SHDocVw.InternetExplorer
SA = CreateObject("Shell.Application")
            Dim windowCount As Integer = SA.windows().count()
            For Each window In SA.windows()
                Dim WindowURL = window.LocationURL
                logmessage("check windowURL = " & WindowURL)
                If InStr(WindowURL, URLToCheck) > 0 Then
                    logleave("IsWebTopPageOpen:success")
                    Return window
                End If
            Next
0
Comment
Question by:Christopher Schene
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 47

Expert Comment

by:David
ID: 39195885
try this
http://powertoe.wordpress.com/2010/11/10/finding-the-thread-pid-that-belongs-to-a-tab-in-ie-8-with-powershell/

Granted it is powershell, but you can always do this from VBS and trap/process the output

But I'm not 100% sure that javascript doesn't allow the same process ID to have more than one window, so this may not even be possible in the first place.
0
 

Author Comment

by:Christopher Schene
ID: 39195900
Thanks but I can't user PS as I am running ie7 on an XP machine.

This is vb.net code, BTW.

I am pretty sure that if I get a window handle that there is a way to get the process id from the window handle....just not sure exactly how
0
 
LVL 4

Expert Comment

by:Tushar_Darwatkar
ID: 39200425
Hello,

Did you tried using "Process Explorer v15.3" to track the process. If no please try installing it from below link ans share your experience.

http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
0
 

Accepted Solution

by:
Christopher Schene earned 0 total points
ID: 39211665
This is the code I used to get the process information from the window handle.  Per my original question I was using vb.net: I needed something programmatic in vb.net. I answered my own question.

'Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, ByRef lpdwProcessId As Long) As Long
    Private Declare Function GetWindowThreadProcessId Lib "user32" _
  (ByVal hwnd As IntPtr, _
    ByRef lpdwProcessId As Long) As Long
    Public Function getProcessFromWindowHandle(ByVal hWnd As Long) As Process

        Dim myProcess As Process = Nothing
        logenter("getProcessIDFromWindowHandle " & hWnd)
        Try
            Dim lngPid As Integer
            Dim lngAccessHwnd As IntPtr = New IntPtr(hWnd)
            GetWindowThreadProcessId(lngAccessHwnd, lngPid)
            ' GetWindowThreadProcessId(lngAccessHwnd, myProcessidPtr)
            myProcess = Process.GetProcessById(lngPid)
        Catch ex As Exception
            logmessage(ex.ToString())
            myProcess = Nothing
        Finally
            logleave("getProcessIDFromWindowHandle")
        End Try
        Return myProcess
    End Function
0
 

Author Closing Comment

by:Christopher Schene
ID: 39251085
Answered my own question
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question