vbscript - Bring Internet Explorer Application window to front

后端 未结 3 1415
别那么骄傲
别那么骄傲 2021-01-26 19:24

I have a script where I create an IE window through CreateObject(\"InternetExplorer.Application\"). The problem is, whenever I run this script, it always opens behi

相关标签:
3条回答
  • 2021-01-26 19:31

    You probably have the problem because the title of the IE window is not exactly the title of the page (ie. "Yahoo - Internet Explorer") Therefore you must bring it to the front before you start navigating to the page :

    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True
    CreateObject("WScript.Shell").AppActivate "Internet Explorer"
    ie.Navigate "http://www.yahoo.com/"
    
    0 讨论(0)
  • 2021-01-26 19:32

    I messed around with a bunch of the solutions on the internet but eventually found the easiest one that worked.

    Set objExplorer = CreateObject ("InternetExplorer.Application")
    objExplorer.document.focus()
    
    0 讨论(0)
  • 2021-01-26 19:46

    I found the sequence affects the behavior. Don't make IE visible until after it has finished loading.

    Set ie = CreateObject("InternetExplorer.Application")
    ie.Navigate "http://www.google.com"
    While ie.Busy Or ie.ReadyState <> READYSTATE_COMPLETE
        DoEvents
    Wend
    ie.visible = True 
    DoEvents
    
    0 讨论(0)
提交回复
热议问题