473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Calling ALT-TAB

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
Nov 16 '05 #1
6 13755
Interesting. I vaguely remember doing something similar in VB6 so I
could use SendKeys to populate fields in another application.
Unfortunately, that was quite some time ago, and in the wrong
language, but at least it is possible to do a similar thing.

IIRC, I had to check the title parameter of the currently running
windows, decide which to switch to, and then run the switch.

I know it's not a lot of use to you, but at least now you know it can
be done.

On Thu, 3 Mar 2005 08:27:51 -0500, "Chris Mason" <te******@gmail.com>
wrote:
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


Nov 16 '05 #2
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="SetForegroundWindo w")]
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" <te******@gmail.com> wrote in message
news:u2**************@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

Nov 16 '05 #3
hi,

sorry, I took the declarations from the pocketpc app, the correct dll to
import is user32.dll no coredll.dl

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:e8****************@TK2MSFTNGP15.phx.gbl...
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="SetForegroundWindo w")]
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" <te******@gmail.com> wrote in message
news:u2**************@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


Nov 16 '05 #4
Well the SendKeys method looks like it has some hope. A couple of small
issues though. The first is that when the alt-tab window comes up, it just
goes right away. It does not stay for any length of period. Do you know if
there is a way to send the key and have it stay until the user selects a
program from the list. SendKeys.SendWait() did not seem to help either.

The second problem was that the alt-tab window would only come up if I had
another window such as a messagebox come up after it. Otherwise nothing
would have happened. Any idea what may be causing that?

Thanks again

"Marc Jennings" <Ma**********@community.nospam> wrote in message
news:7l********************************@4ax.com...
Interesting. I vaguely remember doing something similar in VB6 so I
could use SendKeys to populate fields in another application.
Unfortunately, that was quite some time ago, and in the wrong
language, but at least it is possible to do a similar thing.

IIRC, I had to check the title parameter of the currently running
windows, decide which to switch to, and then run the switch.

I know it's not a lot of use to you, but at least now you know it can
be done.

On Thu, 3 Mar 2005 08:27:51 -0500, "Chris Mason" <te******@gmail.com>
wrote:
I have an application that runs full screen on a system and I would like tobe able to (at times) switch another program using an ALT-TAB like
interface. However the system only has a touchscreen display so doing thisfrom 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

Nov 16 '05 #5
Thanks for the suggestions, but it is not quite what I need. The problem is
that I do not know what the other program that I am going to be changing
focus is. It could be any application. And I was trying to avoid having to
go through and enumerate all the windows that are open, put them in a box
for the user to choose from, and then make the switch... especially when
windows does all that for me when I figure out how to tap into that :)

Chris

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:ue**************@TK2MSFTNGP15.phx.gbl...
hi,

sorry, I took the declarations from the pocketpc app, the correct dll to
import is user32.dll no coredll.dl

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:e8****************@TK2MSFTNGP15.phx.gbl...
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="SetForegroundWindo w")]
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" <te******@gmail.com> wrote in message
news:u2**************@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



Nov 16 '05 #6
If you want to emulate the behaviour of ALT+TAB key combination just like if
you're pressing and holding the keys, you can use PInvoke calling the
keybd_event() API, instead of using the SendKeys class. The API provides
more possibilities to send keystrokes and emulate keystroke behaviour.

Here is an example for your situation:

[DllImport("user32")]
public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int
dwExtraInfo);
private const byte VK_MENU = 0x12;
private const byte VK_TAB = 0x09;
private const int KEYEVENTF_EXTENDEDKEY = 0x01;
private const int KEYEVENTF_KEYUP = 0x02;

private void button1_Click(object sender, System.EventArgs e)
{
keybd_event(VK_MENU,0,0,0);
keybd_event(VK_TAB,0,0,0);
System.Threading.Thread.Sleep(1000);
keybd_event(VK_TAB,0,0,0);
System.Threading.Thread.Sleep(1000);
keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
}

Hope it helps.

-- Ricky Lee
==================================================
^o^ "When all doors are closed, God will open a Windows" ^o^
==================================================
"Chris Mason" <te******@gmail.com> wrote in message
news:u2**************@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

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Joseph Suprenant | last post by:
Hello all, I have a C++ program, it does some calculations on things and then prints out a file in the format in which GNUPLOT can use. So my question is how would i call GNUPLOT from my C++...
6
by: Adrian | last post by:
I need to have 2 submit buttons in one form calling the same page. I just need to know which was used. Being able to pass a hidden form input for each would be ideal. How can I do this?? ...
5
by: Bob Hairgrove | last post by:
Consider the following: #include <string> class A { public: A( const std::string & full_name , const std::string & display_name) : m_full_name(full_name)
8
by: Lian | last post by:
Hi all, It is a newbie's question about html tag "img". The attributes "title" and "alt" for "img" seems having the same function. So what is the main difference between them? Can i use them at...
1
by: Garmt de Vries | last post by:
On my pages, I use a couple of images (with appropriate alt texts of course) for decoration purposes. For example: <p> Blablabla about some topic.<br> <a href="foo.html"> <img src="see.gif"...
12
by: Yuan Zhong | last post by:
Hi, Can someone please explain me what's going on during a call to a function. Specifically, I wanted to know what's going on in Stacks. Why is it ok to pass only 2 parameters or 5 parameters...
1
by: talisman | last post by:
hi, one of my friends was saying it's not a good idea to do this. certainly on my Solaris box man system makes a similar statement. could anyone elaborate in practicality how risky this is?...
2
by: eholz1 | last post by:
Hello PHP Group, I have a php page that calls another php page to load a image from a database (mysql) in to the calling page. It works like this: first_view.php has <img src="image.php?img=5"...
4
by: nash | last post by:
Hi All, I am working on Message Hooking.I am trying to change the value of lParam before calling CallNextHookEx() function.. and its value is getting changed but the contents remains same.. Where...
2
by: ph33red | last post by:
Hi, I'm having a problem getting my code to pull the appropriate information when I call for it via URL. (example: http://..../.php?id=2). For some reason I can't get it to pull the information for...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.