focus on IE

  • Thread starter Thread starter dawn
  • Start date Start date
D

dawn

Thanks for your promptly answer Nicholas,

but I do have another question. How do I set the focus to the IE window, so
that it becomes active. I've been googling on it, but none of the answer
seem to work.

thanks again,

Bart.
 
Bart,

You can do this by calling the FindWindow (to find the Window handle of
IE, if you don't already have it) and then SetForegroundWindow (to bring it
to the foreground) to set the active window before calling the methods on
the SendKeys class. Of course, you will have to call these through the
P/Invoke layer.
 
FYI
I seem to remember that this will not actually bring the window to the
foreground unless the caller is in the same process space, otherwise you
just get the relevent taskbar item flashing for attention. This was
deliberately put in by MS to stop rogue applications snatching focus.

Regards
Lee
Nicholas Paldino said:
Bart,

You can do this by calling the FindWindow (to find the Window handle of
IE, if you don't already have it) and then SetForegroundWindow (to bring it
to the foreground) to set the active window before calling the methods on
the SendKeys class. Of course, you will have to call these through the
P/Invoke layer.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

dawn said:
Thanks for your promptly answer Nicholas,

but I do have another question. How do I set the focus to the IE window, so
that it becomes active. I've been googling on it, but none of the answer
seem to work.

thanks again,

Bart.
 
If you control the page yo are going to display on the IE you could use
window.focus();

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top