Re: Calling ALT-TAB

From: Ignacio Machin \( .NET/ C# MVP \) ("Ignacio)
Date: 03/03/05


Date: Thu, 3 Mar 2005 09:44:33 -0500

Hi,

 You will have to PInvoke, first you need to get the handle of the target
window, then you need to give it focus.

Here is some code:

[DllImport("coredll",EntryPoint="FindWindow")]
public static extern IntPtr FindWindow(string lpClassName,string
lpWindowName);

[DllImport("coredll",EntryPoint="SetForegroundWindow")]
public static extern bool SetForegroundWindow(IntPtr hWnd);

 //this is how you use it

   IntPtr mainwin = FindWindow(null, "Product Details");

   if(! mainwin.Equals(new System.IntPtr(0)))
   {
    //Ask for login/Password
    SetForegroundWindow(mainwin);
                        }

cheers,

-- 
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Chris Mason" <tealdeer@gmail.com> wrote in message 
news:u2ZHmS$HFHA.2620@tk2msftngp13.phx.gbl...
>I have an application that runs full screen on a system and I would like to
> be able to (at times) switch another program using an ALT-TAB like
> interface.  However the system only has a touchscreen display so doing 
> this
> from a keyboard is not an option.  Is there any way I can instantiate the
> built in ALT-TAB window or is there any way I can generate the ALT-TAB
> event/message progammatically.
>
> Thanks for any help.
> Chris
>
> 


Relevant Pages

  • Re: Problems hiding the main form and displaying only a tray icon
    ... > I want my application to run most of the time as just an notify icon> visible in the system tray, with some dialogs windows that open if the> user selects an option from the context menu on the tray icon. ... It was all fine until I noticed that the> form was visible in the Alt-Tab menu and once you had alt-tabbed to it> there was no way of hiding it again:(> ... > But today I have noticed that now I can no longer minimize or hide the> form it appears as a minizied tool window in the bottom left of my desktop> when the application is running and even worse if the user double clicks> on the title bar the window expands to its normal size, apart from the> form is empty and there's no way to minimize it again! ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Grafik C#, screen
    ... public static extern IntPtr FindWindow(string className, ... public static extern IntPtr GetLastActivePopup(IntPtr hWnd); ... specified window ... An application should specify this flag when ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: BringWindowToTop: "Simulate" "ALT-Tab" keys
    ... Thanks for your Simulation of the ALT-tab keys. ... And then asks for the window handle with PostMessage, ... After the second programme has started, ...
    (microsoft.public.vc.mfc)
  • Re: Z-order
    ... "Kathea Banshou" ... > Alt-tab cycles through ALL open documents/programs. ... > window you are using rather than the main window, ... >> I am having a terrible time with XP's Z order. ...
    (microsoft.public.windowsxp.newusers)
  • Re: JDK 1.6 and JFrame icon
    ... for the main window is not displaying under Windows when using Alt-Tab. ... I does display fine in the window itself and in the task bar, but not when I use Alt-Tab. ... Maybe a bug related to the new 1.6 feature which allows you to specify multiple icon images. ...
    (comp.lang.java.gui)