Sign in to follow this  
Followers 0
MonsieurOUXX

How to prevent IE from getting the focus?

6 posts in this topic

#1 ·  Posted (edited)

Suppose you create an IE using the special function _IECreate2 found here :

It has to be done this way because I need to take advantage of the command line parameters.

Now as you can see, IE is an entirely autonomous window -- that is, the embedding is faked.

That means, for example, that you can press Alt+F4 inside the "embedded" IE ... and it will close it without closing your AutoIt window!

Now how can I make sure that the focus doesn't go on IE?

For example, how can I intercept the focus being given to IE and add an event that would immediately pass it forward to someone else?

Any clever solution is accepted, even if you think out of the box.

the goal is simply to prevent wise guys from pressing key combinations on my "embedded" IE.

Edited by MonsieurOUXX

Share this post


Link to post
Share on other sites



Suppose you create an IE using the special function _IECreate2 found here :

It has to be done this way because I need to take advantage of the command line parameters.

Now as you can see, IE is an entirely autonomous window -- that is, the embedding is faked.

That means, for example, that you can press Alt+F4 inside the "embedded" IE ... and it will close it without closing your AutoIt window!

Now how can I make sure that the focus doesn't go on IE?

For example, how can I intercept the focus being given to IE and add an event that would immediately pass it forward to someone else?

Any clever solution is accepted, even if you think out of the box.

the goal is simply to prevent wise guys from pressing key combinations on my "embedded" IE.

Capture the key strokes with "HotKeySet" (If thats what its called)?

I remember people saying that hotkey thing prevents it from passing through and let's you decide what to do with it.


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

$hwnd_ie = WinGetHandle("Some IE Window")
$hwnd_other = WinGetHandle("Some Other Window")
 
While 1
   Sleep(10)
   If WinActive($hwnd_ie) Then
       WinActivate($hwnd_other)
   EndIf
Wend

Edit:

*gets wise*

$hwnd_ie = WinGetHandle("Some Embedded IE Window")
ProcessClose(WinGetProcess($hwnd_ie))
Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You can use GetWindowLong and SetWindowLong to set the window to

WS_EX_NOACTIVATE

Or you can use the equivalent functions in UDF

Edited by MilesAhead

Share this post


Link to post
Share on other sites

Thanks guys, your answers are all very valuable!

I'll run some tests.

However I'm a bit confused by this one :

$hwnd_ie = WinGetHandle("Some Embedded IE Window")
ProcessClose(WinGetProcess($hwnd_ie))

...won't this one kill my embedded IE? :) as we say in French "use a hammer to kill a fly" :D:rip::oops:

Share this post


Link to post
Share on other sites

Yep. It will. I was showing a way to kill your embedded window without needing alt-F4


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
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
Sign in to follow this  
Followers 0