Visual Basic AppActivate + ProcessID of Internet Explorer Object

I need to locate an Internet Explorer using AppActivate and then click press Enter. If there are more than 1 Internet Explorers opened, how can I open locate the Internet Explorer ? How can i get the process ID of an Internet Explorer Object ?

 I can just find these references , can anyone tell me more on the solution?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/html/vastmappactivatex.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbCode/html/vbtskCodeStartingApplicationSendingItKeystrokesVisualBasic.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctShell.asp
mikekwokAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NBrownohCommented:
there might be an easier way, what exactly are you trying to do, just view a web site?  there is a control included with VB that allows you to do that, the other way is by using API and youll need to raise the points on that one.
mikekwokAuthor Commented:
I need to press enter when an internet explorer open an dialog. therefore i use appactative + want to get the processid of the internet explorer object . do u know how to do so ?
i want to get the processid of internet explorer object in visual basic.
NBrownohCommented:
yeah i can do that, but i need to know which internet explorer thingy you want to be sending keystrokes too?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

mikekwokAuthor Commented:
yes , just send keystroke.

NBrownohCommented:
yeah, but if there are multiple IE windows open which one will you want, does it have a special caption, or does it not matter, you just want any IE window?
NBrownohCommented:
also, where do you want to send the keystroke Enter to?  the address bar?
mikekwokAuthor Commented:
Internet Explorer will popup a secure dialog and i have to press enter.
i just want to know how can i get the process id of the internet explorer according to the URL so that i can use appactative to get focus to that internet explorer  and then click enter( send Enter keystroke)
NBrownohCommented:
ok, give me the url to the website your going to that popsup the secure dialog so i can code this for you :)
mikekwokAuthor Commented:
it is secure page and need login and password.
 i just want to know how can i get the process id of the ineternet explorer .
NBrownohCommented:
in a form put this:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Dim ieframe As Long
Private Sub Form_Load()
    Dim ieframe As Long, ProcID As Long
    ieframe = FindWindow("ieframe", vbNullString)
    GetWindowThreadProcessId ieframe, ProcID
    'ProcID is now the process ID of an IE window
    'whether or not this is the right IE window?
End Sub
mikekwokAuthor Commented:
I know the URL of the internet explorer. I want to get the process id of that internet explorer.
I don't want to input the title in the findwindow in order to find the process id of the internet explorer , do u know how? Thanks.
NBrownohCommented:
in that code where it says "ieframe" thats the class pointer to find, not the window title.  If you dont want to hard code the title in to find the exact IE window then there really isnt a way unless you want to enumerate all the windows and search for the one that has a matching title, which will be slower.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mikekwokAuthor Commented:
Public Sub click_Security_dialog(Language As String)
    On Error GoTo ErrorHandler
    If Language = "e" Then
        AppActivate "Security Information"
    ElseIf Language = "tc" Then
        AppActivate "安全性資訊"
    End If
    Dim clskey As New clsKeyboard
    Call clskey.PressKeyVK(keyReturn)
    Exit Sub
ErrorHandler:
Wait 1
Resume
End Sub

This code is for pressing dialog when internet explorer open. But it doesn't work when i try to open more than 1 internet explorer using visual basic and in these internet explorers pop up dialogs.

would some body tell me how to solve my problem ?  my program open 2 browsers and 2 pop up dialog and i need to press enter on that. it sometimes work but it sometimes doesn't work using the code above.
DanRollinsCommented:
Moderator, my recommended disposition is:

    Accept NBrownoh's comment(s) as an answer.

Dan Rollins -- EE database cleanup volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.