473,396 Members | 1,866 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,396 software developers and data experts.

Programmatic Alt+Tab

How can I issue an Alt+Tab command from within VB.NET code?

Specifically, I am trying to swap to the next application in the Alt+Tab
order in a way that is reversible with a single Alt+Tab to get back to my
application. That sounds redundant, but what I've found is that if I
minimize my app, it goes to the very end of the Alt+Tab list instead of
being the next in line.
Related Ramblings:
Oddly enough, in VB6, I had this behavior. Setting frm.WindowState =
vbMinimize would minimize my app but still keep it next in line for Alt+Tab.
The same (equivalent) code in VB.NET places it at the end of the Alt+Tab
list, which is no good for what I'm after.

Now I checked, and if I minimize my app by hand, it also goes to the back of
the order, so I think that the VB.NET WindowState=Minimize command more
correctly mimics user behavior. Nevertheless, it isn't what I'm after. So
I've decided that it's ok if my app doesn't minimize; it just needs to give
focus to the previous window in a way that allows the user to Alt+Tab back
to it with a single Alt+Tab.

Any help is appreciated.
-AJ
Nov 20 '05 #1
4 6266
When you want to activate the other application, try using the following

--------------------------
Microsoft.VisualBasic.AppActivate("Untitled - Notepad")
-----------------------

This should activate the application. Change "Untitled-Notepad" to whatever
the text in the title bar of the application is (You can also use the
Program ID). It should also leave your application next in the Alt+Tab
order.

HTH,

Trev

"Adam J. Schaff" <ju**@maine.rr.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
How can I issue an Alt+Tab command from within VB.NET code?

Specifically, I am trying to swap to the next application in the Alt+Tab
order in a way that is reversible with a single Alt+Tab to get back to my
application. That sounds redundant, but what I've found is that if I
minimize my app, it goes to the very end of the Alt+Tab list instead of
being the next in line.
Related Ramblings:
Oddly enough, in VB6, I had this behavior. Setting frm.WindowState =
vbMinimize would minimize my app but still keep it next in line for Alt+Tab. The same (equivalent) code in VB.NET places it at the end of the Alt+Tab
list, which is no good for what I'm after.

Now I checked, and if I minimize my app by hand, it also goes to the back of the order, so I think that the VB.NET WindowState=Minimize command more
correctly mimics user behavior. Nevertheless, it isn't what I'm after. So
I've decided that it's ok if my app doesn't minimize; it just needs to give focus to the previous window in a way that allows the user to Alt+Tab back
to it with a single Alt+Tab.

Any help is appreciated.
-AJ

Nov 20 '05 #2
When you want to activate the other application, try using the following

--------------------------
Microsoft.VisualBasic.AppActivate("Untitled - Notepad")
-----------------------

This should activate the application. Change "Untitled-Notepad" to whatever
the text in the title bar of the application is (You can also use the
Program ID). It should also leave your application next in the Alt+Tab
order.

HTH,

Trev

"Adam J. Schaff" <ju**@maine.rr.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
How can I issue an Alt+Tab command from within VB.NET code?

Specifically, I am trying to swap to the next application in the Alt+Tab
order in a way that is reversible with a single Alt+Tab to get back to my
application. That sounds redundant, but what I've found is that if I
minimize my app, it goes to the very end of the Alt+Tab list instead of
being the next in line.
Related Ramblings:
Oddly enough, in VB6, I had this behavior. Setting frm.WindowState =
vbMinimize would minimize my app but still keep it next in line for Alt+Tab. The same (equivalent) code in VB.NET places it at the end of the Alt+Tab
list, which is no good for what I'm after.

Now I checked, and if I minimize my app by hand, it also goes to the back of the order, so I think that the VB.NET WindowState=Minimize command more
correctly mimics user behavior. Nevertheless, it isn't what I'm after. So
I've decided that it's ok if my app doesn't minimize; it just needs to give focus to the previous window in a way that allows the user to Alt+Tab back
to it with a single Alt+Tab.

Any help is appreciated.
-AJ

Nov 20 '05 #3
Hmm, perhaps I should have been more specific. I don't know what application
I want to move to, so I can't use its name. I simply want to switch to
whichever application is next in the tab order. So what I want is behavior
exactly like pressing Alt+Tab once.

"Codemonkey" <hu*********@hotmail.com> wrote in message
news:eV**************@TK2MSFTNGP10.phx.gbl...
When you want to activate the other application, try using the following

--------------------------
Microsoft.VisualBasic.AppActivate("Untitled - Notepad")
-----------------------

This should activate the application. Change "Untitled-Notepad" to whatever the text in the title bar of the application is (You can also use the
Program ID). It should also leave your application next in the Alt+Tab
order.

HTH,

Trev

"Adam J. Schaff" <ju**@maine.rr.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
How can I issue an Alt+Tab command from within VB.NET code?

Specifically, I am trying to swap to the next application in the Alt+Tab
order in a way that is reversible with a single Alt+Tab to get back to my application. That sounds redundant, but what I've found is that if I
minimize my app, it goes to the very end of the Alt+Tab list instead of
being the next in line.
Related Ramblings:
Oddly enough, in VB6, I had this behavior. Setting frm.WindowState =
vbMinimize would minimize my app but still keep it next in line for Alt+Tab.
The same (equivalent) code in VB.NET places it at the end of the Alt+Tab
list, which is no good for what I'm after.

Now I checked, and if I minimize my app by hand, it also goes to the back of
the order, so I think that the VB.NET WindowState=Minimize command more
correctly mimics user behavior. Nevertheless, it isn't what I'm after.

So I've decided that it's ok if my app doesn't minimize; it just needs to

give
focus to the previous window in a way that allows the user to Alt+Tab back to it with a single Alt+Tab.

Any help is appreciated.
-AJ


Nov 20 '05 #4
Try the following:

System.Windows.Forms.SendKeys.Send("%{TAB}")

This sends the ALT+Tab combination. I've tried this on WindowsXP and it seem
to work the way it should.

Hope this helps,

Trev.
"Adam J. Schaff" <ju**@maine.rr.com> wrote in message
news:u%****************@TK2MSFTNGP11.phx.gbl...
Hmm, perhaps I should have been more specific. I don't know what application I want to move to, so I can't use its name. I simply want to switch to
whichever application is next in the tab order. So what I want is behavior
exactly like pressing Alt+Tab once.

"Codemonkey" <hu*********@hotmail.com> wrote in message
news:eV**************@TK2MSFTNGP10.phx.gbl...
When you want to activate the other application, try using the following

--------------------------
Microsoft.VisualBasic.AppActivate("Untitled - Notepad")
-----------------------

This should activate the application. Change "Untitled-Notepad" to

whatever
the text in the title bar of the application is (You can also use the
Program ID). It should also leave your application next in the Alt+Tab
order.

HTH,

Trev

"Adam J. Schaff" <ju**@maine.rr.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
How can I issue an Alt+Tab command from within VB.NET code?

Specifically, I am trying to swap to the next application in the Alt+Tab order in a way that is reversible with a single Alt+Tab to get back to my application. That sounds redundant, but what I've found is that if I
minimize my app, it goes to the very end of the Alt+Tab list instead of being the next in line.
Related Ramblings:
Oddly enough, in VB6, I had this behavior. Setting frm.WindowState =
vbMinimize would minimize my app but still keep it next in line for

Alt+Tab.
The same (equivalent) code in VB.NET places it at the end of the Alt+Tab list, which is no good for what I'm after.

Now I checked, and if I minimize my app by hand, it also goes to the back
of
the order, so I think that the VB.NET WindowState=Minimize command more correctly mimics user behavior. Nevertheless, it isn't what I'm after.

So I've decided that it's ok if my app doesn't minimize; it just needs to

give
focus to the previous window in a way that allows the user to Alt+Tab back to it with a single Alt+Tab.

Any help is appreciated.
-AJ



Nov 20 '05 #5

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

Similar topics

3
by: Dale | last post by:
I'm using the NotifyIcon component on a form within a Windows application that will normally show no interface. NotifyIcon does add an icon as required to the notification area of the Task Bar. ...
3
by: meska | last post by:
Is there a way in c# to hide program , that it would show in alt+tab ?
3
by: Nick | last post by:
Hi, I am tring to display a form that does not show in either the task bar or when the user alt-tabs. The form is running full screen and is set to have no border. Nick
6
by: Chris Mason | last post by:
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...
0
by: Adam J. Schaff | last post by:
How can I issue an Alt+Tab command from within VB.NET code? Specifically, I am trying to swap to the next application in the Alt+Tab order in a way that is reversible with a single Alt+Tab to get...
9
by: Peter Larsen | last post by:
Hi, I have asked this question before, but did not get anything useful from it - so sorry that i am asking again !! How do i prevent an application from appears more than once in the ALT+TAB...
5
by: kh | last post by:
My app filters windows messages because of some custom window functionality I have implemented. Does my window receive a message when the user selects Alt-Tab? If so which message? Many thanks ...
10
by: thupham | last post by:
Dear all friend, I want disable Ctl+Alt+Del; Ctrl+Esc; Ctrl+tab, Alt+Tab, Start button, ctrl+Alt+Del, lock all keys on the keyboard. Have you ever do it in C#. Help me. Thanks for all reply.
2
by: Swan | last post by:
How can I restrict alt+tab and start menu from keyboard while program executing(VB)?I am posting what I tried-- form.frm Option Explicit Private Sub Form_Load() HookKeyboard End Sub...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
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,...

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.