Solved

Visual Basic AppActivate  + ProcessID of Internet Explorer Object

Posted on 2003-11-16
16
1,975 Views
Last Modified: 2013-11-25
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
0
Comment
Question by:mikekwok
  • 7
  • 6
16 Comments
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9761548
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.
0
 

Author Comment

by:mikekwok
ID: 9761690
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.
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9761727
yeah i can do that, but i need to know which internet explorer thingy you want to be sending keystrokes too?
0
 

Author Comment

by:mikekwok
ID: 9761734
yes , just send keystroke.

0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9761739
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?
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9761749
also, where do you want to send the keystroke Enter to?  the address bar?
0
 

Author Comment

by:mikekwok
ID: 9761778
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)
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 3

Expert Comment

by:NBrownoh
ID: 9761785
ok, give me the url to the website your going to that popsup the secure dialog so i can code this for you :)
0
 

Author Comment

by:mikekwok
ID: 9761792
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 .
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9761805
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
0
 

Author Comment

by:mikekwok
ID: 9761834
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.
0
 
LVL 3

Accepted Solution

by:
NBrownoh earned 50 total points
ID: 9761849
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.
0
 

Author Comment

by:mikekwok
ID: 9926502
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.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 10548521
Moderator, my recommended disposition is:

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

Dan Rollins -- EE database cleanup volunteer
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

747 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now