Solved

How do I get process information about IE window

Posted on 2013-05-24
5
2,042 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:dlethe
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

733 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