1

Let's consider the following scenario: In my desktop machine i have two applications opened side by side, a browser and a text editor(half size of the display for each application).

How can I switch between those two applications, but without using alt-tab or win-tab or mouse clicks?

If is nothing default built on windows xp/vista or 7 how can I do that programmatically using c++? For example to press alt+l(or alt+1), to activate the left window and the alt+r(alt+2) to activate the right window.

thanks

2
  • Why the close votes? The words "C++" and "programmatically" definitely make this a programming question.
    – Thomas
    Dec 10, 2009 at 19:16
  • @Thomas As I read it, OP is asking for a built-in capability or an existing app, or short of that "how can I do it", which is far too vague for an SO programming question. Dec 10, 2009 at 19:20

4 Answers 4

4

Create an AutoHotKey script to grab those keyboard shortcuts and activate the program you want.

3

If you have the handles to those windows, you can use SetForegroundWindow.

You can get a windows handle if you know the title with FindWindow. This article explains how to get a window handle if you partially know the title (non-exact match), though I've never tried.

For your hot-keys, look at SetWindowsHookEx with WH_KEYBOARD as the hook type. You'll make a KeyboardProc, which Windows will call on key-presses. Here, you can capture your specific key-combinations and activate certain windows.

That said, Windows provides hot-keys for you, as outlined in other answers.

2

On Windows 7, you can switch to any of the first ten items on the taskbar (whether running or not) by pressing Windows+(1..0). You can drag taskbar items around to change the order.

2
  • 1
    This works a little different in Vista: Windows-1..9 opens the corresponding quick link from the bar next to your start menu
    – Jorn
    Dec 10, 2009 at 19:14
  • Yes, which doesn't answer the question. That's why I said On Windows 7.
    – SLaks
    Dec 10, 2009 at 19:19
1

Use this AutoHotKey script:

~LAlt & Tab::Send ^#{Tab}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .