58

Is there a shortcut in Windows 7 to switch between windows in a given application only? I very much like this feature in OS X; what is its equivalent in Windows?

jiejieup
  • 583

16 Answers16

61

If it is one of the first ten applications on the taskbar, then (Win)+n, where n is its position number, will select it and cycle through the windows (if there are more than one).  (Use 0 (zero) for the tenth application.)  For example, I have Windows Explorer and Internet Explorer pinned as the first two things on my taskbar, so I can use +1 to cycle through my directories and I can use +2 to cycle through my browsers.


Some odd notes:

  • If you press and hold and type (and release) a digit n, Windows will open the nth application on the taskbar.  Repeatedly tapping n will cycle through the windows of that program, as discussed above.  As stated by TranslucentCloud, if you then type Shift+n, it will cycle through them in reverse order, as with Alt+Tab and Ctrl+Tab, etc.

    If the nth application on the taskbar is pinned but not running, then +n will start it.

  • As ZYinMD points out, if there are multiple instances (windows) for task n, then +n will display the thumbnails for the tasks until you release the  key.  This can be useful if you have multiple instances (e.g., of Notepad or Word), since you may want to see which window is the one you want.  But this behavior might not always be desired.  ZYinMD points out that adding Ctrl (i.e., using +Ctrl+n) will go directly (“instantly”) to the task without showing the thumbnails.

  • But, if you press and hold and Shift, right from the beginning, and then type n, Windows will start a new instance (or at least a new window) of that application, even if it’s already running.  (This will fail for some applications, like Windows Media Player, that don’t allow multiple windows to run simultaneously.)

    And +Ctrl+Shift+n will start a new instance of application n as administrator.

  • +n seems not to work with the numeric keypad.

28

In Windows 7 and 8, although there is no shortcut I know of available from the keyboard alone, you can hold Ctrl while clicking the taskbar icon of the app you're interested in. Each time you do this a different window belonging to that app will come to the forefront.

In addition, the program VistaSwitcher sets up Win+F11 and Alt+` to switch between the current app's windows. (BTW, its web site says Windows 8 is not supported, but I've had luck with it under 8.1; the only problem I've seen so far is that it sometimes lists things like the search sidebar as open windows. I just ignore that, but YMMV.)

phuclv
  • 30,396
  • 15
  • 136
  • 260
23

You can use AutoHotkey: www.autohotkey.com

And put this script there:

!`:: ; Next window
WinGetClass, ActiveClass, A
WinGet, WinClassCount, Count, ahk_class %ActiveClass%
IF WinClassCount = 1
    Return
Else
WinGet, List, List, % "ahk_class " ActiveClass
Loop, % List
{
    index := List - A_Index + 1
    WinGet, State, MinMax, % "ahk_id " List%index%
    if (State <> -1)
    {
        WinID := List%index%
        break
    }
}
WinActivate, % "ahk_id " WinID
return

!^`:: ; Last window
WinGetClass, ActiveClass, A
WinGet, WinClassCount, Count, ahk_class %ActiveClass%
IF WinClassCount = 1
    Return
Else
WinGet, List, List, % "ahk_class " ActiveClass
Loop, % List
{
    index := List - A_Index + 1
    WinGet, State, MinMax, % "ahk_id " List%index%
    if (State <> -1)
    {
        WinID := List%index%
        break
    }
}
WinActivate, % "ahk_id " WinID
return

Works very well for me. Using Autohotkey I also made my copy/paste/undo,... keys like Mac. Works great!

Eras

Seperman
  • 331
11

Thanks, Erasmose, but your version of the autohotkey script will minimize a window if there are no other windows of that type. Sometimes you don't know, and minimizing is an annoying way to find out, so I modified your script like so:

!`::    ; Next window
WinGetClass, ActiveClass, A
WinGet, WinClassCount, Count, ahk_class %ActiveClass%
IF WinClassCount = 1
    Return
Else
WinSet, Bottom,, A
WinActivate, ahk_class %ActiveClass%
return

!+`::    ; Last window
WinGetClass, ActiveClass, A
WinActivateBottom, ahk_class %ActiveClass%
return

oh, and I also changed last class to use shift instead of ctrl since I that's the modifier to go backwards with several other keyboard shortcuts. I love autohotkey.

9

Easy Windows Switcher from Neosmart does exactly what you are after.

Here is the description from the Easy Windows Switcher Website

Easy Window Switcher makes switching between different windows as easy as alt+` (that's alt+backtick) like on a Mac. Forget having to alt+tab between a million-and-one different open windows to find the one you are looking for, with Easy Window Switcher, tabbing between windows of the same program is only a alt+` away.

Ishan
  • 3,432
7

Some applications that implement MDI provide Ctrl+Tab to switch between "Documents" under the same application instance. e.g. MS Office. But this is not a windows feature and is application dependent. For other software there are different short-cuts. e.g. Firefox does not provide this feature but there is an add-on that adds the functionality.

Additionally, here's a list of keyboard shortcuts provided in windows.

Also, there are existing discussions about Keyboard short-cuts in Windows.

Hope that helps.

6

I created an AutoHotkey script to switch between same application's windows that work with regular Window Apps, Chrome Shortcuts and Chrome Apps.

https://github.com/JuanmaMenendez/AutoHotkey-script-Open-Show-Apps/blob/master/AutoHotkey-script-Switch-Windows-same-App.ahk

Extra

In that Github repo there is another AutoHotkey script that could work well in tandem with this one, because you will be able to Open, Restore or Minimize your Apps using the hotkeys you want.

Example:

  • F7:: OpenOrShowAppBasedOnExeName("C:\Windows\System32\SnippingTool.exe")
  • F8:: OpenOrShowAppBasedOnWindowTitle("Gmail", "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --app=https://mail.google.com/mail/")
4

VistaSwitcher allows or for this feature. Its compatible with Windows 10, (although the name suggests otherwise). On Windows 8 and up, I suggest adding certain metro apps to the exclude list.

The top answer is good, but doesn't work on multi-monitor setups where the taskbar is set to only show icons on active monitor.

4

With AutoHotkey too, a more natural behavior:

; Switch between windows of the same application with Alt+(key above Tab)
; Icon: made by Freepik (www.freepik.com), licence CC 3.0 BY
;       from https://www.flaticon.com/free-icon/switch-window_71630
; Script Licence: CC0 (Public Domain)
; Source: https://framagit.org/dr4Ke/AutoHotkey_scripts

KeyName := GetKeyName("sc029")
Menu, Tray, Tip, Switch between windows of the same applications with 'Alt+%KeyName%'

*!SC029::
WinGetClass, ActiveClass, A
WinGet, WinClassCount, Count, ahk_class %ActiveClass%
If WinClassCount = 1
    Return
WinGet, List, List, % "ahk_class " ActiveClass

index := 0
if not GetKeyState("Shift") {
    index := 1
}
;MsgBox, Entering Loop
While GetKeyState("Alt") {
    If GetKeyState("Shift") {
        index := Mod(List + index - 2, List) + 1
    } else {
        index := Mod(List + index, List) + 1
    }
    WinGet, State, MinMax, % "ahk_id " List%index%
    if (State == -1)
    {
        continue
    }
    WinID := List%index%
    WinActivate, % "ahk_id " WinID
    ErrorLevel := 1
    sleep 50
    While (ErrorLevel != 0) and GetKeyState("Alt") {
        KeyWait, sc029, DT1
    }
}
return
2

If you don't want to bother with autohotkeys just for this particular task, I've found an app that does the job: https://github.com/sigoden/window-switcher (I'm not affiliated with it in any way). Like it better than Easy Windows Switcher from Neosmart since it's open source and configurable (e.g. you can change key combo to your liking).

Alex K
  • 41
1

In addition to what Scott (https://superuser.com/users/150988/scott) shared:

ctrl+repeatedly click over the app icon in the task-bar also will do the job.

1

Using Autohotkey, here's my version, which works with Chrome and Electron apps. It was modified from @user332861's answer, so that it correctly distinguishes between Chrome and Electron apps such as Slack and Visual Studio Code. (To do that, it uses ahk_exe instead of ahk_class)

!`::    ; Next window if using alt-backtick
    WinGet, ExeName, ProcessName , A
    WinGet, ExeCount, Count, ahk_exe %ExeName%
    If ExeCount = 1
        Return
    Else
        WinSet, Bottom,, A
        WinActivate, ahk_exe %ExeName%
return

!+`::    ; prev window, Alt+shift+backtick
    WinGet, ExeName, ProcessName , A
    WinActivateBottom, ahk_exe %ExeName%
return
otter.pro
  • 341
1
!`::
#`::
WinGet, ExeName, ProcessName, A
WinActivateBottom, ahk_exe %ExeName%
return

Simplified from @otter.pro's answer. This simply cycles backwards through the current application windows. Cycling forwards can cause brief flashes of other windows to appear. Since not seeing flashes is probably more important than bidirectional cycling, just don't cycle forwards. Furthermore, this answer allows #` as an alternative to !` since that's the key combination for the Mac shortcut.

cjfp
  • 21
1

For those of you who use AutoHotkey: if you followed other answers and made it work for alt `, but realized it won't work in Explorer windows, you could add these lines below ::, before other code:

If WinActive("ahk_exe Explorer.EXE") {
  Send ^#{1} ; change the number 1 to whichever position your explorer is pinned on Taskbar
  Return
}

This will fall back to use the method in the accepted answer for Explorer only.

ZYinMD
  • 517
0

I created an AutoHotkey script that integrates nicely with Windows Task Switcher (Alt+Tab), providing all of its benefits: previews of app windows, click to select, arrow key navigation, only activate the single window that you want. Invoke/navigate with Alt+` and Alt+Shift+` (backtick) to cycle between windows having the same process name as the current window. I find this more usable than Win+num as it works for any app (rather than having to remember the pinned slot number), window previews are larger, the background doesn't get blurred and it mixes seamlessly with Alt+Tab navigation. Tested on Windows 10.

The main trick is to temporarily hide non-target application windows from Task Switcher by setting WS_EX_TOOLWINDOW and unsetting WS_EX_APPWINDOW. In order to set these windows styles on windows running as administrator, AutoHotkey needs to be signed or run as admin. I followed the very easy signing instructions here.

Some related threads that contributed:

!`::
{
   WS_EX_TOOLWINDOW = 0x80
   WS_EX_APPWINDOW = 0x40000
   tw := []
   aw := []

   WinGet, processName, ProcessName, A

   DetectHiddenWindows, Off
   AltTab_window_list(1)

   Loop, %AltTab_ID_List_0%
   {
      wid := AltTab_ID_List_%A_Index%
      WinGet, processName2, ProcessName, ahk_id %wid%

      if (processName2 != processName)
      {
         WinGet, exStyle2, ExStyle, ahk_id %wid%

         if (!(exStyle2 & WS_EX_TOOLWINDOW))
         {
            tw.InsertAt(0, wid)
            WinSet, ExStyle, ^0x80, ahk_id %wid%
         }

         if ((exStyle2 & WS_EX_APPWINDOW))
         {
            aw.InsertAt(0, wid)
            WinSet, ExStyle, ^0x40000, ahk_id %wid%
         }
      }
   }

   Send {Alt Down}{Tab} ; Bring up switcher immediately

   KeyWait, ``, T.25  ; Go to next window; wait .25s before looping
   if (Errorlevel == 0)
   {
      While ( GetKeyState( "Alt","P" ) )
      {
         KeyWait, ``, D T.25
         if (Errorlevel == 0)
         {
            if (GetKeyState( "Shift","P" ))
            {
               Send {Alt Down}{Shift Down}{Tab}
               Sleep, 200
            }
            else
            {
               Send {Alt Down}{Tab}
               Sleep, 200
            }
         }
      }
   }

   Send {Alt Up} ; Close switcher on hotkey release

   for index, wid in tw
   {
      WinSet, ExStyle, ^0x80, ahk_id %wid%
   }

   for index, wid in aw
   {
      WinSet, ExStyle, ^0x40000, ahk_id %wid%
   }
}
return

AltTab_window_list(excludeToolWindows)
{
   global
   WS_EX_CONTROLPARENT =0x10000
   WS_EX_APPWINDOW =0x40000
   WS_EX_TOOLWINDOW =0x80
   WS_DISABLED =0x8000000
   WS_POPUP =0x80000000
   AltTab_ID_List_ =0
   WinGet, Window_List, List,,, Program Manager ; Gather a list of running programs
   id_list =
   Loop, %Window_List%
   {
      wid := Window_List%A_Index%
      WinGetTitle, wid_Title, ahk_id %wid%
      WinGet, Style, Style, ahk_id %wid%

      If ((Style & WS_DISABLED) or ! (wid_Title)) ; skip unimportant windows
         Continue

      WinGet, es, ExStyle, ahk_id %wid%
      Parent := Decimal_to_Hex( DllCall( "GetParent", "uint", wid ) )
      WinGetClass, Win_Class, ahk_id %wid%
      WinGet, Style_parent, Style, ahk_id %Parent%

      If ((excludeToolWindows & (es & WS_EX_TOOLWINDOW))
         or ((es & ws_ex_controlparent) and ! (Style & WS_POPUP) and !(Win_Class ="#32770") and ! (es & WS_EX_APPWINDOW)) ; pspad child window excluded
         or ((Style & WS_POPUP) and (Parent) and ((Style_parent & WS_DISABLED) =0))) ; notepad find window excluded ; note - some windows result in blank value so must test for zero instead of using NOT operator!
         continue
      AltTab_ID_List_ ++
      AltTab_ID_List_%AltTab_ID_List_% :=wid
   }  
   AltTab_ID_List_0 := AltTab_ID_List_
}

KrisG
  • 1
0

Ctrl + Win + [Number] (Tested on Windows 10)

This is the closest built-in solution I managed to figure out.

Difference compared to the other answers:

When Win + [Number] is used without Ctrl, it always start from the first window, which is annoying/not what I really want most of the time.

No 3rd party software needed.

No mouse click needed.

Taylan
  • 722