focus on IE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dawn

    focus on IE

    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.


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: focus on IE

    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 SetForegroundWi ndow (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]
    - mvp@spam.guard. caspershouse.co m

    "dawn" <dawn4715@hotma il.com> wrote in message
    news:Mlblb.9528 7$EP6.4562059@p hobos.telenet-ops.be...[color=blue]
    > Thanks for your promptly answer Nicholas,
    >
    > but I do have another question. How do I set the focus to the IE window,[/color]
    so[color=blue]
    > that it becomes active. I've been googling on it, but none of the answer
    > seem to work.
    >
    > thanks again,
    >
    > Bart.
    >
    >[/color]


    Comment

    • Lee Alexander

      #3
      Re: focus on IE

      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 [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
      message news:ult9DN%23l DHA.1960@TK2MSF TNGP12.phx.gbl. ..[color=blue]
      > Bart,
      >
      > You can do this by calling the FindWindow (to find the Window handle[/color]
      of[color=blue]
      > IE, if you don't already have it) and then SetForegroundWi ndow (to bring[/color]
      it[color=blue]
      > 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]
      > - mvp@spam.guard. caspershouse.co m
      >
      > "dawn" <dawn4715@hotma il.com> wrote in message
      > news:Mlblb.9528 7$EP6.4562059@p hobos.telenet-ops.be...[color=green]
      > > Thanks for your promptly answer Nicholas,
      > >
      > > but I do have another question. How do I set the focus to the IE window,[/color]
      > so[color=green]
      > > that it becomes active. I've been googling on it, but none of the answer
      > > seem to work.
      > >
      > > thanks again,
      > >
      > > Bart.
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Ignacio Machin \( .NET/ C#  MVP \)

        #4
        Re: focus on IE

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

        Cheers,

        --
        Ignacio Machin,
        ignacio.machin AT dot.state.fl.us
        Florida Department Of Transportation


        "dawn" <dawn4715@hotma il.com> wrote in message
        news:Mlblb.9528 7$EP6.4562059@p hobos.telenet-ops.be...[color=blue]
        > Thanks for your promptly answer Nicholas,
        >
        > but I do have another question. How do I set the focus to the IE window,[/color]
        so[color=blue]
        > that it becomes active. I've been googling on it, but none of the answer
        > seem to work.
        >
        > thanks again,
        >
        > Bart.
        >
        >[/color]


        Comment

        Working...