WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with MSIE
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

WindowOnTop Problem With IE9

 Keywords: MSIE IE Internet Explorer InternetExplorer.Application WindowOnTop ParentWindow Focus IE9

Question:

I need to open IE in specific size for a form but without Menu and status bar. Here is the code I am using

oIE = CreateObject("InternetExplorer.Application")
oIE.Navigate2("http://www.winbatch.com")
While oIE.readyState <> 4
      TimeDelay(.5)
EndWhile

oIE.Toolbar = 0
oIE.StatusBar = 0
oIE.Resizable = 1
oIE.Width = 500
oIE.Height = 125
oIE.Left = 250
oIE.Top = 250
oIE.Visible = 1
I have a compiled script that opens an instance of IE, on Windows XP and IE7 or IE8, everything works fine.

Under Win 7 and using IE9, the IE window randomly opens behind the calling application instead of in front of it. I added windowontop(browser.document.title, 1) without any change in behavior.

Any idea what might be causing this?

Answer:

Not sure what is causing that. Maybe try calling the following code to have IE set window focus:
oIE.document.parentwindow.focus
Here is the complete code sample:
oIE = CreateObject("InternetExplorer.Application")
oIE.Navigate2("http://www.winbatch.com")
While oIE.readyState <> 4
      TimeDelay(.5)
EndWhile

oIE.Toolbar = 0
oIE.StatusBar = 0
oIE.Resizable = 1
oIE.Width = 500
oIE.Height = 125
oIE.Left = 250
oIE.Top = 250
oIE.Visible = 1
; Set focus to IE window
oIE.Document.ParentWindow.Focus()

User Reply:

You're the best! We have tested and retested our original code with the same results: IE9 only randomly reacts to windowontop() commands. oIE.Document.ParentWindow.Focus() is doing the job and it seems reliable with IE7, IE8 and IE9. Thank you.
Article ID:   W18134
Filename:   WindowOnTop Problem With IE9.txt
File Created: 2011:04:25:10:37:12
Last Updated: 2011:04:25:10:37:12