Jump to content

Recommended Posts

Posted

Hi all,

I use websites (intranet) a lot at work, and most cases we have to load pages and enter login details.

The issue that I am facing...when I load up any IE page using _IECreate, the page does load up, but ONLY SOMETIMES stays in background and does not come in front. I have tried several ways to bring this page to front but issue is still there. Here are 3 ways that I have tried...

====================================================

Google is just examples. Cant use work intranet at home.

====================================================

Way 1)

---------------

$oIE = _IECreate("www.google.com")

WinActivate($oIE, "")

Way 2)

---------------

$oIE = _IECreate("www.google.com")

$oIE_title = _IEPropertyGet($oIE, "title")

WinActivate($oIE_title, "")

Way 3) - got desperate

---------------

$oIE = _IECreate("www.google.com")

$oIE_title = _IEPropertyGet($oIE, "title")

Do

WinActivate($oIE_title, "")

Until WinActive($oIE_title, "")

====================================================

Is there another way of doing this. Why I have to do this is because some sites I cannot read id or name and have to use controlsend command. And if these windows stay in background, the logins fail.

PLEASE HELP!!!

Posted (edited)

Hellow!

A suggestion for the usage of _IEGetProperty, you could use "hwnd", instead of "title", this will give you the Window handle, which is much more efficient than the title !!!!

That is odd because by default, _IECreate will bring the created instance into focus automatically, there is a WinActivate in the function.

From my point of view, forcing a WinActivate using the window handle is definitely the best call you can make!!!

but stick it in a loop :

#include <ie.au3>

; Create IE instance
Local $oIE = _IECreate("www.google.com")
Local $hIE

; Force to get window handle
While Not IsHWnd($hIE)
    $hIE = _IEPropertyGet($oIE, "hwnd")
    Sleep(10)
WEnd
ConsoleWrite($hIE & @CRLF)

; Force activation of window
While Not WinActive($hIE)
    WinActivate($hIE)
    Sleep(10)
WEnd

; Bye-bye
Exit

Good luck!!

Edited by hench

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...