Jump to content

How to prevent internet explorer from stealing focus?


Recommended Posts

Hi,

I am trying to make application to download pages by IE browser using IE.au3 UDF. It is running in background doing _IEAction ($oIE,"invisible") or ( WinSetState( Microsoft Internet Explorer", "", @SW_HIDE) but the BIG problem is Internet explorer navigation stole the focus to Active Windows for each page visited. So It is not able to work in other application while running the background application, it is very frustating.

I was looking for information about IE stole focus but in fact I don't find any solution yet.

I appreciate any help about that

Thanks in advance

Eduardo.

Link to comment
Share on other sites

  • 5 months later...

Hi,

I am trying to make application to download pages by IE browser using IE.au3 UDF. It is running in background doing _IEAction ($oIE,"invisible") or ( WinSetState( Microsoft Internet Explorer", "", @SW_HIDE) but the BIG problem is Internet explorer navigation stole the focus to Active Windows for each page visited. So It is not able to work in other application while running the background application, it is very frustating.

I was looking for information about IE stole focus but in fact I don't find any solution yet.

I appreciate any help about that

Thanks in advance

Eduardo.

Could you post what code you have thus far or an example of your code?

A decision is a powerful thing
Link to comment
Share on other sites

Try wrapping your navigate commands inside these undocumented function calls:

__IELockSetForegroundWindow($LSFW_LOCK)

__IELockSetForegroundWindow($LSFW_UNLOCK)

They are used in _IECreate

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

  • 2 weeks later...

Hi everybody and thanks for reply me, I was testing using IELockSetForegroundWindow function and I got a little step forward, the foreground control setting is right in my process space, so in the following test segment, the focus had not stolen by background IE download to windows notepad.

But sadly the setting is not reach global space processes for all applications in windows XP, so changing to another app ALT+TAB then my background IE stole the focus.

#include <IE.au3>

$f_tryAttach = 0

$fvisible = 1

$fwait = 1

;;; Preparing URL search for espacenet server

;;; String TI=hair is looking for patents having word hair in title

$EspaUrl="http://v3.espacenet.com/results?sf=a&FIRST=1&CY=es&LG=es&DB=EPODOC&TI=hair&AB=&PN=&AP=&PR=&PD=&PA=&IN=&EC=&IC=&=&=&=&=&="

; Go for first one.

$oIE = _IECreate ( $EspaUrl,$f_tryAttach,$fvisible,$fwait)

;; Starting notepad

Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

;;; Waiting for search results ....

WinWait ("esp@cenet vista de resultados - " ,"")

;;WinSetState("esp@cenet vista de resultados - " , "", @SW_HIDE)

_IEAction ($oIE,"invisible")

_IELoadWait ($oIE)

; Preparing URL for next page navigation.

$nextone = "http://v3.espacenet.com/results?sf=a&CY=es&LG=es&DB=EPODOC&TI=hair&AB=&PN=&AP=&PR=&PD=&PA=&IN=&EC=&IC=&=&=&=&=&=&PGS=30&FIRST=31"

__IELockSetForegroundWindow($LSFW_LOCK)

; Go for the second one.

_IENavigate ($oIE,$nextone)

$CurrWinActive = WinGetTitle("")

__IELockSetForegroundWindow($LSFW_UNLOCK)

MsgBox(0,"Current focus","Focus on " & $CurrWinActive)

_IEQuit ($oIE)

WinClose("Untitled - Notepad", "")

Finally I have to say that seems to me it is a complex issue to application programmers it should solved at operating system level.

Regards,

Eduardo.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...