Skip to content

Instantly share code, notes, and snippets.

@snmishra
Created September 13, 2019 15:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save snmishra/794c5f41693510c46ba9bedc839696a8 to your computer and use it in GitHub Desktop.
Save snmishra/794c5f41693510c46ba9bedc839696a8 to your computer and use it in GitHub Desktop.
Switch windows by process name using Alt+` and S
; Based on https://superuser.com/a/768060/542406
!`:: ; Next window
WinGet, ActiveProcessName, ProcessName, A
WinGet, WinClassCount, Count, ahk_exe %ActiveProcessName%
IF WinClassCount = 1
Return
Else
WinSet, Bottom,, A
WinActivate, ahk_exe %ActiveProcessName%
return
!+`:: ; Last window
WinGet, ActiveProcessName, ProcessName, A
WinGet, WinClassCount, Count, ahk_exe %ActiveProcessName%
IF WinClassCount = 1
Return
Else
WinActivateBottom, ahk_exe %ActiveProcessName%
return
@voidray
Copy link

voidray commented Nov 21, 2019

Did you test it with File Explorer windows? It seems to focus some hidden explorer.exe windows (maybe the desktop?) when I want to cycle thorugh all explorer windows.

@snmishra
Copy link
Author

Hmm, no. I never used it with Explorer in the last two months. Indeed it doesn't work there. I am open to updating the gist if you find a fix. It's not a problem I'm facing, and I'm not an AHK expert, so I probably won't spend any time fixing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment