473,657 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 13824
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("core dll",EntryPoint ="FindWindow ")]
public static extern IntPtr FindWindow(stri ng lpClassName,str ing
lpWindowName);

[DllImport("core dll",EntryPoint ="SetForeground Window")]
public static extern bool SetForegroundWi ndow(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
SetForegroundWi ndow(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******** ******@tk2msftn gp13.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.mach in AT dot.state.fl.us > wrote
in message news:e8******** ********@TK2MSF TNGP15.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("core dll",EntryPoint ="FindWindow ")]
public static extern IntPtr FindWindow(stri ng lpClassName,str ing
lpWindowName);

[DllImport("core dll",EntryPoint ="SetForeground Window")]
public static extern bool SetForegroundWi ndow(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
SetForegroundWi ndow(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******** ******@tk2msftn gp13.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.SendWa it() 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**********@c ommunity.nospam > wrote in message
news:7l******** *************** *********@4ax.c om...
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.mach in AT dot.state.fl.us > wrote
in message news:ue******** ******@TK2MSFTN GP15.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.mach in AT dot.state.fl.us > wrote in message news:e8******** ********@TK2MSF TNGP15.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("core dll",EntryPoint ="FindWindow ")]
public static extern IntPtr FindWindow(stri ng lpClassName,str ing
lpWindowName);

[DllImport("core dll",EntryPoint ="SetForeground Window")]
public static extern bool SetForegroundWi ndow(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
SetForegroundWi ndow(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******** ******@tk2msftn gp13.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("user 32")]
public static extern void keybd_event(byt e bVk, byte bScan, int dwFlags, int
dwExtraInfo);
private const byte VK_MENU = 0x12;
private const byte VK_TAB = 0x09;
private const int KEYEVENTF_EXTEN DEDKEY = 0x01;
private const int KEYEVENTF_KEYUP = 0x02;

private void button1_Click(o bject sender, System.EventArg s e)
{
keybd_event(VK_ MENU,0,0,0);
keybd_event(VK_ TAB,0,0,0);
System.Threadin g.Thread.Sleep( 1000);
keybd_event(VK_ TAB,0,0,0);
System.Threadin g.Thread.Sleep( 1000);
keybd_event(VK_ MENU,0,KEYEVENT F_KEYUP,0);
keybd_event(VK_ MENU,0,KEYEVENT F_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******** ******@tk2msftn gp13.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
10695
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++ program. I know in some operating systems you can do system("gnuplot"); But not with red hat 7.3. So could some kind soul help me out? After it starts up GNUPLOT my program will terminate. Thanks
6
5672
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?? Thanks!,Adrian
5
11328
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
10639
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 the same time and set different values? Thank you for suggestions!
1
6667
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" alt="See:">More info on bla... </a> </p>
12
1512
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 when the function prototype requires 3. thanks.
1
1559
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? i'm currently calling the system() function from within my 64 bit c app..
2
1673
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" width="200" border="1" alt="Image of Sunset"> the image.php opens the database and returns the image to the page (first_view.php).
4
6853
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 as if I am able to change wParam. For Eg: if I press any key 'S' and if I want to modify it to 'B' by using wParam its possible.. Can u now please help me in modifying this 'S' to 'B' using lParam? Regards,
2
1669
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 ID #2 (or any ID over 1) and input that information into my dynamic page. No matter what ID i type, or even if I neglect to type in an ID to begin with, it displays the same information. What am I doing wrong? The entire code for my page is pasted...
0
8403
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8833
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8610
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.